Viewing 7 posts - 1 through 7 (of 7 total)
• Author
Posts
• #6389
antoniowu
Participant

Hi OpenLB community,

I am trying to calculate the y-direction outflow mass flux using the SuperPlaneIntegralFluxMass2D. I can get a good value for the mass flux although it is negative (why is that?). However, the region size (e.g., output) is a bit strange. My understanding is the region size should be the width of the outlet in a 2D simulation. In my case, I set nx = 200 but I keep getting output = 279 or 280 even when I change nx. Does anyone have any ideas on this issue?

Code snippet:

const int nx = 200; // width of the channel
const int ny = 200; // height of the channel

SuperLatticeVelocity2D<T, NSDESCRIPTOR> velocity(NSlattice);

Vector<T,2> normal(0,1); // normal vector in the y-direction

SuperPlaneIntegralFluxMass2D<T> outflux(velocity, concentration, superGeometry, 1.0, 1.0, normal, 4, BlockDataReductionMode::Analytical); // material 4 is the outlet; conversion factor is 1 as I am using lattice units in the simulation

Output:
[SuperPlaneIntegralFluxMass2D]regionName=outflux; regionSize[m]=279; massFlowRate[kg/s]=-7.89133

Regards,
Antonio

#6393
Keymaster

The sign of the computed mass flux value depends on the orientation of the integration plane’s normal. In your case it is likely pointing in the opposite direction of where it should.

For the region size: Can you post your whole example code / the geometry setup? (Just to make sure that there are no other issues, your setup of the plane integral functor looks correct).

#6394
antoniowu
Participant

Thank you for your comments. I’ve attached the code snippet for setting the geometry as below.

/// Stores geometry information in form of material numbers
void prepareGeometry(SuperGeometry2D<T>& superGeometry)
{

OstreamManager clout(std::cout,”prepareGeometry”);
clout << “Prepare Geometry …” << std::endl;

superGeometry.rename(0,2);
superGeometry.rename(2,1,1,1);

std::vector<T> extend( 2, T(0) );
extend = nx+2;
extend = 1;

/// Set material number for bottom and top
std::vector<T> origin( 2, T(0) );
origin = -1;
IndicatorCuboid2D<T> bottom(extend, origin);
superGeometry.rename(2,3,1,bottom);

origin = ny-1;
IndicatorCuboid2D<T> top(extend, origin);
superGeometry.rename(2,4,1,top);

/// Set material number for right
origin = nx-1;
extend = 1;
origin = -1;
extend = ny+1;
IndicatorCuboid2D<T> right(extend, origin);
superGeometry.rename(2,5,right);

/// Removes all not needed boundary voxels outside the surface
// superGeometry.clean();
/// Removes all not needed boundary voxels inside the surface
// superGeometry.innerClean();
superGeometry.checkForErrors();

superGeometry.print();

clout << “Prepare Geometry … OK” << std::endl;
}

/// === 2nd Step: Prepare Geometry ===
std::vector<T> extend(2,T());
extend = nx;
extend = ny;
std::vector<T> origin(2,T());
IndicatorCuboid2D<T> cuboid(extend, origin);

/// Instantiation of a cuboidGeometry with weights
#ifdef PARALLEL_MODE_MPI
const int noOfCuboids = singleton::mpi().getSize();
#else
const int noOfCuboids = 1;
#endif
CuboidGeometry2D<T> cuboidGeometry(cuboid, 1, noOfCuboids);
cuboidGeometry.setPeriodicity(false, false);

/// Instantiation of a superGeometry

prepareGeometry(superGeometry);

#6395
antoniowu
Participant

Just so you know. I changed my normal from (0,1) to (0,-1) but I am still getting negative mass flux…

Regards,
Antonio

#6498
Keymaster

Sorry for the late response – our new release took up most of my time in the past weeks.

I rechecked your instantiation of the mass flux functor: Which constructor did you actually want to use? (See Doxygen for reference).

The arguments likely lead to selecting

``````
SuperPlaneIntegralFluxMass2D(FunctorPtr<SuperF2D<T>>&& velocityF,
FunctorPtr<SuperF2D<T>>&& densityF,
SuperGeometry<T,2>&       geometry,
T conversationFactorMass,
T conversationFactorTime,
const Vector<T,2>& origin,
const Vector<T,2>& u,
BlockDataReductionMode mode);
``````

which is not we want here.

#6522
antoniowu
Participant

Thank you so much for checking. Excited to hear the new version is out!

You are right. I just realized SuperPlaneIntegralFluxMass2D doesn’t support using a normal. I am now setting the origin (0,ny) and u (1,0) instead. Just curious – is the direction vector u supposed to be along the outlet width? I get a negative flux when u is (1,0) and a positive one at (-1,0). Not quite sure why this happened.

#6537
For the persisting dependency on u: This is an artifact of how the hyperplane (i.e. the line) is constructed in `Hyperplane2D`. u is passed to the `parallelTo` method which uses it to construct the normal vector. This normal vector is dependent on the sign of u and is also used to calculate the flow in `SuperPlaneIntegralF2D::operator()` (`output = (h * Vector<T,2>(flow)) * _normal;`).