Extract Lattice data
OpenLB – Open Source Lattice Boltzmann Code › Forums › on OpenLB › General Topics › Extract Lattice data
- This topic has 17 replies, 2 voices, and was last updated 3 years ago by achodankar.
-
AuthorPosts
-
July 19, 2021 at 11:15 pm #5825achodankarParticipant
Hello Developers,
I would like to extract the raw data like:
1) x and y Coordinate data corresponding to lattice data
2) The no of points and no of cells in the geometry
3) the material no corresponding to x and y coordinates and lattice
2) velocity lattice data (SuperLatticePhysVelocity2D<T, DESCRIPTOR> velocity( sLattice, converter ); will extract the physical data to my understanding)Also, I don’t understand these two lines of codes in prepareGeometry function fully:
superGeometry.rename( 0,2 );
superGeometry.rename( 2,1,1,1 );
I get the pverall gist of setting the walls to 2 and fluid to 1.But I fail to understand why are all the nodes set to zero initially. How do I set only certain nodes to 2 for a custom problem statement ? I would really appreciate your feedback.
Thank you.
Yours sincerely,
Abhijeet
July 20, 2021 at 10:28 am #5828AdrianKeymasterw.r.t. geometry renames:
All material numbers being set to zero is simply the default. This makes sense as zero cells are considered as inactive cells for which no processing is done.
More complex geometry setups are commonly created using indicator functors. OpenLB provides both a library of indicators for various geometric primitives as well as a STLReader indicator for importing STL data. All of these can be used in rename calls to set material numbers. You can check out e.g. the cylinder(2,3)d examples for basic examples of this. The User guide also contains further explanations.
July 20, 2021 at 10:33 am #5829AdrianKeymaster1. You can access this via CuboidGeometry::getPhysR
2. This information is provided in the geometry statistics printed at the start of all examples
3. CuboidGeometry::getLatticeR can be used to convert physical locations to lattice locations. These lattice locations can the be passed to SuperGeometry for accessing material numbers.
4. For post-processing, the unscaled lattice velocity moment is available as SuperLatticeVelocity2D
July 21, 2021 at 5:27 am #5831achodankarParticipantHello Adrian,
I am trying to store the physical coordinates using the following code, but it is not working. All values are zero in output. Also, is it correct to use the getMaxLatticeVolume() and getMinLatticeVolume() functions to obtain the no of points in x and y direction i.e nx and ny? I tried using the getNx and getNy functions, but it didn’t work. I would really appreciate your feedback.!!!———————————————————————————————-
int latticeE[3] { };
T output[2]{ };cuboidGeometry.getPhysR(output,latticeE);
//superGeometry.getPhysR(output,latticeE);for (latticeE[0]=0; latticeE[0] < cuboidGeometry.getMaxLatticeVolume(); ++latticeE[0])
{
for (latticeE[1]=0; latticeE[1] < cuboidGeometry.getMinLatticeVolume(); ++latticeE[1])
{
cout << latticeE[0] << “,” << latticeE[1] << “,”<< output[0] << “,”<< output[1] << std::endl;
}
cout<<std::endl;
}!!!———————————————————————————————-
Thank you.
Yours sincerely,
Abhijeet
July 21, 2021 at 9:47 am #5833AdrianKeymasterThe call to getPhysR has to be inside to loop – currently the listing only calls it once at the beginning.
Independently of this “get(Min/Max)LatticeVolume” is not what you want here (they compute the minimum and maximum number of cells over the set of cuboids in the decomposition).
If you want the physical coordinates of all cells that are actually covered by cuboids in the geometry you can:
1. Iterate over all cuboids
for (int iC=0; iC < cGeometry.getNc(); ++iC) {
2. Access the i-th cuboid
cuboid = cGeometry.get(iC)
3. Iterate over the nodes of the cuboid
cuboid.getNx()
resp.cuboid.getNy()
4. Translate the lattice location
[iC, iX, iY]
to its physical embedding viacGeometry.getPhysR
July 21, 2021 at 7:21 pm #5836achodankarParticipantHello Adrian,
I followed your procedure and was able to get the physical coordinates from lattice coordinates. However, I was unable to get obtain the lattice coordinates from given physical coordinates. I would appreciate your suggestions on this matter.The code snippet is as follows:
!!—————————————————————————————-
//——————Convert physical coordinates to lattice coordinates————–
std::vector<int> latticeR(2,T());cout<<“——-Convert Physical coordinates to Lattice coordinates———-“<<endl;
for (int iC=0; iC < cuboidGeometry.getNc(); ++iC)
{
for (int iX=0; iX < cuboidGeometry.get(iC).getNx(); ++iX)
{
for (int iY=0; iY < cuboidGeometry.get(iC).getNy(); ++iY)
{
physCord[0] = double(iX)*cuboidGeometry.getMinDeltaR();
physCord[1] = double(iY)*cuboidGeometry.getMinDeltaR();
cuboidGeometry.getLatticeR(physCord, latticeR);
cout<<physCord[0]<<“,”<<physCord[1]<<“,”<<latticeR[0]<<“,”<<latticeR[1]<<endl;
}
cout<<endl;
}
cout<<endl;
}
cout<<“—————————————————————“<<endl;
//———————————————————————————–
!!————————————————————————————————Thank you.
Yours sincerely,
Abhijeet
July 21, 2021 at 8:24 pm #5837achodankarParticipantHello Adrian,
I would like to save the material no besides the corresponding lattice points. You mentioned earlier to pass the lattice locations to the superGeometry. I don’t understand on how to implement it. I found two code snippets related to this in the source code. I would really appreciate any suggestion on this matter.!!!—————————————————————————–
template<typename T>
461 std::unique_ptr<SuperIndicatorF2D<T>> SuperGeometry2D<T>::getMaterialIndicator(
462 std::vector<int>&& materials)
463 {
464 return this->getIndicator<SuperIndicatorMaterial2D>(
465 std::forward<std::vector<int>>(materials));
466 }
467
468 template<typename T>
469 std::unique_ptr<SuperIndicatorF2D<T>> SuperGeometry2D<T>::getMaterialIndicator(int material)
470 {
471 return this->getMaterialIndicator(std::vector<int> { material });
472 }
!!———————————————————————————————-Thank you.
Yours sincerely,
Abhijeet
July 21, 2021 at 10:32 pm #5839AdrianKeymasterThe [iC, iX, iY] you get from the cuboid geometry loop are lattice coordinates that can be converted to physical coordinates via getPhysR. The additional lines
physCord[0] = double(iX)*cuboidGeometry.getMinDeltaR();
are wrong – you would also need to add the cuboid start point. However, simply use getPhysR with latticeR set to [iC, iX, iY].- This reply was modified 3 years, 1 month ago by Adrian.
July 21, 2021 at 10:36 pm #5841AdrianKeymasterAs for the second question (you may consider opening separate threads for separate questions to keep things easy to follow for other users):
You do not need material indicators for that. I am not completely sure what you want to accomplish. If you only want to get the material data the VTK output included in every example is the most straight forward option.
If you have a lattice position [iC, iX, iY] you can get the material number via e.g.
SuperGeometry2D::getBlockGeometry(iC).get(iX, iY)
.July 22, 2021 at 7:16 am #5842achodankarParticipantHello Adrian,
Thank you very much for your prompt reply and help. I got the physical coordinates and material no using the following code, and its working fine.for (int iC=0; iC < cuboidGeometry.getNc(); ++iC)
{
//cuboid = cuboidGeometry.get(iC);
for (int iX=0; iX < cuboidGeometry.get(iC).getNx(); ++iX)
{
for (int iY=0; iY < cuboidGeometry.get(iC).getNy(); ++iY)
{
latticeE[0] = iX;
latticeE[1] = iY;
physCord=cuboidGeometry.getPhysR(iC, iX, iY);
x_phys[iX][iY][iC] = physCord[0];
y_phys[iX][iY][iC] = physCord[1];
x_lattice[iX][iY][iC] = latticeE[0];
y_lattice[iX][iY][iC] = latticeE[1];
materialno = superGeometry.getBlockGeometry(iC).get(iX, iY);
material_no[iX][iY][iC] = superGeometry.getBlockGeometry(iC).get(iX, iY);
cout<<iC<<“,”<<latticeE[0]<<“,”<<latticeE[1]<<“,”<<materialno<<“,”<<physCord[0]<<“,”<<physCord[1]<<endl;
myfile9<<iC<<“,”<<latticeE[0]<<“,”<<latticeE[1]<<“,”<<materialno<<“,”<<physCord[0]<<“,”<<physCord[1]<<endl;
}
cout<<endl;
}
cout<<endl;
}I have saved the physical coordinates in an array and then trying to convert it to lattice coordinates using the following code, but it is not working correctly. The y lattice coordinate remains the same for the same x and updates for changing x. The x lattice coordinate doesn’t update.
For example:
———————————————–
physical coordinates lattice coordinates
———————————————–
(0,0) (0,0)
(0,0.1) (0,0)
(0,0.2) (0,0)
………………………….
………………………..
(0,1) (0,1)
———————————-
(0.1,0) (0,1)
(0.1,0.1) (0,1)
(0.1,0.2) (0,1)
………………………….
………………………..
(0.1,1) (0,1)
—————————————I would really appreciate your suggestion.
Thank you for your patience.
Yours sincerely,
Abhijeet
July 23, 2021 at 11:00 am #5848AdrianKeymasterI think you forgot to include the code in your last message.
July 23, 2021 at 4:32 pm #5849achodankarParticipantHello Adrian,
I forgot to include the code. My apologies. Here is the code://——————Convert physical coordinates to lattice coordinates————–
std::vector<int> latticeR(2,T());cout<<“——-Convert Physical coordinates to Lattice coordinates———-“<<endl;
for (int iC=0; iC < cuboidGeometry.getNc(); ++iC)
{
for (int iX=0; iX < cuboidGeometry.get(iC).getNx(); ++iX)
{
for (int iY=0; iY < cuboidGeometry.get(iC).getNy(); ++iY)
{
physCord[0] = x_phys[iX][iY][iC];
physCord[1] = y_phys[iX][iY][iC];
cuboidGeometry.getLatticeR(physCord, latticeR);
cout<<physCord[0]<<“,”<<physCord[1]<<“,”<<latticeR[0]<<“,”<<latticeR[1]<<endl;
}
cout<<endl;
}
cout<<endl;
}
cout<<“—————————————————————“<<endl;
//———————————————————————————–Thank you.
Yours sincerely,
Abhijeet
July 29, 2021 at 9:37 am #5858AdrianKeymastergetLatticeR
accepts the lattice location as its first argument, not the second.See e.g. the Doxygen documentation CuboidGeometry2D::getLatticeR.
July 29, 2021 at 4:26 pm #5860achodankarParticipantHello Adrian,
I employed your suggestion, however, the same issue shows up again. Here is the code snippet://——————Convert physical coordinates to lattice coordinates————–
//std::vector<int> latticeR(2,T());
int latticeNew[2];
T physNew[2];cout<<“——-Convert Physical coordinates to Lattice coordinates———-“<<endl;
for (int iC=0; iC < cuboidGeometry.getNc(); ++iC)
{
for (int iX=0; iX < cuboidGeometry.get(iC).getNx(); ++iX)
{
for (int iY=0; iY < cuboidGeometry.get(iC).getNy(); ++iY)
{
// physCord[0] = x_phys[iX][iY][iC];
// physCord[1] = y_phys[iX][iY][iC];
// cuboidGeometry.getLatticeR(physCord, latticeR);
physNew[0] = x_phys[iX][iY][iC];
physNew[1] = y_phys[iX][iY][iC];
cuboidGeometry.getLatticeR(latticeNew, physNew);
// cout<<physCord[0]<<“,”<<physCord[1]<<“,”<<latticeR[0]<<“,”<<latticeR[1]<<endl;
cout<<physNew[0]<<“,”<<physNew[1]<<“,”<<latticeNew[0]<<“,”<<latticeNew[1]<<endl;
}
cout<<endl;
}
cout<<endl;
}
cout<<“—————————————————————“<<endl;
//———————————————————————————–Thank you.
Yours sincerely,
Abhijeet
August 2, 2021 at 9:35 pm #5883AdrianKeymasterGlobal lattice locations in 2D are 3-component vectors – the first one is the cuboid number, not the x component.
-
AuthorPosts
- You must be logged in to reply to this topic.