27#ifndef SET_BOUZIDI_VELOCITY_BOUNDARY_HH
28#define SET_BOUZIDI_VELOCITY_BOUNDARY_HH
39template<
typename T,
typename DESCRIPTOR>
42 std::vector<int> bulkMaterials)
51template<
typename T,
typename DESCRIPTOR>
57 T _epsFraction = 0.0001;
61 clout <<
"epsFraction=" << _epsFraction << std::endl;
64 for (
int iCloc = 0; iCloc < sLattice.
getLoadBalancer().size(); ++iCloc) {
67 <<
" starts to read distances for Velocity Boundary..." << std::endl;
70 setBouzidiVelocityBoundary<T,DESCRIPTOR>(
71 sLattice.
getBlock(iCloc), boundaryIndicator->getBlockIndicatorF(iCloc),
72 bulkIndicator->getBlockIndicatorF(iCloc),
73 geometryIndicator, _epsFraction);
76 <<
" finished reading distances for Velocity Boundary." << std::endl;
83 addPoints2CommBC<T,DESCRIPTOR>(sLattice,std::forward<
decltype(boundaryIndicator)>(boundaryIndicator), overlap);
90template<
typename T,
typename DESCRIPTOR>
95 if (boundaryIndicator(iX,iY,iZ)) {
96 setBouzidiVelocityBoundary<T,DESCRIPTOR>(block,
107template<
typename T,
typename DESCRIPTOR>
112 T distances[DESCRIPTOR::q];
113 for (
int iPop = 1; iPop < DESCRIPTOR::q ; ++iPop) {
114 distances[iPop] = -1;
117 for (
int iPop = 1; iPop < DESCRIPTOR::q ; ++iPop) {
119 const int iXn = iX + c[0];
120 const int iYn = iY + c[1];
121 const int iZn = iZ + c[2];
122 if (blockGeometryStructure.
isInside(iXn,iYn,iZn) && bulkIndicator(iXn,iYn,iZn)) {
125 blockGeometryStructure.
getPhysR(physR,{iXn,iYn,iZn});
126 T voxelSize=blockGeometryStructure.
getDeltaR();
129 Vector<T,3> direction(-voxelSize*c[0],-voxelSize*c[1],-voxelSize*c[2]);
130 T cPhysNorm = voxelSize*
util::sqrt(c[0]*c[0]+c[1]*c[1]+c[2]*c[2]);
132 if (!geometryIndicator.
distance(dist,physC,direction,blockGeometryStructure.
getIcGlob() ) ) {
133 T epsX = voxelSize*c[0]*_epsFraction;
134 T epsY = voxelSize*c[1]*_epsFraction;
135 T epsZ = voxelSize*c[2]*_epsFraction;
142 direction2[0] -= 2.*epsX;
143 direction2[1] -= 2.*epsY;
144 direction2[2] -= 2.*epsZ;
146 if ( !geometryIndicator.
distance(dist,physC2,direction2,blockGeometryStructure.
getIcGlob())) {
147 clout <<
"ERROR: no boundary found at (" << iXn <<
"," << iYn <<
"," << iZn <<
") ~ ("
148 << physR[0] <<
"," << physR[1] <<
"," << physR[2] <<
"), "
149 <<
"in direction " << descriptors::opposite<DESCRIPTOR >(iPop)
153 T distNew = (dist -
util::sqrt(epsX*epsX+epsY*epsY+epsZ*epsZ))/cPhysNorm;
158 dist = 0.5 * cPhysNorm;
159 clout <<
"WARNING: distance at (" << iXn <<
"," << iYn <<
"," << iZn <<
") ~ ("
160 << physR[0] <<
"," << physR[1] <<
"," << physR[2] <<
"), "
161 <<
"in direction " << descriptors::opposite<DESCRIPTOR >(iPop) <<
": "
169 distances[descriptors::opposite<DESCRIPTOR >(iPop)] = dist/cPhysNorm;
172 setBouzidiVelocityBoundary<T,DESCRIPTOR>(block, blockGeometryStructure, iX, iY, iZ, distances);
176template<
typename T,
typename DESCRIPTOR>
179 T location[DESCRIPTOR::d];
180 blockGeometryStructure.
getPhysR(location, {x,y,z});
181 T distancesCopy[DESCRIPTOR::q];
182 T spacing = blockGeometryStructure.
getDeltaR();
183 for (
int iPop = 1; iPop < DESCRIPTOR::q ; ++iPop) {
184 distancesCopy[iPop] = spacing*(1.-distances[iPop]);
186 distancesCopy[iPop] = -1;
192 for (
int iPop = 1; iPop < DESCRIPTOR::q ; ++iPop) {
196 setBouzidiVelocityBoundary<T,DESCRIPTOR>(block, blockGeometryStructure, x-c[0], y-c[1], z-c[2], iPop, distances[iPop]);
201template<
typename T,
typename DESCRIPTOR>
206 auto postProcessor = std::unique_ptr<PostProcessorGenerator3D<T, DESCRIPTOR>> {
nullptr };
207 if (blockGeometryStructure.
getMaterial({x-c[0], y-c[1], z-c[2]}) != 1) {
208 postProcessor.reset(
new VelocityBounceBackPostProcessorGenerator3D <T, DESCRIPTOR>(x, y, z, iPop, dist));
214 if (postProcessor && !block.
isPadding({x,y,z})) {
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.
BlockGeometry< T, 3 > & 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 defineDynamics(LatticeR< DESCRIPTOR::d > latticeR, DynamicsPromise< T, DESCRIPTOR > &&promise)
Assign promised DYNAMICS to latticeR.
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.
IndicatorF3D is an application from .
virtual bool distance(S &distance, const Vector< S, 3 > &origin, S precision, const Vector< S, 3 > &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.
Base indicator functor (discrete)
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.
Dynamics for offLattice boundary conditions OffDynamics are basically NoLatticeDynamics with the addi...
void setBouzidiVelocityBoundary(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.
Interface for per-cell dynamics.