Skip to content

Reply To: NSlattice.getLoadBalancer().size() is always 1 independent of blocks number

OpenLB – Open Source Lattice Boltzmann Code Forums on OpenLB General Topics NSlattice.getLoadBalancer().size() is always 1 independent of blocks number Reply To: NSlattice.getLoadBalancer().size() is always 1 independent of blocks number

#7827
jflorezgi
Participant

thanks for your response I understand what you’re saying, so I have a question.

I want to make a function that reviews all the cells in a horizontal plane at a certain height and, depending on the value of a specific functor in each cell, counts the number of cells that have the same value of the functor.

When I run the program with mpirun -np 1 ./…. and I look at the number of cells it is checking it gives me, for example:

nx = sLatticeNS.getBlock(iC).getNx() = 323 ny = sLatticeNS.getBlock(iC).getNy()= 415 and the number of cells that the program is checking is the multiplication of these two values, as I expected, but if I run the program with mpirun -np 2 ./…., the values are nx = sLatticeNS.getBlock(iC).getNx() = 323 ny = sLatticeNS.getBlock(iC).getNy()= 208 and the number of cells that the program is checking is the multiplication of these two values also, so depending on the number of blocks, the function only calculates the inverse (of the number of blocks) of the cells it should calculate.

the code of the function is:

void computeAirAngleFraction(SuperGeometry<T,3>& superGeometry,
UnitConverter<T, NSDESCRIPTOR> &converter,
SuperLattice<T,NSDESCRIPTOR>& sLatticeNS,
SuperLatticeAirAngleClass3D<T, NSDESCRIPTOR>& airAngleClass,
std::ofstream& fileAngleFr, T breathHeight)
{
OstreamManager clout( std::cout,”computeAirAngleFraction” );
clout << “Computing the Airflow Angle Fraction …” << std::endl;

int iZ = converter.getLatticeLength(breathHeight);

AnalyticalFfromSuperF3D<T> intpolateAirAngleClass( airAngleClass, true );

int material = 0;
//Write the macroscopic variables through the horizontal plane at breathHeight
T numerical[5] { };
T position[3] { };

for (int iC = 0; iC < sLatticeNS.getLoadBalancer().size(); iC++) {

for (int iY = 0; iY < sLatticeNS.getBlock(iC).getNy(); ++iY) {
for (int iX = 0; iX < sLatticeNS.getBlock(iC).getNx(); ++iX) {

material = superGeometry.getBlockGeometry(iC).getMaterial(iX,iY,iZ);
if (material == 1){
position[0] = (T)iX * converter.getPhysDeltaX();
position[1] = (T)iY * converter.getPhysDeltaX();
position[2] = breathHeight/*(T)iZ * converter.getPhysDeltaX()*/;

intpolateAirAngleClass(numerical, position);
//clout << numerical[0] << ” ” << position[0] << ” ” << position[1] << ” ” << position[2] << std::endl;

if (numerical[0] == 0.){
numerical[2]++;
numerical[4]++;
}
else if (numerical[0] == 1.){
numerical[3]++;
numerical[4]++;
}
else{
numerical[1]++;
numerical[4]++;
}
}
}
}
}

clout << “breathHeight = ” << breathHeight << ” ” << numerical[1] << ” ” << numerical[2] << ” ” << numerical[3] << ” ” << numerical[4] << ” ” << numerical[1] / numerical[4] << ” ” << numerical[2] / numerical[4] << ” ” << numerical[3] / numerical[4] << std::endl;

fileAngleFr << “breathHeight = ” << breathHeight << ” ” << numerical[1] << ” ” << numerical[2] << ” ” << numerical[3] << ” ” << numerical[4] << ” ” << numerical[1] / numerical[4] << ” ” << numerical[2] / numerical[4] << ” ” << numerical[3] / numerical[4] << std::endl;
}

I would appreciate if you can review the function and give me some idea about my question.