Imported STL Files
OpenLB – Open Source Lattice Boltzmann Code › Forums › on OpenLB › General Topics › Imported STL Files
- This topic has 10 replies, 3 voices, and was last updated 4 months, 3 weeks ago by Adrian.
-
AuthorPosts
-
September 9, 2024 at 3:20 pm #9207sasanParticipant
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.
September 9, 2024 at 3:49 pm #9208AdrianKeymasterSure, you can import multiple STL files by instantiating multiple
STLreader
s 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.September 9, 2024 at 3:51 pm #9209DennisKeymasterHi 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,
DennisSeptember 10, 2024 at 7:50 pm #9223sasanParticipantThank 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 readerIndicatorLayer3D<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!
September 11, 2024 at 11:31 am #9224DennisKeymasterHi 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()) September 16, 2024 at 10:46 am #9240sasanParticipantThank 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());
September 16, 2024 at 11:05 am #9243AdrianKeymasterBy 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.
September 17, 2024 at 12:03 pm #9254sasanParticipantYes, 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.
September 18, 2024 at 9:51 am #9261AdrianKeymaster…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?
September 19, 2024 at 12:01 pm #9266sasanParticipantThank 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.
September 19, 2024 at 12:12 pm #9267AdrianKeymasterWhy 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.
-
AuthorPosts
- You must be logged in to reply to this topic.