Mass flux calculation
OpenLB – Open Source Lattice Boltzmann Code › Forums › on OpenLB › General Topics › Mass flux calculation
- This topic has 6 replies, 2 voices, and was last updated 2 years, 6 months ago by Adrian.
-
AuthorPosts
-
March 19, 2022 at 11:03 am #6389antoniowuParticipant
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[1]) 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[1] = 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 channelSuperLatticeVelocity2D<T, NSDESCRIPTOR> velocity(NSlattice);
SuperLatticeDensity2D<T, TDESCRIPTOR> concentration(ADlattice);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.89133Regards,
AntonioMarch 23, 2022 at 5:35 pm #6393AdrianKeymasterThe 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).
March 24, 2022 at 4:25 am #6394antoniowuParticipantHi Adrian,
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[0] = nx+2;
extend[1] = 1;/// Set material number for bottom and top
std::vector<T> origin( 2, T(0) );
origin[0] = -1;
IndicatorCuboid2D<T> bottom(extend, origin);
superGeometry.rename(2,3,1,bottom);origin[1] = ny-1;
IndicatorCuboid2D<T> top(extend, origin);
superGeometry.rename(2,4,1,top);/// Set material number for right
origin[0] = nx-1;
extend[0] = 1;
origin[1] = -1;
extend[1] = 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[0] = nx;
extend[1] = 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 loadBalancer
HeuristicLoadBalancer<T> loadBalancer(cuboidGeometry);/// Instantiation of a superGeometry
SuperGeometry2D<T> superGeometry(cuboidGeometry, loadBalancer, 2);prepareGeometry(superGeometry);
March 24, 2022 at 11:10 am #6395antoniowuParticipantHi Adrian,
Just so you know. I changed my normal from (0,1) to (0,-1) but I am still getting negative mass flux…
Regards,
AntonioApril 25, 2022 at 1:58 pm #6498AdrianKeymasterSorry 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.
April 28, 2022 at 6:53 am #6522antoniowuParticipantThank 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.
May 3, 2022 at 3:57 pm #6537AdrianKeymasterGood to hear that it works now.
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 theparallelTo
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 inSuperPlaneIntegralF2D::operator()
(output[0] = (h * Vector<T,2>(flow)) * _normal;
). -
AuthorPosts
- You must be logged in to reply to this topic.