Skip to content

Reply To: BounceBack boundary

#7709
Mike
Participant

Here is my code, I do use discretnormal directions to get unknownIndexes.
As for setter code, it is like:
setHalfBounceBackBoundary(NSlattice, omega, supergeometry, 4);
4 means solid node, which is implemented with nodynamics.

template<typename T, typename DESCRIPTOR, class MixinDynamics>
void setHalfBounceBackBoundary(BlockLatticeStructure2D<T,DESCRIPTOR>& block, T omega, BlockIndicatorF2D<T>& indicator, bool includeOuterCells)
{
OstreamManager clout(std::cout, “setHalfBounceBackBoundary2D”);
auto& blockGeometryStructure = indicator.getBlockGeometryStructure();
const int margin = includeOuterCells ? 0 : 1;
/*
*x0,x1,y0,y1 Range of cells to be traversed
**/
int x0 = margin;
int y0 = margin;
int x1 = blockGeometryStructure.getNx()-1 -margin;
int y1 = blockGeometryStructure.getNy()-1 -margin;
std::vector<int> discreteNormal(3, 0);
for (int iX = x0; iX <= x1; ++iX) {
for (int iY = y0; iY <= y1; ++iY) {
//momenta vector provisionally inside src/core/blockLatticeStructure3D.h
Momenta<T, DESCRIPTOR>* momenta = nullptr;
Dynamics<T, DESCRIPTOR>* dynamics = nullptr;
// Momenta<T, DESCRIPTOR>* momenta = new BulkMomenta<T, DESCRIPTOR>();
// Dynamics<T, DESCRIPTOR>* dynamics = new NoDynamics<T, DESCRIPTOR>();
PostProcessorGenerator2D<T, DESCRIPTOR>* postProcessor = nullptr;
if (indicator(iX, iY)) {
discreteNormal = indicator.getBlockGeometryStructure().getStatistics().getType(iX, iY);
clout << discreteNormal[0] << ” ” << discreteNormal[1] << ” ” << discreteNormal[2] << std::endl;

if (discreteNormal[0] == 0) {
//set the momenta,dynamics and post processor on the indicated local velocity boundary cells
if (discreteNormal[1] == 1) {
postProcessor = new BoundaryStreamPostProcessorGenerator2D<T, DESCRIPTOR, 0, 1>(iX, iY);
}
else if (discreteNormal[1] == -1) {

postProcessor = new BoundaryStreamPostProcessorGenerator2D<T, DESCRIPTOR, 0, -1>(iX, iY);
}
else if (discreteNormal[2] == 1) {

postProcessor = new BoundaryStreamPostProcessorGenerator2D<T, DESCRIPTOR, 1, 1>(iX, iY);
}
else if (discreteNormal[2] == -1) {

postProcessor = new BoundaryStreamPostProcessorGenerator2D<T, DESCRIPTOR, 1, -1>(iX, iY);
}
else {
clout << “here “<< “Could not setHalfBounceBackBoundary2D (” << iX
<< “, ” << iY << “)” << std::endl;
clout << discreteNormal[0] << ” ” << discreteNormal[1] << ” ” << discreteNormal[2] << std::endl;
}
}
else if (discreteNormal[0] == 1) {
//sets the momenta, dynamics and post processors on indicated localVelocityCornerBoundary cells
if (discreteNormal[1] == 1) {
if (discreteNormal[2] == 1) {
postProcessor = new BoundaryStreamPostProcessorGenerator2D<T, DESCRIPTOR, 1, 8>(iX, iY);
}
else if (discreteNormal[2] == -1) {
// clout << “5” << endl;

postProcessor = new BoundaryStreamPostProcessorGenerator2D<T, DESCRIPTOR, 1, -8>(iX, iY);
}
else {
clout << “Could not setHalfBounceBackBoundary2D (” << iX
<< “, ” << iY << “)” << std::endl;
}
}
else if (discreteNormal[1] == -1) {
if (discreteNormal[2] == 1) {
postProcessor = new BoundaryStreamPostProcessorGenerator2D<T, DESCRIPTOR, 1, 9>(iX, iY);
}
else if (discreteNormal[2] == -1) {
postProcessor = new BoundaryStreamPostProcessorGenerator2D<T, DESCRIPTOR, 1, -9>(iX, iY);
}
else {
clout << “Could not setHalfBounceBackBoundary2D (” << iX
<< “, ” << iY << “)” << std::endl;
}
}
}
//sets momenta, dynamics and postProcessors on local InnerVelocityCornerBoundary Cells
else if (discreteNormal[0] == 2) {
if (discreteNormal[1] == 1) {
if (discreteNormal[2] == 1) {

postProcessor = nullptr;
}
else if (discreteNormal[2] == -1) {

postProcessor = nullptr;
}
else {
clout << “Could not setHalfBounceBackBoundary2D (” << iX
<< “, ” << iY << “)” << std::endl;
}
}
else if (discreteNormal[1] == -1) {
if (discreteNormal[2] == 1) {

postProcessor = nullptr;
}
else if (discreteNormal[2] == -1) {
clout << “6” << endl;

// postProcessor = new BoundaryStreamPostProcessorGenerator2D<T, DESCRIPTOR, 1, 8>(iX, iY);
}
else {
clout << “Could not setHalfBounceBackBoundary2D (” << iX
<< “, ” << iY << “)” << std::endl;
}
}
}

setBoundary<T, DESCRIPTOR, MixinDynamics>(block, omega, iX,iY, momenta, dynamics, postProcessor);

}
}
}

}