CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Meshing & Mesh Conversion

[snappyHexMesh] Setting up a case using .stl files

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   May 19, 2020, 12:25
Default Setting up a case using .stl files
  #1
New Member
 
Join Date: May 2020
Posts: 5
Rep Power: 6
MichaelO is on a distinguished road
Hello, I have been trying to set up a simple case in OpenFOAM of fluid flow through a pipe using a mesh I created (ASCII .stl) of a cylinder using Blender. I read that it is easier to modify a tutorial case than to set up a case from scratch and I also read that the pitzDaily (simpleFoam) example was close enough to the case I am trying to set up. The issue is that I am unsure how to switch from the mesh that the case uses to the mesh I have created. I read that snappyHexMesh is a good way to convert .stl files into a format that openFoam can use and a snappyHexMesh tutorial I read said I had to use blockMesh first but blockMesh is non-parametric and I think when I use it it's targeting the mesh from the tutorial and not my mesh and deleting the blockMeshDict folder gives me an error when I then try to run the blockMesh command. Do I need to convert my .stl files to a blockMeshDict file in some way first? I have 3 .stl files (inlet, outlet, boundary). Thanks in advance
MichaelO is offline   Reply With Quote

Old   July 6, 2020, 09:54
Default Answer from Quora
  #2
New Member
 
Join Date: May 2020
Posts: 5
Rep Power: 6
MichaelO is on a distinguished road
I also asked this question on Quora and Gavin Tabor gave me this answer:

Gavin: "snappyHexMesh is your friend here - this is exactly what sHM is
intended for. Assuming that you are doing an exterior aerodynamics type
problem, your best approach is to modify the motorBike tutorial from the distribution.

sHM takes a base mesh which is generally a rectangular block of cells generated by blockMesh, so your first task is to make sure that the .stl file is properly located inside the cell block. You can do this by running blockMesh to generate the base mesh, then looking at this and the .stl file in paraFoam - paraview has an stl viewer module which enables you to read in your ASCII stl, which is very helpful. Then adjust the parameters in blockMeshDict until the block is where you want it relative to the stl - you may also need to adjust the boundaries (if the orientation is different) and the number of cells in the x, y, z directions. With some of this, if you can manipulate the .stl file that might be easier.

Having got everything in the right place, you now need to edit snappyHexMeshDict. This is reading in a series of .stl files making up the motorbike, so you need to edit this to point to your new stl file (or files). There are also settings controlling things like the number of levels of refinement and boundary layer control around the stl. The most important (in some ways) setting is locationInMesh, which specifies a point in the domain. There is a choice here as to whether you want to mesh inside the stl or outside, and this is how you make that choice (it keeps the portions of mesh contiguous with the point specified).

sHM is a 3 stage process; truncation, snapping, boundary layer. If you run it with no flags, it will write out the meshes for each stage as separate timestep directories, which can be useful, particularly if you are feeling your way and checking the steps off one by one (you can switch off later stages of the process by altering the flags in sHMD).

Once you are satisfied with the mesh, run sHM with the -overwrite flag, which modifies the mesh in the 0 timestep directory. You can then use this for your choice of solvers (probably simpleFoam as a starting point). You may need to set up or alter the different initial condition files (for U, p etc); and running potentialFoam to initialise the velocity field is typically useful as well.

Happy #foaming!"


Me: "Hello, thanks for your response. I am modelling fluid flowing through a pipe. I thought I added extra details to the question using a comment but I cannot find that now.

I’ve been trying to modify the pitzDaily or the pipeCyclic tutorial because they seem the closest to my problem. Is it easier to start with a tutorial that uses snappyHexMesh like the motorBike tutorial? I am unsure how to switch from the mesh that the case uses to the mesh I have created. I read that snappyHexMesh is a good way to convert .stl files into a format that openFoam can use and a snappyHexMesh tutorial I read said I had to use blockMesh first but blockMesh is non-parametric and I think when I use it it's targeting the mesh from the tutorial and not my mesh and deleting the blockMeshDict folder gives me an error when I then try to run the blockMesh command.

Do I need to convert my .stl files to a blockMeshDict file in some way first? I have 3 .stl files (inlet, outlet, boundary)."


Gavin: "Er, yes, that makes sense. If you delete the files blockMesh uses its going to give an error.

sHM needs as input an (or more than one) .stl file, and an input base mesh for it to truncate - it doesn’t generate this automatically. Normally this is a rectangular block of cells generated using blockMesh, but you can use another mesh generator or a non-rectangular block if you need to.

In your case I would still start with the motorBike test case , but now of course you want the inside cells not the external cells. Alter the blockMeshDict until you are getting a block of cells which is just larger than the pipe stl (out sideways; you probably want the ends of the stl to stick out to generate inlet and outlet patches from the faces of the original domain). Put your .stl file into constant/triSurface, and adjust the entries in snappyHexMeshDict to use yours rather than the motorbike ones. Change locationInMesh so it is a point inside the pipe. Then when you run sHM, it should trim the block down to the domain of your pipe.

Actually; having quickly taken a look at the tutorials in v7; there is one called”flange” which generates the geometry below; this might be an even better starting point for you.


as it clearly is doing an interior geometry rather than an exterior one. I haven’t looked at it in detail however!"

https://www.quora.com/How-do-you-run...3__=8355298568
Attached Images
File Type: png gavin t.png (115.8 KB, 56 views)
MichaelO is offline   Reply With Quote

Reply

Tags
blockmeshdict, openfoam, pitzdaily, snappyhexmesh, stl


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Is Playstation 3 cluster suitable for CFD work hsieh OpenFOAM 9 August 16, 2015 15:53
UDF issue MASOUD Fluent UDF and Scheme Programming 14 December 6, 2012 14:39
critical error during installation of openfoam Fabio88 OpenFOAM Installation 21 June 2, 2010 04:01
Video from case and data files girino FLUENT 9 March 29, 2010 03:41
Warning 097- AB Siemens 6 November 15, 2004 05:41


All times are GMT -4. The time now is 12:17.