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

[Other] Generating a unstructured grids from STL files

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   May 5, 2005, 15:45
Default Generating a unstructured grids from STL files
  #1
Senior Member
 
Billy
Join Date: Mar 2009
Posts: 167
Rep Power: 17
billy is on a distinguished road
Hello everyone,

I have been working on a voxel mesh generator using STL files as input. This has two advantages:

1. It can handle complex geometries modelled by standard CAD applications,

2. It builds an orthogonal grid (mesh), which is ideal for FV calculations.

In the meantime, I am testing it with some simple geometries and it seems to work. I can make the source code available soon to anyone wishing to try it.
billy is offline   Reply With Quote

Old   May 5, 2005, 15:52
Default Hi Billy, This is very inte
  #2
Senior Member
 
Hrvoje Jasak
Join Date: Mar 2009
Location: London, England
Posts: 1,907
Rep Power: 33
hjasak will become famous soon enough
Hi Billy,

This is very interesting - I've always had trouble building foam meshes for complex 3-D geometries I wanted to do. :-)

Could you please set up a small site (if you haven't already) with some pictures of the meshes you create. I am particularly interested in kinds of cell shapes you produce and mesh quality around concave corners + control of mesh resolution etc.

Do you think it would be possible to hook the mesh generator info FOAM by using FOAM mesh classes for direct conversion.

Are there any plans to handle a dynamically changing STL geometry (say, moving or morphing in time) and handle delta-changes in the mesh. This would allow simulations of breaking bubbles (and similar) using a moving/deforming/morphing mesh technique.

Thanks,

Hrv
__________________
Hrvoje Jasak
Providing commercial FOAM/OpenFOAM and CFD Consulting: http://wikki.co.uk
hjasak is offline   Reply With Quote

Old   May 5, 2005, 15:56
Default Billy, I'd like to see your
  #3
New Member
 
Michael Prinkey
Join Date: Mar 2009
Posts: 3
Rep Power: 17
prinkey is on a distinguished road
Billy,

I'd like to see your code too. Making a cartesian mesher like this is something that has been on my todo list since I started working with OpenFOAM.

Thanks,

Mike
prinkey is offline   Reply With Quote

Old   May 5, 2005, 16:12
Default Hi Harje, I don't have a si
  #4
Senior Member
 
Billy
Join Date: Mar 2009
Posts: 167
Rep Power: 17
billy is on a distinguished road
Hi Harje,

I don't have a site with the pictures of the meshes yet. For now the cell shapes are hexahedrons. About the curvature aspect, I think it may possible to adjust cells to the curvature using a projection method, thus increasing non-orthogonality but I have not anything done yet. Can openFOAM deal with non-matching grids? If it can maybe it is possible to refine only the cells near the boundaries.

I would also like to plug it into openFOAM. But I think I need to eliminate some of the bugs first.

Is it possible to post the source code here on this site?

Billy.
billy is offline   Reply With Quote

Old   May 5, 2005, 16:16
Default Yes OpenFOAM can handle meshes
  #5
Senior Member
 
Join Date: Mar 2009
Posts: 854
Rep Power: 22
henry is on a distinguished road
Yes OpenFOAM can handle meshes with local refinement and we have utilities to do this.

You are very welcome to post the source code here, just clear it out of binaries and pack and compress, I am pretty sure it will be small enough to be accepted by the attachment facility.
henry is offline   Reply With Quote

Old   May 6, 2005, 09:27
Default Here is the source code: h
  #6
Senior Member
 
Billy
Join Date: Mar 2009
Posts: 167
Rep Power: 17
billy is on a distinguished road
Here is the source code:

stlToGmsh.tar.gz

Billy.
billy is offline   Reply With Quote

Old   May 6, 2005, 09:29
Default I also send a STL file as an e
  #7
Senior Member
 
Billy
Join Date: Mar 2009
Posts: 167
Rep Power: 17
billy is on a distinguished road
I also send a STL file as an example:

lever.tar.gz

Billy.
billy is offline   Reply With Quote

Old   May 6, 2005, 10:44
Default Hi, Billy, Thanks a lot for
  #8
Senior Member
 
Pei-Ying Hsieh
Join Date: Mar 2009
Posts: 317
Rep Power: 18
hsieh is on a distinguished road
Hi, Billy,

Thanks a lot for posting the mesher. You are an amazing guy - it is very difficult to do unstructured hex grid based on my conversation with several commercial CFD mesher companies.

I compiled the code without any problem and was able to generate the lever.msh file. A couple of questions:

1. is it possible to view the .msh?
2. I converted the .msh using gmshToFoam and got a warning message - Foam warning: polyMesh::polyMesh(... construct from shapes ...): Found 9656 undefined faces in mesh: adding to default patch.
3. how to put the boundary patches in boundary (using autoPatch? I am not familar with this utililty yet) so that BCs can be defined?

Again, great work! Thanks!

Pei
hsieh is offline   Reply With Quote

Old   May 6, 2005, 11:18
Default Hi, Billy, Is this cartesia
  #9
Senior Member
 
Pei-Ying Hsieh
Join Date: Mar 2009
Posts: 317
Rep Power: 18
hsieh is on a distinguished road
Hi, Billy,

Is this cartesian grid and not body-fitted grid?

Pei
hsieh is offline   Reply With Quote

Old   May 6, 2005, 11:19
Default Hi Pei, You can open the me
  #10
Senior Member
 
Billy
Join Date: Mar 2009
Posts: 167
Rep Power: 17
billy is on a distinguished road
Hi Pei,

You can open the mesh using GMSH.
http://www.geuz.org/gmsh/

Another way is to view it in paraview. I create a new case in FoamX and then I copy the mesh file there. After I run gmshToFoam to obtain the points, faces and cells. Then I run FoamX to define the boundary and then I open it using paraFoam.

Yes, you can use the autoPatch which is really a great tool to reconstruct the patches.

You can see that the mesh obtained has some error compared with the original geometry. To get a good aproximation you need to increase the number of divisions but this usually produces a very heavy mesh.

I am thinking about ways to improve the quality of the mesh and to refine it better near boundaries. Any suggestions?

Billy.
billy is offline   Reply With Quote

Old   May 6, 2005, 12:28
Default Hi, Billy, Thanks for the r
  #11
Senior Member
 
Pei-Ying Hsieh
Join Date: Mar 2009
Posts: 317
Rep Power: 18
hsieh is on a distinguished road
Hi, Billy,

Thanks for the response.

After I ran gmshToFoam. Under FoamX, I only see one default boundary. When I ran autoPatch, I played with several different angles (80, 90, 100, 120). 90 generated 256 patches and 100 and greater generated 2 patches. I still do not understand how autoPatch works.

I really have zero experience in mesh generation (only a user). However, a couple of years back, I did read a couple of papers discussing local cartesian grid refinement(someting like hanging nodes). I will let you know if I come across those again. I have also seen a cartesian grid generator from NASA. You might want to check it out.

Pei
hsieh is offline   Reply With Quote

Old   May 6, 2005, 18:24
Default autoPatch is really quite simp
  #12
Senior Member
 
Mattijs Janssens
Join Date: Mar 2009
Posts: 1,419
Rep Power: 26
mattijs is on a distinguished road
autoPatch is really quite simple. It takes all the edges on the surface of the mesh, marks those edges where the angle between the two faces using the edge is larger than the user specified value and then puts all faces inside such a delimited region into a single patch.
mattijs is offline   Reply With Quote

Old   May 7, 2005, 13:29
Default Hi billy, There is a "Algorit
  #13
New Member
 
stefan
Join Date: Mar 2009
Posts: 5
Rep Power: 17
stefan is on a distinguished road
Hi billy,
There is a "Algorithm oriented mesh database". Maybe you can use this code to get some inspiration.
http://www.scorec.rpi.edu/AOMD/

--Stefan
stefan is offline   Reply With Quote

Old   May 8, 2005, 17:28
Default Thanks Stefan for the link. I
  #14
Senior Member
 
Billy
Join Date: Mar 2009
Posts: 167
Rep Power: 17
billy is on a distinguished road
Thanks Stefan for the link. I will look into it.

Billy.
billy is offline   Reply With Quote

Old   May 9, 2005, 10:29
Default Hi, Billy, I don't know whe
  #15
Senior Member
 
Pei-Ying Hsieh
Join Date: Mar 2009
Posts: 317
Rep Power: 18
hsieh is on a distinguished road
Hi, Billy,

I don't know whether this is very difficult to do or not, but, just a thought:

Is it possible to project all the nodes near the walls onto the walls? If possible, then, you have an body-fitted mesh.

Pei
hsieh is offline   Reply With Quote

Old   May 9, 2005, 10:51
Default Pei, I think it is a little
  #16
New Member
 
Michael Prinkey
Join Date: Mar 2009
Posts: 3
Rep Power: 17
prinkey is on a distinguished road
Pei,

I think it is a little more complicated than projecting. The staircase mesh cannot be made to conform to a smooth boundary without adding "fillet" cells (wedges or tets). That changes the topology of the staircase and would allow it to be projected to the walls with mesh morphing.

The other option is to cut the cells at the surface. Then you have boundary hex cells with one or more vertices removed and various possible numbers of faces. This is pretty commonly done. Most references on cartesian meshing address this. Handling all of the possible cut cells at the boundary is one of the difficult parts. Calculating the volume of a regular hex cell cut by an arbitrary plane is more challenging than it may seem at first.

Mike
prinkey is offline   Reply With Quote

Old   May 9, 2005, 14:18
Default Hi, Mike, Thanks for the in
  #17
Senior Member
 
Pei-Ying Hsieh
Join Date: Mar 2009
Posts: 317
Rep Power: 18
hsieh is on a distinguished road
Hi, Mike,

Thanks for the information. It is very informative.

Almost all my work involves strong surface tension and wall adhesion effect. I have always used body-fitted mesh to preserve the wall geomtry. I have not tried cartensian grid. It is not clear to me if wall contact angle can be properly handled in a cartesian grid.

Pei
hsieh is offline   Reply With Quote

Old   August 10, 2005, 05:07
Default Hello, Can anyone tell me h
  #18
Senior Member
 
Sita Drost
Join Date: Mar 2009
Location: Arnhem, The Netherlands
Posts: 227
Rep Power: 18
sita is on a distinguished road
Hello,

Can anyone tell me how to create .stl files? I know it is possible in Solid Works, but that's rather huge and (as far as I know) you need M$ Windows for it. Is there another program (preferably freeware, Linux...) that I can use?

Sita
sita is offline   Reply With Quote

Old   August 10, 2005, 06:08
Default Hi Sita, I came up with thi
  #19
Senior Member
 
Mattijs Janssens
Join Date: Mar 2009
Posts: 1,419
Rep Power: 26
mattijs is on a distinguished road
Hi Sita,

I came up with this list before:

http://www.cfd-online.com/cgi-bin/Op...st=859#POST859

For polygon modelling you might also have a look at e.g. Blender which is very active.
mattijs is offline   Reply With Quote

Old   August 10, 2005, 12:25
Default Thanks! And sorry that I did n
  #20
Senior Member
 
Sita Drost
Join Date: Mar 2009
Location: Arnhem, The Netherlands
Posts: 227
Rep Power: 18
sita is on a distinguished road
Thanks! And sorry that I did not search the discussion board more thorouhgly before posting my question...
sita is offline   Reply With Quote

Reply


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
[Other] OpenFOAM - structured or unstructured Grids ? thomasduerr OpenFOAM Meshing & Mesh Conversion 22 November 25, 2018 00:18
On the diffusion term discretization on unstructured grids sbaffini Main CFD Forum 33 November 10, 2017 04:20
[snappyHexMesh] Convert stl files and multi region abrunet OpenFOAM Meshing & Mesh Conversion 1 July 1, 2014 11:15
Reading in and Manipulating STL files prapanj Mesh Generation & Pre-Processing 0 December 9, 2013 06:37
TVD/NVD in unstructured grids m.s. darwish Main CFD Forum 0 August 24, 1999 14:44


All times are GMT -4. The time now is 09:49.