Skip to content

STL File position shifting

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #7624
    IboralalpI
    Participant

    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,
    Berkay

    #7627
    Adrian
    Keymaster

    Yes, 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 using IndicatorTranslate3D. You only need to provide it with a translation vector and the indicator to be translated.

    #7719
    IboralalpI
    Participant

    Dear 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.
    Aborted

    I 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,
    Berkay

    #7725
    Adrian
    Keymaster

    The 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?

    #7745
    IboralalpI
    Participant

    I 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]

    #7761
    Adrian
    Keymaster

    The 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.

    #7819
    IboralalpI
    Participant

    Dear 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,
    Berkay

    #7820
    Adrian
    Keymaster

    Good 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

Viewing 8 posts - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.