24#ifndef SET_BOUNDARY_3D_H
25#define SET_BOUNDARY_3D_H
30template<
typename T,
typename DESCRIPTOR >
35 _block.defineDynamics({iX, iY, iZ}, dynamics);
36 auto cell = _block.get(iX,iY,iZ);
39 if (postProcessor && !_block.isPadding({iX,iY,iZ})) {
40 _block.addPostProcessor(*postProcessor);
44template<
typename T,
typename DESCRIPTOR >
49 _block.defineDynamics({iX, iY, iZ}, dynamics);
50 auto cell = _block.get(iX,iY,iZ);
56template<
typename T,
typename DESCRIPTOR>
71 communicator.template requestField<descriptors::POPULATION>();
74 for (
int iCloc = 0; iCloc < sLattice.
getLoadBalancer().size(); ++iCloc) {
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 ) {
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});
110 communicator.exchangeRequests();
113namespace boundaryhelper {
117 typename T,
typename DESCRIPTOR,
118 template <
int...>
typename DYNAMICS
147 throw std::runtime_error(
"Could not set Boundary.");
153 typename T,
typename DESCRIPTOR,
154 template <
int...>
typename DYNAMICS
195 throw std::invalid_argument(
"Invalid normal");
201 typename T,
typename DESCRIPTOR,
202 template <
int...>
typename DYNAMICS
225 throw std::runtime_error(
"Could not set Boundary.");
231 typename T,
typename DESCRIPTOR,
232 template <
typename,
typename,
typename,
int,
int,
int>
typename DYNAMICS,
236 template <
int x,
int y,
int z>
246 typename T,
typename DESCRIPTOR,
247 template <
typename,
typename,
typename,
typename>
typename DYNAMICS,
249 template <
int...>
typename MOMENTA
252 template <
int... PlaneAndNormal>
262 typename T,
typename DESCRIPTOR,
263 template <
typename,
typename,
typename,
typename,
int,
int,
int>
typename DYNAMICS,
268 template <
int x,
int y,
int z>
278 typename RESULT,
typename T,
typename DESCRIPTOR,
279 template <
typename,
typename,
int,
int>
typename TYPE
284 return meta::id<TYPE<T,DESCRIPTOR,0,-1>>();
290 return meta::id<TYPE<T,DESCRIPTOR,1,-1>>();
296 return meta::id<TYPE<T,DESCRIPTOR,2,-1>>();
302 throw std::runtime_error(
"Could not set Boundary.");
309 typename RESULT,
typename T,
typename DESCRIPTOR,
310 template <
typename,
typename,
int,
int,
int>
typename TYPE,
316 return new TYPE<T,DESCRIPTOR,1,1,1>(std::forward<
decltype(args)>(args)...);
319 return new TYPE<T,DESCRIPTOR,1,-1,1>(std::forward<decltype(args)>(args)...);
322 return new TYPE<T,DESCRIPTOR,1,1,-1>(std::forward<decltype(args)>(args)...);
325 return new TYPE<T,DESCRIPTOR,1,-1,-1>(std::forward<decltype(args)>(args)...);
328 return new TYPE<T,DESCRIPTOR,-1,1,1>(std::forward<decltype(args)>(args)...);
331 return new TYPE<T,DESCRIPTOR,-1,-1,1>(std::forward<decltype(args)>(args)...);
334 return new TYPE<T,DESCRIPTOR,-1,1,-1>(std::forward<decltype(args)>(args)...);
337 return new TYPE<T,DESCRIPTOR,-1,-1,-1>(std::forward<decltype(args)>(args)...);
346 template <
int...>
typename TYPE
429 throw std::domain_error(
"Invalid normal");
435 typename T,
typename DESCRIPTOR,
436 template <
int,
int,
int>
typename TYPE
443 typename RESULT,
typename T,
typename DESCRIPTOR,
444 template <
typename,
typename,
int,
int,
int>
typename TYPE
449 return meta::id<TYPE<T,DESCRIPTOR,1,1,1>>();
451 else if (n == Vector<int,3> {1, -1, 1}) {
452 return meta::id<TYPE<T,DESCRIPTOR,1,-1,1>>();
454 else if (n == Vector<int,3> {1, 1, -1}) {
455 return meta::id<TYPE<T,DESCRIPTOR,1,1,-1>>();
457 else if (n == Vector<int,3> {1, -1, -1}) {
458 return meta::id<TYPE<T,DESCRIPTOR,1,-1,-1>>();
460 else if (n == Vector<int,3> {-1, 1, 1}) {
461 return meta::id<TYPE<T,DESCRIPTOR,-1,1,1>>();
463 else if (n == Vector<int,3> {-1, -1, 1}) {
464 return meta::id<TYPE<T,DESCRIPTOR,-1,-1,1>>();
466 else if (n == Vector<int,3> {-1, 1, -1}) {
467 return meta::id<TYPE<T,DESCRIPTOR,-1,1,-1>>();
469 else if (n == Vector<int,3> {-1, -1, -1}) {
470 return meta::id<TYPE<T,DESCRIPTOR,-1,-1,-1>>();
472 else if (n == Vector<int,3> {-1, -1, 0}) {
473 return meta::id<TYPE<T,DESCRIPTOR,-1,-1,0>>();
475 else if (n == Vector<int,3> {-1, 0, 0}) {
476 return meta::id<TYPE<T,DESCRIPTOR,-1,0,0>>();
478 else if (n == Vector<int,3> {1, 0, 0}) {
479 return meta::id<TYPE<T,DESCRIPTOR,1,0,0>>();
481 else if (n == Vector<int,3> {0, -1, 0}) {
482 return meta::id<TYPE<T,DESCRIPTOR,0,-1,0>>();
484 else if (n == Vector<int,3> {-1, 0, -1}) {
485 return meta::id<TYPE<T,DESCRIPTOR,-1,0,-1>>();
487 else if (n == Vector<int,3> {0, 1, 0}) {
488 return meta::id<TYPE<T,DESCRIPTOR,0,1,0>>();
490 else if (n == Vector<int,3> {0, 0, -1}) {
491 return meta::id<TYPE<T,DESCRIPTOR,0,0,-1>>();
493 else if (n == Vector<int,3> {-1, 1, 0}) {
494 return meta::id<TYPE<T,DESCRIPTOR,-1,1,0>>();
496 else if (n == Vector<int,3> {0, -1, -1}) {
497 return meta::id<TYPE<T,DESCRIPTOR,0,-1,-1>>();
499 else if (n == Vector<int,3> {0, -1, 1}) {
500 return meta::id<TYPE<T,DESCRIPTOR,0,-1,1>>();
502 else if (n == Vector<int,3> {-1, 0, 1}) {
503 return meta::id<TYPE<T,DESCRIPTOR,-1,0,1>>();
505 else if (n == Vector<int,3> {1, 0, -1}) {
506 return meta::id<TYPE<T,DESCRIPTOR,1,0,-1>>();
508 else if (n == Vector<int,3> {0, 0, 1}) {
509 return meta::id<TYPE<T,DESCRIPTOR,0,0,1>>();
511 else if (n == Vector<int,3> {0, 1, -1}) {
512 return meta::id<TYPE<T,DESCRIPTOR,0,1,-1>>();
514 else if (n == Vector<int,3> {0, 1, 1}) {
515 return meta::id<TYPE<T,DESCRIPTOR,0,1,1>>();
517 else if (n == Vector<int,3> {1, 0, 1}) {
518 return meta::id<TYPE<T,DESCRIPTOR,1,0,1>>();
520 else if (n == Vector<int,3> {1, -1, 0}) {
521 return meta::id<TYPE<T,DESCRIPTOR,1,-1,0>>();
523 else if (n == Vector<int,3> {1, 1, 0}) {
524 return meta::id<TYPE<T,DESCRIPTOR,1,1,0>>();
527 throw std::domain_error(
"Invalid normal");
534 typename RESULT,
typename T,
typename DESCRIPTOR,
535 template <
typename,
typename,
int,
int,
int>
typename TYPE,
541 return new TYPE<T,DESCRIPTOR,0,1,1>(std::forward<
decltype(args)>(args)...);
544 return new TYPE<T,DESCRIPTOR,0,-1,1>(std::forward<decltype(args)>(args)...);
547 return new TYPE<T,DESCRIPTOR,0,1,-1>(std::forward<decltype(args)>(args)...);
550 return new TYPE<T,DESCRIPTOR,0,-1,-1>(std::forward<decltype(args)>(args)...);
553 return new TYPE<T,DESCRIPTOR,1,1,1>(std::forward<
decltype(args)>(args)...);
556 return new TYPE<T,DESCRIPTOR,1,-1,-1>(std::forward<decltype(args)>(args)...);
559 return new TYPE<T,DESCRIPTOR,1,1,-1>(std::forward<decltype(args)>(args)...);
562 return new TYPE<T,DESCRIPTOR,1,-1,1>(std::forward<decltype(args)>(args)...);
565 return new TYPE<T,DESCRIPTOR,2,1,1>(std::forward<
decltype(args)>(args)...);
568 return new TYPE<T,DESCRIPTOR,2,-1,1>(std::forward<decltype(args)>(args)...);
571 return new TYPE<T,DESCRIPTOR,2,1,-1>(std::forward<decltype(args)>(args)...);
574 return new TYPE<T,DESCRIPTOR,2,-1,-1>(std::forward<decltype(args)>(args)...);
583 typename T,
typename DESCRIPTOR,
584 template <
typename,
typename,
int,
int,
int>
typename TYPE
592 return meta::id<TYPE<T,DESCRIPTOR,0,-1,1>>();
595 return meta::id<TYPE<T,DESCRIPTOR,0,1,-1>>();
598 return meta::id<TYPE<T,DESCRIPTOR,0,-1,-1>>();
604 return meta::id<TYPE<T,DESCRIPTOR,1,-1,-1>>();
607 return meta::id<TYPE<T,DESCRIPTOR,1,1,-1>>();
610 return meta::id<TYPE<T,DESCRIPTOR,1,-1,1>>();
616 return meta::id<TYPE<T,DESCRIPTOR,2,-1,1>>();
619 return meta::id<TYPE<T,DESCRIPTOR,2,1,-1>>();
622 return meta::id<TYPE<T,DESCRIPTOR,2,-1,-1>>();
625 throw std::domain_error(
"Invalid normal");
630 typename T,
typename DESCRIPTOR,
631 template<
typename,
typename,
int,
int>
typename TYPE
640 typename T,
typename DESCRIPTOR,
641 template<
typename,
typename,
int,
int,
int>
typename TYPE,
650 typename T,
typename DESCRIPTOR,
651 template <
int...>
typename TYPE
659 typename T,
typename DESCRIPTOR,
660 template<
typename,
typename,
int,
int,
int>
typename TYPE
669 typename T,
typename DESCRIPTOR,
670 template<
typename,
typename,
int,
int,
int>
typename TYPE,
679 typename T,
typename DESCRIPTOR,
680 template<
typename,
typename,
int,
int,
int>
typename TYPE
689template <
typename T,
typename DESCRIPTOR,
template<
typename,
typename,
int...>
typename OPERATOR>
695 for (
int iCloc = 0; iCloc < sLattice.
getLoadBalancer().size(); ++iCloc) {
697 boundaryI->getBlockIndicatorF(iCloc),
698 fluidI->getBlockIndicatorF(iCloc),
699 outsideI->getBlockIndicatorF(iCloc));
701 addPoints2CommBC(sLattice, std::forward<
decltype(boundaryI)>(boundaryI), 1);
704template <
typename T,
typename DESCRIPTOR,
template<
typename,
typename,
int...>
typename OPERATOR>
713 if ( blockGeometryStructure.getNeighborhoodRadius({iX, iY, iZ}) >= 1
714 && boundaryI(iX, iY, iZ)) {
716 if (normal[0]!=0 || normal[1]!=0 || normal[2]!=0) {
717 block.addPostProcessor(
723 clout <<
"Warning: Could not setOperatorForNormal("
724 << iX <<
", " << iY <<
", " << iZ
725 <<
"), discreteNormal=" << normal <<
"" << std::endl;
#define OPERATOR(OP, rhs)
Base block indicator functor.
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.
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)
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.
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.
virtual void initialize(Cell< T, DESCRIPTOR > &cell)
Initialize dynamics-specific data for cell.
DYNAMICS< T, DESCRIPTOR, MOMENTA, x, y, z > ConcreteDynamics
static auto construct(Vector< int, 3 > n)
static auto construct(Vector< int, 3 > n)
DYNAMICS< T, DESCRIPTOR, MIXIN, MOMENTA, x, y, z > ConcreteDynamics
static auto construct(Vector< int, 3 > n)
DYNAMICS< T, DESCRIPTOR, MIXIN, MOMENTA< PlaneAndNormal... > > ConcreteDynamics
Communication after collision.
Communication after propagation.