STL File position shifting
OpenLB – Open Source Lattice Boltzmann Code › Forums › on OpenLB › General Topics › STL File position shifting
- This topic has 7 replies, 2 voices, and was last updated 11 months, 1 week ago by Adrian.
-
AuthorPosts
-
July 13, 2023 at 4:12 pm #7624IboralalpIParticipant
Dear developers and OpenLB community,
Is there an easy way to change the position (Coordinates) of the Geometry imported into OpenLB. I am using the stlReader to import my .stl files.
I couldn’t find a specific function to do it. So, I was thinking about coding it on my own. However, before doing that I decided to ask this matter to more experienced people out there.
Best,
BerkayJuly 14, 2023 at 7:01 pm #7627AdrianKeymasterYes, an essential aspect of OpenLB’s indicator resp. functor concept is that individual operations are extracted into generic functors. Any indicator, including
STLreader
, can be translated usingIndicatorTranslate3D
. You only need to provide it with a translation vector and the indicator to be translated.September 1, 2023 at 3:47 pm #7719IboralalpIParticipantDear Adrian, sorry for the late response, my answer got blocked quite a few times.
After your response, I had a small trial with the IndicatorTranslate3D function inside the cylinder3d example. However, I couldn’t get it to work properly.
std::array<T,3> shift {0.5, 0., 0.};
STLreader<T>stlReader(“cylinder3d.stl”, converter.getConversionFactorLength(), 0.001);
IndicatorTranslate3D<T>stlReaderShifted(shift,stlReader);
IndicatorLayer3D<T>extendedDomain(stlReaderShifted,converter.getConversionFactorLength());This gives the …/IndicatorF3D.hh:624 -> Assertion ‘_xLength>0 && _yLength>0 && _zLength>0’ failed.
AbortedI tried to use the IndicatorTranslate3D inside the prepare geometry function, in some other parts of the code and with different IndicatorF3Ds but nothing worked. The rest of the code is just like the cylinder3d example. Am I missing something obvious?
Thank you in advance for your support.
Best,
BerkaySeptember 4, 2023 at 3:24 pm #7725AdrianKeymasterThe error in this case is not ideal – the problem likely is that the unit scaling of the STL resp. the resolution are ill-fitted. i.e. the discretization width is larger then the entire STL bounding box causing it to not voxelize.
What is the base unit of your STL?
September 18, 2023 at 10:01 am #7745IboralalpIParticipantI am testing it on the examples/laminar/cylinder3d example. So, the base unit of the cylinder3d.stl is set to 0.001. The same error is still there even if I increase the resolution so that the dx is smaller than 0.001.
After I use the IndicatorTranslate3D<T>, I use the getMin() and getMax() functions in order to check if the Translation worked properly. The print-out of those are both [0,0,0] causing it to give a 0 length error.
Here it is:
-> STLreader<T> stlReader(“cylinder3d.stl”, converter.getConversionFactorLength(), 0.001);
IndicatorLater3D<T> stlReaderShifted(shift, stlReader);clout << “stlReaderMin: ” << stlReader.getMin() << std::endl;
clout << “stlReaderMax: ” << stlReader.getMax() << std::endl;
clout << “stlReaderShiftedMin: ” << stlReaderShifted.getMin() << std::endl;
clout << “stlReaderShiftedMax: ” << stlReaderShifted.getMax() << std::endl;Console:
[0.00025 0.00025 0.00025]
[2.49925 0.40925 0.40925]
[0 0 0]
[0 0 0]September 25, 2023 at 9:20 am #7761AdrianKeymasterThe STL file used for the cylinder3d example cases describes the entire simulation geometry, not just the cylinder.
I just checked and the overloads for
get(Min,Max)
are missing in ´IndicatorTranslate3D`, explaining the 0 output (they are easy to add however, just return the wrapped indicator’s min/max values shifted). This also explains why a translated indicator fails when passed into the cuboid geometry as the voxelization loop is based on the min/max values.October 11, 2023 at 1:54 pm #7819IboralalpIParticipantDear Adrian,
adding get(Min,Max) functions and of course updating with the translate array fixed the issue. STL transition works now.
Hope it is also useful for the other users.
I believe you won`t need it but I could also share the updated indicatorF3D.h and indicatorF3D.hh via mail. Would be great if we can have this on the next update.
Best,
BerkayOctober 12, 2023 at 8:14 am #7820AdrianKeymasterGood to hear. We’d gladly accept your patch and merge it for the next release. Simply send me an eMail via kummerlaender at kit edu
-
AuthorPosts
- You must be logged in to reply to this topic.