CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Meshing & Mesh Conversion (https://www.cfd-online.com/Forums/openfoam-meshing/)
-   -   [Other] Generating a unstructured grids from STL files (https://www.cfd-online.com/Forums/openfoam-meshing/61973-generating-unstructured-grids-stl-files.html)

billy May 5, 2005 14:45

Generating a unstructured grids from STL files
 
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.

hjasak May 5, 2005 14:52

Hi Billy, This is very inte
 
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

prinkey May 5, 2005 14:56

Billy, I'd like to see your
 
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

billy May 5, 2005 15:12

Hi Harje, I don't have a si
 
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.

henry May 5, 2005 15:16

Yes OpenFOAM can handle meshes
 
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.

billy May 6, 2005 08:27

Here is the source code: h
 
Here is the source code:

http://www.cfd-online.com/OpenFOAM_D...hment_icon.gif stlToGmsh.tar.gz

Billy.

billy May 6, 2005 08:29

I also send a STL file as an e
 
I also send a STL file as an example:

http://www.cfd-online.com/OpenFOAM_D...hment_icon.gif lever.tar.gz

Billy.

hsieh May 6, 2005 09:44

Hi, Billy, Thanks a lot for
 
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 May 6, 2005 10:18

Hi, Billy, Is this cartesia
 
Hi, Billy,

Is this cartesian grid and not body-fitted grid?

Pei

billy May 6, 2005 10:19

Hi Pei, You can open the me
 
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.

hsieh May 6, 2005 11:28

Hi, Billy, Thanks for the r
 
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

mattijs May 6, 2005 17:24

autoPatch is really quite simp
 
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.

stefan May 7, 2005 12:29

Hi billy, There is a "Algorit
 
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

billy May 8, 2005 16:28

Thanks Stefan for the link. I
 
Thanks Stefan for the link. I will look into it.

Billy.

hsieh May 9, 2005 09:29

Hi, Billy, I don't know whe
 
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

prinkey May 9, 2005 09:51

Pei, I think it is a little
 
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

hsieh May 9, 2005 13:18

Hi, Mike, Thanks for the in
 
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

sita August 10, 2005 04:07

Hello, Can anyone tell me h
 
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

mattijs August 10, 2005 05:08

Hi Sita, I came up with thi
 
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.

sita August 10, 2005 11:25

Thanks! And sorry that I did n
 
Thanks! And sorry that I did not search the discussion board more thorouhgly before posting my question...


All times are GMT -4. The time now is 01:43.