27#ifndef SET_BOUZIDI_ZERO_VELOCITY_BOUNDARY_2D_HH
28#define SET_BOUZIDI_ZERO_VELOCITY_BOUNDARY_2D_HH
39template<
typename T,
typename DESCRIPTOR,
class MixinDynamics>
42 std::vector<int> bulkMaterials)
44 setBouzidiZeroVelocityBoundary<T,DESCRIPTOR,MixinDynamics>(sLattice, superGeometry.
getMaterialIndicator(material),
52template<
typename T,
typename DESCRIPTOR,
class MixinDynamics>
58 T _epsFraction = 0.0001;
62 clout <<
"epsFraction=" << _epsFraction << std::endl;
64 for (
int iCloc = 0; iCloc < sLattice.
getLoadBalancer().size(); ++iCloc) {
66 <<
" starts to read distances for ZeroVelocity Boundary..." << std::endl;
67 setBouzidiZeroVelocityBoundary<T,DESCRIPTOR,MixinDynamics>(sLattice.
getBlock(iCloc),
68 boundaryIndicator->getBlockIndicatorF(iCloc),
69 bulkIndicator->getBlockIndicatorF(iCloc),
72 <<
" finished reading distances for ZeroVelocity Boundary." << std::endl;
76 addPoints2CommBC<T,DESCRIPTOR>(sLattice, std::forward<
decltype(boundaryIndicator)>(boundaryIndicator), _overlap);
83template<
typename T,
typename DESCRIPTOR,
class MixinDynamics>
87 if (boundaryIndicator(iX,iY)) {
88 setBouzidiZeroVelocityBoundary<T,DESCRIPTOR,MixinDynamics>(block,
98template<
typename T,
typename DESCRIPTOR,
class MixinDynamics>
101 OstreamManager clout(std::cout,
"setBouzidiZeroVelocityBoundary");
102 T _epsFraction = 0.0001;
103 T distances[DESCRIPTOR::q];
104 std::fill(std::begin(distances), std::end(distances), -1);
106 for (
int iPop = 1; iPop < DESCRIPTOR::q ; ++iPop) {
108 const int iXn = iX + c[0];
109 const int iYn = iY + c[1];
110 if (blockGeometryStructure.
isInside(iXn,iYn)) {
111 if (bulkIndicator(iXn,iYn)) {
114 blockGeometryStructure.
getPhysR(physR,{iXn,iYn});
115 T voxelSize=blockGeometryStructure.
getDeltaR();
118 Vector<T,2> direction(-voxelSize*descriptors::c<DESCRIPTOR >(iPop,0),-voxelSize*descriptors::c<DESCRIPTOR >(iPop,1));
119 T cPhysNorm = voxelSize*
util::sqrt(descriptors::c<DESCRIPTOR >(iPop,0)*descriptors::c<DESCRIPTOR >(iPop,0)+descriptors::c<DESCRIPTOR >(iPop,1)*descriptors::c<DESCRIPTOR >(iPop,1));
121 if (!geometryIndicator.
distance(dist,physC,direction,blockGeometryStructure.
getIcGlob() ) ) {
122 T epsX = voxelSize*descriptors::c<DESCRIPTOR >(iPop,0)*_epsFraction;
123 T epsY = voxelSize*descriptors::c<DESCRIPTOR >(iPop,1)*_epsFraction;
129 direction2[0] -= 2.*epsX;
130 direction2[1] -= 2.*epsY;
132 if ( !geometryIndicator.
distance(dist,physC2,direction2,blockGeometryStructure.
getIcGlob())) {
133 clout <<
"ERROR: no boundary found at (" << iXn <<
"," << iYn <<
") ~ ("
134 << physR[0] <<
"," << physR[1] <<
"), "
135 <<
"in direction " << descriptors::opposite<DESCRIPTOR >(iPop)
138 T distNew = (dist -
util::sqrt(epsX*epsX+epsY*epsY))/cPhysNorm;
143 dist = 0.5 * cPhysNorm;
144 clout <<
"WARNING: distance at (" << iXn <<
"," << iYn <<
") ~ ("
145 << physR[0] <<
"," << physR[1] <<
"), "
146 <<
"in direction " << descriptors::opposite<DESCRIPTOR >(iPop) <<
": "
153 distances[descriptors::opposite<DESCRIPTOR >(iPop)] = dist/cPhysNorm;
156 if (blockGeometryStructure.
getMaterial({iXn,iYn}) != 0) {
163 setBouzidiZeroVelocityBoundary<T,DESCRIPTOR,MixinDynamics>(block, blockGeometryStructure, iX, iY, distances);
167template<
typename T,
typename DESCRIPTOR,
class MixinDynamics>
170 for (
int iPop = 1; iPop < DESCRIPTOR::q ; ++iPop) {
173 setBouzidiZeroVelocityBoundary<T,DESCRIPTOR,MixinDynamics>(block, blockGeometryStructure, x-c[0], y-c[1], iPop, distances[iPop]);
179template<
typename T,
typename DESCRIPTOR,
class MixinDynamics>
182 auto postProcessor = std::unique_ptr<PostProcessorGenerator2D<T, DESCRIPTOR>>{
nullptr };
185 if (blockGeometryStructure.
getMaterial({x-c[0], y-c[1]}) != 1) {
192 if (postProcessor && !block.
isPadding({x,y})) {
Representation of a block geometry.
Vector< T, D > getPhysR(LatticeR< D > latticeR)
int getMaterial(LatticeR< D > latticeR) const
returns the (iX,iY) entry in the 2D scalar field
int getIcGlob() const
Read only access to the global iC number which is given !=-1 if the block geometries are part of a su...
T getDeltaR() const
Read only access to the voxel size given in SI units (meter)
Base block indicator functor (discrete)
BlockGeometry< T, 2 > & getBlockGeometry()
Get underlying block geometry structure.
Platform-abstracted block lattice for external access and inter-block interaction.
virtual void addPostProcessor(std::type_index stage, LatticeR< DESCRIPTOR::d > latticeR, PostProcessorPromise< T, DESCRIPTOR > &&promise)=0
Schedule post processor for application to latticeR in stage.
void forSpatialLocations(F f) const
bool isPadding(LatticeR< D > latticeR) const
Return whether location is valid.
bool isInside(LatticeR< D > latticeR) const
Return whether location is valid.
Smart pointer for managing the various ways of passing functors around.
IndicatorF2D is an application from .
virtual bool distance(S &distance, const Vector< S, 2 > &origin, S precision, const Vector< S, 2 > &direction)
returns false or true and pos. distance if there was one found for an given origin and direction
class for marking output with some text
void setMultiOutput(bool b)
enable message output for all MPI processes, disabled by default
Representation of a statistic for a parallel 2D geometry.
std::unique_ptr< SuperIndicatorF< T, D > > getMaterialIndicator(std::vector< int > &&materials)
Returns a material indicator using the given vector of materials.
Super class maintaining block lattices for a cuboid decomposition.
BlockLattice< T, DESCRIPTOR > & getBlock(int locC)
Return BlockLattice with local index locC.
LoadBalancer< T > & getLoadBalancer()
Read and write access to the load balancer.
void setBouzidiZeroVelocityBoundary(SuperLattice< T, DESCRIPTOR > &sLattice, SuperGeometry< T, 2 > &superGeometry, int material, IndicatorF2D< T > &geometryIndicator, std::vector< int > bulkMaterials=std::vector< int >(1, 1))
Set offDynamics with boundary links and post processors using indicators.
cpu::simd::Pack< T > sqrt(cpu::simd::Pack< T > value)
bool nearZero(const ADf< T, DIM > &a)
Top level namespace for all of OpenLB.