OpenLB 1.8.1
Loading...
Searching...
No Matches
setBoundary3D.h
Go to the documentation of this file.
1/* This file is part of the OpenLB library
2 *
3 * Copyright (C) 2021 Lennart Neukamm, Adrian Kummerlaender
4 * E-mail contact: info@openlb.net
5 * The most recent release of OpenLB can be downloaded at
6 * <http://www.openlb.net/>
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public
19 * License along with this program; if not, write to the Free
20 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 * Boston, MA 02110-1301, USA.
22*/
23
24#ifndef SET_BOUNDARY_3D_H
25#define SET_BOUNDARY_3D_H
26
27namespace olb {
28
30template<typename T, typename DESCRIPTOR >
31void setBoundary(BlockLattice<T,DESCRIPTOR>& _block, int iX,int iY,int iZ,
33{
34 if (dynamics) {
35 _block.defineDynamics({iX, iY, iZ}, dynamics);
36 auto cell = _block.get(iX,iY,iZ);
37 dynamics->initialize(cell);
38 }
39 if (postProcessor && !_block.isPadding({iX,iY,iZ})) {
40 _block.addPostProcessor(*postProcessor);
41 }
42}
43
44template<typename T, typename DESCRIPTOR >
45void setBoundary(BlockLattice<T,DESCRIPTOR>& _block, int iX,int iY,int iZ,
46 Dynamics<T,DESCRIPTOR>* dynamics)
47{
48 if (dynamics) {
49 _block.defineDynamics({iX, iY, iZ}, dynamics);
50 auto cell = _block.get(iX,iY,iZ);
51 dynamics->initialize(cell);
52 }
53}
54
56template<typename T, typename DESCRIPTOR>
58{
59 /* local boundaries: _overlap = 0;
60 * interp boundaries: _overlap = 1;
61 * bouzidi boundaries: _overlap = 1;
62 * extField boundaries: _overlap = 1;
63 * advectionDiffusion boundaries: _overlap = 1;
64 */
65
66 if (_overlap == 0) {
67 return;
68 }
69
70 auto& communicator = sLattice.getCommunicator(stage::PostStream());
71 communicator.template requestField<descriptors::POPULATION>();
72
73 SuperGeometry<T,3>& superGeometry = indicator->getSuperGeometry();
74 for (int iCloc = 0; iCloc < sLattice.getLoadBalancer().size(); ++iCloc) {
75 const int nX = superGeometry.getBlockGeometry(iCloc).getNx();
76 const int nY = superGeometry.getBlockGeometry(iCloc).getNy();
77 const int nZ = superGeometry.getBlockGeometry(iCloc).getNz();
78
79 for (int iX = -_overlap; iX < nX+_overlap; ++iX) {
80 for (int iY = -_overlap; iY < nY+_overlap; ++iY) {
81 for (int iZ = -_overlap; iZ < nZ+_overlap; ++iZ) {
82 if (iX < 0 || iX > nX - 1 ||
83 iY < 0 || iY > nY - 1 ||
84 iZ < 0 || iZ > nZ - 1 ) { // if within overlap
85 if (superGeometry.getBlockGeometry(iCloc).getMaterial(iX,iY,iZ) != 0) {
86 bool found = false;
87 for (int iXo = -_overlap; iXo <= _overlap && !found; ++iXo) {
88 for (int iYo = -_overlap; iYo <= _overlap && !found; ++iYo) {
89 for (int iZo = -_overlap; iZo <= _overlap && !found; ++iZo) {
90 const int nextX = iXo + iX;
91 const int nextY = iYo + iY;
92 const int nextZ = iZo + iZ;
93 if (indicator->getBlockIndicatorF(iCloc)(nextX, nextY, nextZ)
94 && nextX >= -_overlap && nextX < nX+_overlap
95 && nextY >= -_overlap && nextY < nY+_overlap
96 && nextZ >= -_overlap && nextZ < nZ+_overlap) {
97 communicator.requestCell({iCloc, iX, iY, iZ});
98 found = true;
99 }
100 }
101 }
102 }
103 }
104 }
105 }
106 }
107 }
108 }
109
110 communicator.exchangeRequests();
111}
112
113namespace boundaryhelper {
114
115//Instatiates DYNAMICS with three normal values from discreteNormal vector n
116template <
117 typename T, typename DESCRIPTOR,
118 template <int...> typename DYNAMICS
119>
121{
122 if (n == Vector<int,3> {1, 1, 1}) {
123 return DynamicsPromise(meta::id<DYNAMICS<1,1,1>>{});
124 }
125 else if (n == Vector<int,3> {1, -1, 1}) {
126 return DynamicsPromise(meta::id<DYNAMICS<1,-1,1>>{});
127 }
128 else if (n == Vector<int,3> {1, 1, -1}) {
129 return DynamicsPromise(meta::id<DYNAMICS<1,1,-1>>{});
130 }
131 else if (n == Vector<int,3> {1, -1, -1}) {
132 return DynamicsPromise(meta::id<DYNAMICS<1,-1,-1>>{});
133 }
134 else if (n == Vector<int,3> {-1, 1, 1}) {
135 return DynamicsPromise(meta::id<DYNAMICS<-1,1,1>>{});
136 }
137 else if (n == Vector<int,3> {-1, -1, 1}) {
138 return DynamicsPromise(meta::id<DYNAMICS<-1,-1,1>>{});
139 }
140 else if (n == Vector<int,3> {-1, 1, -1}) {
141 return DynamicsPromise(meta::id<DYNAMICS<-1,1,-1>>{});
142 }
143 else if (n == Vector<int,3> {-1, -1, -1}) {
144 return DynamicsPromise(meta::id<DYNAMICS<-1,-1,-1>>{});
145 }
146 else {
147 throw std::runtime_error("Could not set Boundary.");
148 }
149}
150
151//Instatiates DYNAMICS with a plane and two normal values from discreteNormal vector n
152template <
153 typename T, typename DESCRIPTOR,
154 template <int...> typename DYNAMICS
155>
157{
158 if (n == Vector<int,3> {0, 1, 1}) {
159 return DynamicsPromise(meta::id<DYNAMICS<0,1,1>>{});
160 }
161 else if (n == Vector<int,3> {0, -1, 1}) {
162 return DynamicsPromise(meta::id<DYNAMICS<0,-1,1>>{});
163 }
164 else if (n == Vector<int,3> {0, 1, -1}) {
165 return DynamicsPromise(meta::id<DYNAMICS<0,1,-1>>{});
166 }
167 else if (n == Vector<int,3> {0, -1, -1}) {
168 return DynamicsPromise(meta::id<DYNAMICS<0,-1,-1>>{});
169 }
170 else if (n == Vector<int,3> {1, 0, 1}) {
171 return DynamicsPromise(meta::id<DYNAMICS<1,1,1>>{});
172 }
173 else if (n == Vector<int,3> {-1, 0, -1}) {
174 return DynamicsPromise(meta::id<DYNAMICS<1,-1,-1>>{});
175 }
176 else if (n == Vector<int,3> {-1, 0, 1}) {
177 return DynamicsPromise(meta::id<DYNAMICS<1,1,-1>>{});
178 }
179 else if (n == Vector<int,3> {1, 0, -1}) {
180 return DynamicsPromise(meta::id<DYNAMICS<1,-1,1>>{});
181 }
182 else if (n == Vector<int,3> {1, 1, 0}) {
183 return DynamicsPromise(meta::id<DYNAMICS<2,1,1>>{});
184 }
185 else if (n == Vector<int,3> {-1, 1, 0}) {
186 return DynamicsPromise(meta::id<DYNAMICS<2,-1,1>>{});
187 }
188 else if (n == Vector<int,3> {1, -1, 0}) {
189 return DynamicsPromise(meta::id<DYNAMICS<2,1,-1>>{});
190 }
191 else if (n == Vector<int,3> {-1, -1, 0}) {
192 return DynamicsPromise(meta::id<DYNAMICS<2,-1,-1>>{});
193 }
194 else {
195 throw std::invalid_argument("Invalid normal");
196 }
197}
198
199//Instatiates DYNAMICS with a direction and an orientation
200template <
201 typename T, typename DESCRIPTOR,
202 template <int...> typename DYNAMICS
203>
205{
206 if (n == Vector<int,3> {-1, 0, 0}) {
207 return DynamicsPromise(meta::id<DYNAMICS<0,-1>>{});
208 }
209 else if (n == Vector<int,3> {1, 0, 0}) {
210 return DynamicsPromise(meta::id<DYNAMICS<0,1>>{});
211 }
212 else if (n == Vector<int,3> {0, -1, 0}) {
213 return DynamicsPromise(meta::id<DYNAMICS<1,-1>>{});
214 }
215 else if (n == Vector<int,3> {0, 1, 0}) {
216 return DynamicsPromise(meta::id<DYNAMICS<1,1>>{});
217 }
218 else if (n == Vector<int,3> {0, 0, -1}) {
219 return DynamicsPromise(meta::id<DYNAMICS<2,-1>>{});
220 }
221 else if (n == Vector<int,3> {0, 0, 1}) {
222 return DynamicsPromise(meta::id<DYNAMICS<2,1>>{});
223 }
224 else {
225 throw std::runtime_error("Could not set Boundary.");
226 }
227}
228
229//constructs Dynamics with a Momenta, a plane and two normals as template args
230template <
231 typename T, typename DESCRIPTOR,
232 template <typename,typename,typename,int,int,int> typename DYNAMICS,
233 typename MOMENTA
234>
236 template <int x, int y, int z>
237 using ConcreteDynamics = DYNAMICS<T,DESCRIPTOR,MOMENTA,x,y,z>;
238
242};
243
244//constructs Dynamics with template args MixinDynamics and a Momenta that expects a plane and two normals
245template <
246 typename T, typename DESCRIPTOR,
247 template <typename,typename,typename,typename> typename DYNAMICS,
248 typename MIXIN,
249 template <int...> typename MOMENTA
250>
252 template <int... PlaneAndNormal>
253 using ConcreteDynamics = DYNAMICS<T,DESCRIPTOR,MIXIN,MOMENTA<PlaneAndNormal...>>;
254
258};
259
260//constructs Dynamics with template args MixinDynamics, Momenta, plane normal1 and normal2
261template <
262 typename T, typename DESCRIPTOR,
263 template <typename,typename,typename,typename,int,int,int> typename DYNAMICS,
264 typename MIXIN,
265 typename MOMENTA
266>
268 template <int x, int y, int z>
269 using ConcreteDynamics = DYNAMICS<T,DESCRIPTOR,MIXIN,MOMENTA,x,y,z>;
270
274};
275
276//Instantiates TYPE derived from RESULT with direction and orientation
277template <
278 typename RESULT, typename T, typename DESCRIPTOR,
279 template <typename,typename,int,int> typename TYPE
280>
282{
283 if (n == Vector<int,3> {-1, 0, 0}) {
284 return meta::id<TYPE<T,DESCRIPTOR,0,-1>>();
285 }
286 else if (n == Vector<int,3> {1, 0, 0}) {
288 }
289 else if (n == Vector<int,3> {0, -1, 0}) {
290 return meta::id<TYPE<T,DESCRIPTOR,1,-1>>();
291 }
292 else if (n == Vector<int,3> {0, 1, 0}) {
294 }
295 else if (n == Vector<int,3> {0, 0, -1}) {
296 return meta::id<TYPE<T,DESCRIPTOR,2,-1>>();
297 }
298 else if (n == Vector<int,3> {0, 0, 1}) {
300 }
301 else {
302 throw std::runtime_error("Could not set Boundary.");
303 }
304}
305
306//Instantiates TYPE derived from RESULT with values from descreteNormal Vector n
307//RESULT can be either Dynamics or PostProcessorGenerator3D
308template <
309 typename RESULT, typename T, typename DESCRIPTOR,
310 template <typename,typename,int,int,int> typename TYPE,
311 typename... ARGS
312>
313RESULT* constructForNormal(Vector<int,3> n, ARGS&&... args)
314{
315 if (n == Vector<int,3> {1, 1, 1}) {
316 return new TYPE<T,DESCRIPTOR,1,1,1>(std::forward<decltype(args)>(args)...);
317 }
318 else if (n == Vector<int,3> {1, -1, 1}) {
319 return new TYPE<T,DESCRIPTOR,1,-1,1>(std::forward<decltype(args)>(args)...);
320 }
321 else if (n == Vector<int,3> {1, 1, -1}) {
322 return new TYPE<T,DESCRIPTOR,1,1,-1>(std::forward<decltype(args)>(args)...);
323 }
324 else if (n == Vector<int,3> {1, -1, -1}) {
325 return new TYPE<T,DESCRIPTOR,1,-1,-1>(std::forward<decltype(args)>(args)...);
326 }
327 else if (n == Vector<int,3> {-1, 1, 1}) {
328 return new TYPE<T,DESCRIPTOR,-1,1,1>(std::forward<decltype(args)>(args)...);
329 }
330 else if (n == Vector<int,3> {-1, -1, 1}) {
331 return new TYPE<T,DESCRIPTOR,-1,-1,1>(std::forward<decltype(args)>(args)...);
332 }
333 else if (n == Vector<int,3> {-1, 1, -1}) {
334 return new TYPE<T,DESCRIPTOR,-1,1,-1>(std::forward<decltype(args)>(args)...);
335 }
336 else if (n == Vector<int,3> {-1, -1, -1}) {
337 return new TYPE<T,DESCRIPTOR,-1,-1,-1>(std::forward<decltype(args)>(args)...);
338 }
339 else {
340 return nullptr;
341 }
342}
343
344template <
345 typename RESULT,
346 template <int...> typename TYPE
347>
349{
350 if (n == Vector<int,3> {1, 1, 1}) {
351 return meta::id<TYPE<1,1,1>>();
352 }
353 else if (n == Vector<int,3> {1, -1, 1}) {
354 return meta::id<TYPE<1,-1,1>>();
355 }
356 else if (n == Vector<int,3> {1, 1, -1}) {
357 return meta::id<TYPE<1,1,-1>>();
358 }
359 else if (n == Vector<int,3> {1, -1, -1}) {
360 return meta::id<TYPE<1,-1,-1>>();
361 }
362 else if (n == Vector<int,3> {-1, 1, 1}) {
363 return meta::id<TYPE<-1,1,1>>();
364 }
365 else if (n == Vector<int,3> {-1, -1, 1}) {
366 return meta::id<TYPE<-1,-1,1>>();
367 }
368 else if (n == Vector<int,3> {-1, 1, -1}) {
369 return meta::id<TYPE<-1,1,-1>>();
370 }
371 else if (n == Vector<int,3> {-1, -1, -1}) {
372 return meta::id<TYPE<-1,-1,-1>>();
373 }
374 else if (n == Vector<int,3> {-1, -1, 0}) {
375 return meta::id<TYPE<-1,-1,0>>();
376 }
377 else if (n == Vector<int,3> {-1, 0, 0}) {
378 return meta::id<TYPE<-1,0,0>>();
379 }
380 else if (n == Vector<int,3> {1, 0, 0}) {
381 return meta::id<TYPE<1,0,0>>();
382 }
383 else if (n == Vector<int,3> {0, -1, 0}) {
384 return meta::id<TYPE<0,-1,0>>();
385 }
386 else if (n == Vector<int,3> {-1, 0, -1}) {
387 return meta::id<TYPE<-1,0,-1>>();
388 }
389 else if (n == Vector<int,3> {0, 1, 0}) {
390 return meta::id<TYPE<0,1,0>>();
391 }
392 else if (n == Vector<int,3> {0, 0, -1}) {
393 return meta::id<TYPE<0,0,-1>>();
394 }
395 else if (n == Vector<int,3> {-1, 1, 0}) {
396 return meta::id<TYPE<-1,1,0>>();
397 }
398 else if (n == Vector<int,3> {0, -1, -1}) {
399 return meta::id<TYPE<0,-1,-1>>();
400 }
401 else if (n == Vector<int,3> {0, -1, 1}) {
402 return meta::id<TYPE<0,-1,1>>();
403 }
404 else if (n == Vector<int,3> {-1, 0, 1}) {
405 return meta::id<TYPE<-1,0,1>>();
406 }
407 else if (n == Vector<int,3> {1, 0, -1}) {
408 return meta::id<TYPE<1,0,-1>>();
409 }
410 else if (n == Vector<int,3> {0, 0, 1}) {
411 return meta::id<TYPE<0,0,1>>();
412 }
413 else if (n == Vector<int,3> {0, 1, -1}) {
414 return meta::id<TYPE<0,1,-1>>();
415 }
416 else if (n == Vector<int,3> {0, 1, 1}) {
417 return meta::id<TYPE<0,1,1>>();
418 }
419 else if (n == Vector<int,3> {1, 0, 1}) {
420 return meta::id<TYPE<1,0,1>>();
421 }
422 else if (n == Vector<int,3> {1, -1, 0}) {
423 return meta::id<TYPE<1,-1,0>>();
424 }
425 else if (n == Vector<int,3> {1, 1, 0}) {
426 return meta::id<TYPE<1,1,0>>();
427 }
428 else {
429 throw std::domain_error("Invalid normal");
430 }
431}
432
433template <
434 typename RESULT,
435 typename T, typename DESCRIPTOR,
436 template <int,int,int> typename TYPE
437>
441
442template <
443 typename RESULT, typename T, typename DESCRIPTOR,
444 template <typename,typename,int,int,int> typename TYPE
445>
447{
448 if (n == Vector<int,3> {1, 1, 1}) {
449 return meta::id<TYPE<T,DESCRIPTOR,1,1,1>>();
450 }
451 else if (n == Vector<int,3> {1, -1, 1}) {
452 return meta::id<TYPE<T,DESCRIPTOR,1,-1,1>>();
453 }
454 else if (n == Vector<int,3> {1, 1, -1}) {
455 return meta::id<TYPE<T,DESCRIPTOR,1,1,-1>>();
456 }
457 else if (n == Vector<int,3> {1, -1, -1}) {
458 return meta::id<TYPE<T,DESCRIPTOR,1,-1,-1>>();
459 }
460 else if (n == Vector<int,3> {-1, 1, 1}) {
461 return meta::id<TYPE<T,DESCRIPTOR,-1,1,1>>();
462 }
463 else if (n == Vector<int,3> {-1, -1, 1}) {
464 return meta::id<TYPE<T,DESCRIPTOR,-1,-1,1>>();
465 }
466 else if (n == Vector<int,3> {-1, 1, -1}) {
467 return meta::id<TYPE<T,DESCRIPTOR,-1,1,-1>>();
468 }
469 else if (n == Vector<int,3> {-1, -1, -1}) {
470 return meta::id<TYPE<T,DESCRIPTOR,-1,-1,-1>>();
471 }
472 else if (n == Vector<int,3> {-1, -1, 0}) {
473 return meta::id<TYPE<T,DESCRIPTOR,-1,-1,0>>();
474 }
475 else if (n == Vector<int,3> {-1, 0, 0}) {
476 return meta::id<TYPE<T,DESCRIPTOR,-1,0,0>>();
477 }
478 else if (n == Vector<int,3> {1, 0, 0}) {
479 return meta::id<TYPE<T,DESCRIPTOR,1,0,0>>();
480 }
481 else if (n == Vector<int,3> {0, -1, 0}) {
482 return meta::id<TYPE<T,DESCRIPTOR,0,-1,0>>();
483 }
484 else if (n == Vector<int,3> {-1, 0, -1}) {
485 return meta::id<TYPE<T,DESCRIPTOR,-1,0,-1>>();
486 }
487 else if (n == Vector<int,3> {0, 1, 0}) {
488 return meta::id<TYPE<T,DESCRIPTOR,0,1,0>>();
489 }
490 else if (n == Vector<int,3> {0, 0, -1}) {
491 return meta::id<TYPE<T,DESCRIPTOR,0,0,-1>>();
492 }
493 else if (n == Vector<int,3> {-1, 1, 0}) {
494 return meta::id<TYPE<T,DESCRIPTOR,-1,1,0>>();
495 }
496 else if (n == Vector<int,3> {0, -1, -1}) {
497 return meta::id<TYPE<T,DESCRIPTOR,0,-1,-1>>();
498 }
499 else if (n == Vector<int,3> {0, -1, 1}) {
500 return meta::id<TYPE<T,DESCRIPTOR,0,-1,1>>();
501 }
502 else if (n == Vector<int,3> {-1, 0, 1}) {
503 return meta::id<TYPE<T,DESCRIPTOR,-1,0,1>>();
504 }
505 else if (n == Vector<int,3> {1, 0, -1}) {
506 return meta::id<TYPE<T,DESCRIPTOR,1,0,-1>>();
507 }
508 else if (n == Vector<int,3> {0, 0, 1}) {
509 return meta::id<TYPE<T,DESCRIPTOR,0,0,1>>();
510 }
511 else if (n == Vector<int,3> {0, 1, -1}) {
512 return meta::id<TYPE<T,DESCRIPTOR,0,1,-1>>();
513 }
514 else if (n == Vector<int,3> {0, 1, 1}) {
515 return meta::id<TYPE<T,DESCRIPTOR,0,1,1>>();
516 }
517 else if (n == Vector<int,3> {1, 0, 1}) {
518 return meta::id<TYPE<T,DESCRIPTOR,1,0,1>>();
519 }
520 else if (n == Vector<int,3> {1, -1, 0}) {
521 return meta::id<TYPE<T,DESCRIPTOR,1,-1,0>>();
522 }
523 else if (n == Vector<int,3> {1, 1, 0}) {
524 return meta::id<TYPE<T,DESCRIPTOR,1,1,0>>();
525 }
526 else {
527 throw std::domain_error("Invalid normal");
528 }
529}
530
531//Instantiates TYPE derived from RESULT with values from descreteNormal Vector n
532//RESULT can be either Dynamics or PostProcessorGenerator3D
533template <
534 typename RESULT, typename T, typename DESCRIPTOR,
535 template <typename,typename,int,int,int> typename TYPE,
536 typename... ARGS
537>
538RESULT* constructForNormalSpecial(Vector<int,3> n, ARGS&&... args)
539{
540 if (n == Vector<int,3> {0, 1, 1}) {
541 return new TYPE<T,DESCRIPTOR,0,1,1>(std::forward<decltype(args)>(args)...);
542 }
543 else if (n == Vector<int,3> {0, -1, 1}) {
544 return new TYPE<T,DESCRIPTOR,0,-1,1>(std::forward<decltype(args)>(args)...);
545 }
546 else if (n == Vector<int,3> {0, 1, -1}) {
547 return new TYPE<T,DESCRIPTOR,0,1,-1>(std::forward<decltype(args)>(args)...);
548 }
549 else if (n == Vector<int,3> {0, -1, -1}) {
550 return new TYPE<T,DESCRIPTOR,0,-1,-1>(std::forward<decltype(args)>(args)...);
551 }
552 else if (n == Vector<int,3> {1, 0, 1}) {
553 return new TYPE<T,DESCRIPTOR,1,1,1>(std::forward<decltype(args)>(args)...);
554 }
555 else if (n == Vector<int,3> {-1, 0, -1}) {
556 return new TYPE<T,DESCRIPTOR,1,-1,-1>(std::forward<decltype(args)>(args)...);
557 }
558 else if (n == Vector<int,3> {-1, 0, 1}) {
559 return new TYPE<T,DESCRIPTOR,1,1,-1>(std::forward<decltype(args)>(args)...);
560 }
561 else if (n == Vector<int,3> {1, 0, -1}) {
562 return new TYPE<T,DESCRIPTOR,1,-1,1>(std::forward<decltype(args)>(args)...);
563 }
564 else if (n == Vector<int,3> {1, 1, 0}) {
565 return new TYPE<T,DESCRIPTOR,2,1,1>(std::forward<decltype(args)>(args)...);
566 }
567 else if (n == Vector<int,3> {-1, 1, 0}) {
568 return new TYPE<T,DESCRIPTOR,2,-1,1>(std::forward<decltype(args)>(args)...);
569 }
570 else if (n == Vector<int,3> {1, -1, 0}) {
571 return new TYPE<T,DESCRIPTOR,2,1,-1>(std::forward<decltype(args)>(args)...);
572 }
573 else if (n == Vector<int,3> {-1, -1, 0}) {
574 return new TYPE<T,DESCRIPTOR,2,-1,-1>(std::forward<decltype(args)>(args)...);
575 }
576 else {
577 return nullptr;
578 }
579}
580
581template <
582 typename PROMISE,
583 typename T, typename DESCRIPTOR,
584 template <typename,typename,int,int,int> typename TYPE
585>
587{
588 if (n == Vector<int,3> {0, 1, 1}) {
590 }
591 else if (n == Vector<int,3> {0, -1, 1}) {
592 return meta::id<TYPE<T,DESCRIPTOR,0,-1,1>>();
593 }
594 else if (n == Vector<int,3> {0, 1, -1}) {
595 return meta::id<TYPE<T,DESCRIPTOR,0,1,-1>>();
596 }
597 else if (n == Vector<int,3> {0, -1, -1}) {
598 return meta::id<TYPE<T,DESCRIPTOR,0,-1,-1>>();
599 }
600 else if (n == Vector<int,3> {1, 0, 1}) {
602 }
603 else if (n == Vector<int,3> {-1, 0, -1}) {
604 return meta::id<TYPE<T,DESCRIPTOR,1,-1,-1>>();
605 }
606 else if (n == Vector<int,3> {-1, 0, 1}) {
607 return meta::id<TYPE<T,DESCRIPTOR,1,1,-1>>();
608 }
609 else if (n == Vector<int,3> {1, 0, -1}) {
610 return meta::id<TYPE<T,DESCRIPTOR,1,-1,1>>();
611 }
612 else if (n == Vector<int,3> {1, 1, 0}) {
614 }
615 else if (n == Vector<int,3> {-1, 1, 0}) {
616 return meta::id<TYPE<T,DESCRIPTOR,2,-1,1>>();
617 }
618 else if (n == Vector<int,3> {1, -1, 0}) {
619 return meta::id<TYPE<T,DESCRIPTOR,2,1,-1>>();
620 }
621 else if (n == Vector<int,3> {-1, -1, 0}) {
622 return meta::id<TYPE<T,DESCRIPTOR,2,-1,-1>>();
623 }
624 else {
625 throw std::domain_error("Invalid normal");
626 }
627}
628
629template <
630 typename T, typename DESCRIPTOR,
631 template<typename,typename,int,int> typename TYPE
632>
637
638//constructs TYPE derived from PostProcessorGenerator3D with three normals as template args
639template <
640 typename T, typename DESCRIPTOR,
641 template<typename,typename,int,int,int> typename TYPE,
642 typename... ARGS
643>
645{
646 return constructForNormal<PostProcessorGenerator3D<T,DESCRIPTOR>,T,DESCRIPTOR,TYPE>(n, std::forward<decltype(args)>(args)...);
647}
648
649template <
650 typename T, typename DESCRIPTOR,
651 template <int...> typename TYPE
652>
657
658template <
659 typename T, typename DESCRIPTOR,
660 template<typename,typename,int,int,int> typename TYPE
661>
663{
664 return promiseForNormal<PostProcessorPromise<T,DESCRIPTOR>,T,DESCRIPTOR,TYPE>(n);
665}
666
667//constructs TYPE derived from PostProcessorGenerator3D with a plane and two normals as template args
668template <
669 typename T, typename DESCRIPTOR,
670 template<typename,typename,int,int,int> typename TYPE,
671 typename... ARGS
672>
674{
675 return constructForNormalSpecial<PostProcessorGenerator3D<T,DESCRIPTOR>,T,DESCRIPTOR,TYPE>(n, std::forward<decltype(args)>(args)...);
676}
677
678template <
679 typename T, typename DESCRIPTOR,
680 template<typename,typename,int,int,int> typename TYPE
681>
686
687}//namespace boundaryhelper
688
689template <typename T, typename DESCRIPTOR, template<typename,typename,int...> typename OPERATOR>
691 FunctorPtr<SuperIndicatorF3D<T>>&& boundaryI,
694{
695 for (int iCloc = 0; iCloc < sLattice.getLoadBalancer().size(); ++iCloc) {
697 boundaryI->getBlockIndicatorF(iCloc),
698 fluidI->getBlockIndicatorF(iCloc),
699 outsideI->getBlockIndicatorF(iCloc));
700 }
701 addPoints2CommBC(sLattice, std::forward<decltype(boundaryI)>(boundaryI), 1);
702}
703
704template <typename T, typename DESCRIPTOR, template<typename,typename,int...> typename OPERATOR>
706 BlockIndicatorF3D<T>& boundaryI,
707 BlockIndicatorF3D<T>& fluidI,
708 BlockIndicatorF3D<T>& outsideI)
709{
710 OstreamManager clout(std::cout, "setOperatorForNormal");
711 auto& blockGeometryStructure = boundaryI.getBlockGeometry();
712 blockGeometryStructure.forSpatialLocations([&](auto iX, auto iY, auto iZ) {
713 if ( blockGeometryStructure.getNeighborhoodRadius({iX, iY, iZ}) >= 1
714 && boundaryI(iX, iY, iZ)) {
715 auto [normalType, normal] = computeBoundaryTypeAndNormal(fluidI, outsideI, {iX,iY,iZ});
716 if (normal[0]!=0 || normal[1]!=0 || normal[2]!=0) {
717 block.addPostProcessor(
718 typeid(stage::PostCollide), {iX,iY,iZ},
720 );
721 }
722 else {
723 clout << "Warning: Could not setOperatorForNormal("
724 << iX << ", " << iY << ", " << iZ
725 << "), discreteNormal=" << normal << "" << std::endl;
726 }
727 }
728 });
729}
730
731}
732
733#endif
#define OPERATOR(OP, rhs)
Definition aDiffTape.h:64
Base block indicator functor.
Definition aliases.h:204
BlockGeometry< T, 3 > & getBlockGeometry()
Get underlying block geometry structure.
void forSpatialLocations(F f) const
Factory for instances of a specific Dynamics type.
Smart pointer for managing the various ways of passing functors around.
Definition functorPtr.h:60
class for marking output with some text
Factory for instances of a specific OPERATOR type.
Representation of a statistic for a parallel 2D geometry.
BlockGeometry< T, D > & getBlockGeometry(int locIC)
Read and write access to a single block geometry.
Base indicator functor (discrete)
Definition aliases.h:194
Super class maintaining block lattices for a cuboid decomposition.
SuperCommunicator< T, SuperLattice > & getCommunicator(STAGE stage=STAGE())
Return communicator for given communication stage.
BlockLattice< T, DESCRIPTOR > & getBlock(int locC)
Return BlockLattice with local index locC.
LoadBalancer< T > & getLoadBalancer()
Read and write access to the load balancer.
Plain old scalar vector.
DynamicsPromise< T, DESCRIPTOR > constructConcreteDynamicsForDirectionOrientation(Vector< int, 2 > n)
PostProcessorGenerator2D< T, DESCRIPTOR > * constructPostProcessorForNormal(Vector< int, 2 > n, ARGS &&... args)
RESULT * constructForNormalSpecial(Vector< int, 3 > n, ARGS &&... args)
PostProcessorPromise< T, DESCRIPTOR > promisePostProcessorForNormalSpecial(Vector< int, 3 > n)
PROMISE promiseForDirectionOrientation(Vector< int, 2 > n)
RESULT * constructForNormal(Vector< int, 2 > n, ARGS &&... args)
PostProcessorPromise< T, DESCRIPTOR > promisePostProcessorForNormal(Vector< int, 2 > n)
PostProcessorGenerator3D< T, DESCRIPTOR > * constructPostProcessorForNormalSpecial(Vector< int, 3 > n, ARGS &&... args)
DynamicsPromise< T, DESCRIPTOR > constructConcreteDynamicsForNormalSpecial(Vector< int, 3 > n)
RESULT promiseForNormal(Vector< int, 2 > n)
DynamicsPromise< T, DESCRIPTOR > constructConcreteDynamicsForNormal(Vector< int, 2 > n)
PROMISE promiseForNormalSpecial(Vector< int, 3 > n)
PostProcessorPromise< T, DESCRIPTOR > promisePostProcessorForDirectionOrientation(Vector< int, 2 > n)
Top level namespace for all of OpenLB.
void addPoints2CommBC(SuperLattice< T, DESCRIPTOR > &sLattice, FunctorPtr< SuperIndicatorF2D< T > > &&indicator, int _overlap)
Adds needed Cells to the Communicator _commBC in SuperLattice.
void setOperatorForNormal(SuperLattice< T, DESCRIPTOR > &sLattice, FunctorPtr< SuperIndicatorF3D< T > > &&boundaryI, FunctorPtr< SuperIndicatorF3D< T > > &&fluidI, FunctorPtr< SuperIndicatorF3D< T > > &&outsideI)
DynamicsPromise(meta::id< DYNAMICS >) -> DynamicsPromise< typename DYNAMICS::value_t, typename DYNAMICS::descriptor_t >
void setBoundary(BlockLattice< T, DESCRIPTOR > &block, int iX, int iY, Dynamics< T, DESCRIPTOR > *dynamics, PostProcessorGenerator2D< T, DESCRIPTOR > *postProcessor)
std::pair< DiscreteNormalType, Vector< int, 2 > > computeBoundaryTypeAndNormal(BlockIndicatorF2D< T > &fluidI, BlockIndicatorF2D< T > &outsideI, Vector< int, 2 > latticeR)
Returns type (e.g. edge / corner) and discrete normal in 2D.
Interface for per-cell dynamics.
Definition interface.h:56
virtual void initialize(Cell< T, DESCRIPTOR > &cell)
Initialize dynamics-specific data for cell.
Definition interface.h:70
DYNAMICS< T, DESCRIPTOR, MOMENTA, x, y, z > ConcreteDynamics
DYNAMICS< T, DESCRIPTOR, MIXIN, MOMENTA, x, y, z > ConcreteDynamics
DYNAMICS< T, DESCRIPTOR, MIXIN, MOMENTA< PlaneAndNormal... > > ConcreteDynamics
Identity type to pass non-constructible types as value.
Definition meta.h:79
Communication after collision.
Definition stages.h:34
Communication after propagation.
Definition stages.h:36