Skip to content

Imported STL Files

Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • #9207
    sasan
    Participant

    Hi everyone,

    Is there any possibility to import multiple STL files and define them as inlets, outlets, and other faces afterward? Also, is there any example that I can use?

    I really appreciate any help you can provide.

    #9208
    Adrian
    Keymaster

    Sure, you can import multiple STL files by instantiating multiple STLreaders for the individual files. They satisfy the common indicator interface in OpenLB so you can use them to identify regions of the simulation domain in the same way as you would use the primitive cuboid / sphere / … indicators.

    #9209
    Dennis
    Keymaster

    Hi Sasan,

    Yes, you can import multiple STL files using the STLReader class. However, if you’re asking whether it’s possible to import all STL files from a folder at once, that feature is not available yet. You’ll need to manually add each STL file you’d like to use. Once imported, you can assign them appropriate names and manage the geometries using the rename function.

    You can see an example of this in /examples/laminar/cylinder3d.

    Best regards,
    Dennis

    #9223
    sasan
    Participant

    Thank you for your previous help! I have written the following code to read each face separately from STL files:

    STLreader<T> inletfaceReader(“inlet.stl”, converter.getConversionFactorLength(), 0.001); // Inlet STL reader
    STLreader<T> outletfaceReader(“outlet.stl”, converter.getConversionFactorLength(), 0.001); // Outlet STL reader
    STLreader<T> wallsfaceReader(“walls.stl”, converter.getConversionFactorLength(), 0.001); // Walls STL reader

    IndicatorLayer3D<T> extendedDomain(wallsfaceReader, converter.getConversionFactorLength());

    I would like to pass all the faces (inlet, outlet, and walls) to IndicatorLayer3D instead of just the wallsfaceReader. Could someone please guide me on how to achieve this?

    Thank you again for your assistance!

    #9224
    Dennis
    Keymaster

    Hi Sasan,

    There is indicator arithmetic for this but only if the Indicator is wrapped in a shared pointer.

    You could wrap them like this: std::shared_ptr> face(new STLreader(…..));

    After that you should be able to combine them like this: IndicatorLayer3D extendedDomain(face1+face2+face3, converter.getPhysDeltaX())

    • This reply was modified 5 months ago by Dennis.
    • This reply was modified 5 months ago by Dennis.
    • This reply was modified 5 months ago by Dennis.
    • This reply was modified 5 months ago by Dennis.
    • This reply was modified 5 months ago by Dennis.
    • This reply was modified 5 months ago by Dennis.
    #9240
    sasan
    Participant

    Thank you for your assistance. I’ve written the following code, but it’s not functioning as expected. Could you please help me troubleshoot?

       std::shared_ptr<Indicator> face1(new STLreader("inlet.stl"));
        std::shared_ptr<Indicator> face2(new STLreader("outlet.stl"));
        std::shared_ptr<Indicator> face3(new STLreader("walls.stl"));
       
    
        IndicatorLayer3D extendedDomain(face1 + face2 + face3, converter.getPhysDeltaX());
    #9243
    Adrian
    Keymaster

    By not working as expected you mean that it doesn’t compile (the listing you provided definitely won’t)?

    I kindly suggest that you read both the introductory step-by-step section and the functor arithmetic section of our user guide. This will tell you how to combine multiple indicators in this way.

    #9254
    sasan
    Participant

    Yes, the code isn’t compiling. If you have an example or code snippet that I could reference, I would greatly appreciate it. The examples I’ve found so far only demonstrate importing a single STL file.

    #9261
    Adrian
    Keymaster

    …you just instantiate another STLreader for the other STL files? This is just a class that you can construct as many times as you want with different arguments.

    Indicator arithmetic for combining multiple indicators is described in the user guide. Did you take a look?

    #9266
    sasan
    Participant

    Thank you for your helpful tips and for taking the time to assist me.

    I have joined the faces as follows:

    T voxelSize = 0.001; 
    T stlSize = 0.001;   
    
    int method = 1;
    bool verbose = true;
    
    // Read the inlet STL file
    STLreader<T> stlReaderInlet("inlet.stl", voxelSize, stlSize, method, verbose);
    olb::STLmesh<T> meshInlet = stlReaderInlet.getMesh();
    std::shared_ptr<olb::SuperF3D<T, T>> inletGeometry = std::make_shared<olb::SuperF3D<T, T>>(meshInlet);
    
    // Read the outlet STL file
    STLreader<T> stlReaderOutlet("outlet.stl", voxelSize, stlSize, method, verbose);
    olb::STLmesh<T> meshOutlet = stlReaderOutlet.getMesh();
    std::shared_ptr<olb::SuperF3D<T, T>> outletGeometry = std::make_shared<olb::SuperF3D<T, T>>(meshOutlet);
    
    // Read the walls STL file
    STLreader<T> stlReaderWalls("walls.stl", voxelSize, stlSize, method, verbose);
    olb::STLmesh<T> meshWalls = stlReaderWalls.getMesh();
    std::shared_ptr<olb::SuperF3D<T, T>> wallsGeometry = std::make_shared<olb::SuperF3D<T, T>>(meshWalls);
    
    auto combinedGeometry = min(min(inletGeometry, outletGeometry), wallsGeometry);
    
    IndicatorLayer3D<T> extendedDomain(*combinedGeometry, converter.getConversionFactorLength())

    ;

    However, when I attempt to create extendedDomain by passing combinedGeometry to it, I receive the following error:

    error: no instance of constructor "olb::IndicatorLayer3D<S>::IndicatorLayer3D [with S=T]" matches the argument list
    argument types are: (olb::SuperF3D<T, T>, T)

    Could you please guide me on how to resolve this issue? I appreciate your help.

    #9267
    Adrian
    Keymaster

    Why do you interact with the internals of the STL reader? (STL mesh)

    You just need to construct the STL readers as shared pointers and add them using indicator arithmetic.

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