SuperLatticePhysWallShearStress3D() returns norm of wall shear stress tensor
OpenLB – Open Source Lattice Boltzmann Code › Forums › on OpenLB › General Topics › SuperLatticePhysWallShearStress3D() returns norm of wall shear stress tensor
- This topic has 6 replies, 2 voices, and was last updated 3 years, 9 months ago by guojuw.
-
AuthorPosts
-
February 24, 2021 at 2:38 am #5489guojuwParticipant
Dear OLB developer,
I am looking at the sample code poiseuille3d.cpp. The function SuperLatticePhysWallShearStress3D() seems to calculate and return the magnitude of the wall shear stress tensor. Is it possible to return the shear stress tensor for general purposes?
Regards,
Junwei GuoFebruary 24, 2021 at 9:50 am #5490jonathanParticipantHi Junwei,
wall shear stress is calculated from the stress tensor taking the wall normal vector into account.
The “general-purpose” stress tensor can be accessed on block level with:sLattice.getBlockLattice(iC).computeStress(x, y, z, pi);
,
where pi is your tensor.
To my knowledge there’s no functor implemented for that.
For just having the tensor components exposed to your application, you can iterate over every BlockLattice and use the above expression.If you plan on using it as a functor a good starting point would be the SuperLatticePhysWallShearStress3D functor. Just copy it and remove anything to do with the normal vector calculation in the constructor of BlockLatticePhysWallShearStress3D and output the stress tensor directly. You will also see the computeStress there. Lastly you have to increase your functors output dimension to 6.
https://www.openlb.net/DoxyGen/html/db/d6f/classolb_1_1BlockLatticePhysWallShearStress3D.html
Hope this helps!Best,
JonathanFebruary 24, 2021 at 11:23 am #5491jonathanParticipantI think I misunderstood your question there, sorry. If I now understand correctly you just want it to give you the vector components and not the magnitude. Go to the file I linked above (BlockLatticePhysWallShearStress3D) and look for
WSS[0] = traction[0] - tractionNormalComponent[0]; WSS[1] = traction[1] - tractionNormalComponent[1]; WSS[2] = traction[2] - tractionNormalComponent[2];
Replace WSS with output and remove the line with output[0] = sqrt(…). Then you need to increase the functor dimension of both Super and BlockLatticePhysWallShearStress3D to 3 in order to have 3 output components.
Hope this clarifies, as I originally thought you needed the stress tensor.
Best
JonathanFebruary 25, 2021 at 2:20 am #5492guojuwParticipantThanks Jonathan. I worked it out by outputting the WSS[0] to WSS[2].
Regards,
JunweiFebruary 25, 2021 at 4:19 am #5493guojuwParticipantDear Jonathan,
I have another related problem.
After I have calculated the WSS using SuperLatticePhysWallShearStress3D(). I want to write WSS to disk as a CSV text file for post-processing purposes. I tried two different ways:
1.
a. calculate the WSS using ‘SuperLatticePhysWallShearStress3D<T,DESCRIPTOR> wallShearStressBot(sLattice,superGeometry,4,converter,base)’
b. write data to vtk files, ‘SuperVTMwriter3D<T> vtkWriter(“ellipsoid”);’ then ‘vtkWriter.addFunctor(wallShearStressBotVec);’ and last ‘vtkWriter.write(iT);’
c. extra the WSS using paraview and write WSS as CSV file.This way is very inconvenient.
2.
a. same as 1.a
b. use the interpolate utility AnalyticalFfromSuperF3D<T> intpolateBotWSS(wallShearStressBot,true); then interpolate the WSS at a given location intpolateBotWSS(WSSBot,loc);
c. write WSSBot and loc to disk.This way seems better. However, WSS is calculated at a given 2D plane (usually curved) in SuperLatticePhysWallShearStress3D, AnalyticalFfromSuperF3D<T> interpolates the results incorrectly in 3D (the value of WSS outside the plane is 0).
Do you recommend any better ways to write WSS as CSV text to disk?
Regards,
Junwei GuoFebruary 27, 2021 at 11:06 pm #5497jonathanParticipantHi Junwei,
@1.d.: Record a ParaView Python macro for the output, clean it up and it won’t be inconvenient for further usage.
This would be the fast, but dirty solution.I usually avoid AnalyticalFfromSuperF3D when outputting discrete fields if I don’t need the interpolation.
I’m not aware of a standalone class for your purpose, but a long-term solution would be writing your output interface manually.These are the relevant function calls I would use in a 1D scenario:
T minX = superGeometry.getStatistics().getMinPhysR(2)[0]; T maxX = superGeometry.getStatistics().getMaxPhysR(2)[0]; for(T iX = minX; iX < (maxX + converter.getPhysDeltaX()*0.5); iX+=converter.getPhysDeltaX()){ T pos_tmp[3] = {iX, somey, somez}; superGeometry.getCuboidGeometry().getLatticeR(latticeR, pos_tmp); //get lattice coordinates for wss output superGeometry.getCuboidGeometry().getPhysR(pos_tmp, latticeR); //convert lattice coordinates into physical coordinates WSS(output,latticeR); //write output and pos_tmp to disk with fstream... }
Add a barrier and some reduceAndBcasts depending on your MPI usage via singleton::mpi()… (maybe thats whats causing 0 outside the plane?)
Best
JonathanFebruary 28, 2021 at 1:50 am #5498guojuwParticipantDear Jonathan,
Thanks for your idea. Here is my solution.
1. create SuperVTMwriter3D<T> rawWriter(“rawvtk”,false,false);
2. dump uncompressed data in text, vtkWriter.addFunctor(wallShearStressLidVec);
rawWriter.write(iT);3. modify rawWriter.write(iT) so that it writes data in the region of interest only.
4. process the vtk files directly using python scripts, since they contain all information I need.
I am trying your approach as well.
Regards,
Junwei Guo -
AuthorPosts
- You must be logged in to reply to this topic.