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/)
-   -   [CAD formats] Freecad: how to prepare a mesh suitable for OpenFOAM? (https://www.cfd-online.com/Forums/openfoam-meshing/194648-freecad-how-prepare-mesh-suitable-openfoam.html)

samiam1000 October 20, 2017 10:54

Freecad: how to prepare a mesh suitable for OpenFOAM?
 
Dear All,

I am having a couple of problems dealing wirh the mesh.

1. I want to create a geometry using freecad, and to mesh it with OpenFOAM. Let's say that I want to prepare a channel with an inlet, an outlet and four walls. Do you know any step-by-step tutorial to do this? I can build this (very easy) geometry, but I can not create the patches.
2. if I have a step file, which is the best way to import it, create the patches that I need and mesh it?


Thanks a lot,
Samuele

NablaDyn October 23, 2017 02:46

Quote:

Originally Posted by samiam1000 (Post 668615)
Dear All,

I am having a couple of problems dealing wirh the mesh.

1. I want to create a geometry using freecad, and to mesh it with OpenFOAM. Let's say that I want to prepare a channel with an inlet, an outlet and four walls. Do you know any step-by-step tutorial to do this? I can build this (very easy) geometry, but I can not create the patches.
2. if I have a step file, which is the best way to import it, create the patches that I need and mesh it?


Thanks a lot,
Samuele

Hi Samuele,

that's a pretty simple and handy task. In my opinion even simpler and more consistent than in many commercial softwares. I use only FreeCAD in combination with cfMesh for my unstructured/hybrid CFD analyses' preprocessing.

  1. Model the geometry you want to analyse OR import it from other CAD environments using e.g. STEP or IGES
  2. Do the surface-wrapping: I use the Part and the Draft workbench simultaneously for this because it offers great freedom and flexibility when it comes to geometry repair. To do so, for example, on imported solids go to Draft, use the Explode operation and subdivide the solid into a shell. Repeat on the shell which results in faces. Now do your geometry repair or face reconstruction in case you have bad geometry using the Create Shape utility (sometimes you may need to switch between Draft and Part workbench to create/repair surfaces). After your geometry is set up in the form of clean and proper surfaces you can cluster the corresponding faces into groups that represent the boundary patches you need (i.e. inlet, outlet, wall etc.). For that, use the Create Shape utility and combine the faces of a patch in the form of a shell. Now, head over to the Mesh Desing workbench.
  3. Remesh the shells and export each shell mesh as a single ASCII encoded STL file (e.g. inlet shell > inletMesh > inlet.stl). Unfortunately this somewhat unhandy step is necessary because FreeCAD doesn't assign the proper mesh region names for the patches in a precombined STL file. Recombine the ASCII encoded STL patches by hand (copy/paste using e.g. Gedit) and assign the corresponding patch names (for example, in the header line of the inlet STL patch data: 'solid INLET') which enables cfMesh to address the patches for boundary creation etc. Store the STL file that now includes all correctly named patches
  4. Create your mesh with cfMesh or SnappyHexMesh or whatever STL based mesher you want to use. If you want to use something like Salome Platfrom for meshing you should stick with STEP/IGES geometry.
Best regards,


Martin

samiam1000 October 23, 2017 04:08

That's a great help: thanks a lot Martin, I'll follow your advice.


Samuele

samiam1000 October 25, 2017 09:37

Hi Martin,

thanks again for your kind answer.

I have a question, just to completely understand this point. I have a cad that I explode into many faces (something like 5000). I create a shell, but it is almost impossible to mesh it: it seems that creating the surface mesh is almost impossible for Freecad. Have you ever handle quite big and complex geometries?


Thanks a lot,
Samuele

NablaDyn October 25, 2017 11:35

Quote:

Originally Posted by samiam1000 (Post 669152)
Hi Martin,

thanks again for your kind answer.

I have a question, just to completely understand this point. I have a cad that I explode into many faces (something like 5000). I create a shell, but it is almost impossible to mesh it: it seems that creating the surface mesh is almost impossible for Freecad. Have you ever handle quite big and complex geometries?


Thanks a lot,
Samuele

Hello Samuele,

what do you mean by impossible? Does the mesher or FreeCAD crash? One hint: I usually use the standard mesher with surface deviation set to 0.01.

I never encountered any issues regarding the number of faces but I must note that I never got to process more than about 1000 surfaces.

Regards

Martin

samiam1000 October 26, 2017 03:36

Hello Martin,

thanks for answering.

Actually, using the standard mesher, with standard deviation of 0.01 mm, it works. It crashed when I used either Netgen or Mephisto. Don't know why.

Anyway, how about the second parameter, linked to the angle? Is 30° a good value?

Thanks a lot,
Samuele

NablaDyn October 26, 2017 03:50

Quote:

Originally Posted by samiam1000 (Post 669237)
Hello Martin,

thanks for answering.

Actually, using the standard mesher, with standard deviation of 0.01 mm, it works. It crashed when I used either Netgen or Mephisto. Don't know why.

Anyway, how about the second parameter, linked to the angle? Is 30° a good value?

Thanks a lot,
Samuele

Glad to read that. In my experience 30 ° has always been a good choice. But that clearly depends on your geometry - or more specifically on features - you want to resolve as STL is not as 'exact' on geometry as IGES/STEP/BREP. You should check critical regions afterwards to see if they have been captured adequately by the mesher. If not there is also the possiblity (besides playing around with the feature angle) to mesh the feature region face-wise which will lead to the most acurate results, for instance, when you want to resolve small steps or pockets in your geometry.

samiam1000 October 26, 2017 08:24

It works, great.

Thanks a lot for your help.

I'll dig into all the parameters, to better understand how they work.



Thanks a lot,
Samuele

nepomnyi August 19, 2020 22:07

A little correction
 
Quote:

Originally Posted by NablaDyn (Post 668819)
Hi Samuele,

that's a pretty simple and handy task. In my opinion even simpler and more consistent than in many commercial softwares. I use only FreeCAD in combination with cfMesh for my unstructured/hybrid CFD analyses' preprocessing.

  1. Model the geometry you want to analyse OR import it from other CAD environments using e.g. STEP or IGES
  2. Do the surface-wrapping: I use the Part and the Draft workbench simultaneously for this because it offers great freedom and flexibility when it comes to geometry repair. To do so, for example, on imported solids go to Draft, use the Explode operation and subdivide the solid into a shell. Repeat on the shell which results in faces. Now do your geometry repair or face reconstruction in case you have bad geometry using the Create Shape utility (sometimes you may need to switch between Draft and Part workbench to create/repair surfaces). After your geometry is set up in the form of clean and proper surfaces you can cluster the corresponding faces into groups that represent the boundary patches you need (i.e. inlet, outlet, wall etc.). For that, use the Create Shape utility and combine the faces of a patch in the form of a shell. Now, head over to the Mesh Desing workbench.
  3. Remesh the shells and export each shell mesh as a single ASCII encoded STL file (e.g. inlet shell > inletMesh > inlet.stl). Unfortunately this somewhat unhandy step is necessary because FreeCAD doesn't assign the proper mesh region names for the patches in a precombined STL file. Recombine the ASCII encoded STL patches by hand (copy/paste using e.g. Gedit) and assign the corresponding patch names (for example, in the header line of the inlet STL patch data: 'solid INLET') which enables cfMesh to address the patches for boundary creation etc. Store the STL file that now includes all correctly named patches
  4. Create your mesh with cfMesh or SnappyHexMesh or whatever STL based mesher you want to use. If you want to use something like Salome Platfrom for meshing you should stick with STEP/IGES geometry.
Best regards,


Martin


Thank you very much. I've a little correction.

1) I'm using FreeCad 0.18.4 and I was unable to find Explode option in the Draft. I found it in the Part workbench: Part --> Compound --> Explode compound (referene: https://wiki.freecadweb.org/Part_ExplodeCompound).
2) Where to find "Create shape utility"? It is actually this thing: https://wiki.freecadweb.org/Part_Builder. To do it, go to Part --> Shape builder and then you'll see the necessary options.
3) Here is a detailed review of how to export .stl files from FreeCAD for snappyhexmesh: https://wiki.openfoam.com/Integratio...by_Stefan_Radl. Very close to what NableDyn described but uses different tools and - what is most important - shows how to do it.

Ivan

NablaDyn February 19, 2021 12:38

Quote:

Originally Posted by nepomnyi (Post 780874)
Thank you very much. I've a little correction.

1) I'm using FreeCad 0.18.4 and I was unable to find Explode option in the Draft. I found it in the Part workbench: Part --> Compound --> Explode compound (referene: https://wiki.freecadweb.org/Part_ExplodeCompound).
2) Where to find "Create shape utility"? It is actually this thing: https://wiki.freecadweb.org/Part_Builder. To do it, go to Part --> Shape builder and then you'll see the necessary options.
3) Here is a detailed review of how to export .stl files from FreeCAD for snappyhexmesh: https://wiki.openfoam.com/Integratio...by_Stefan_Radl. Very close to what NableDyn described but uses different tools and - what is most important - shows how to do it.

Ivan

Hi Ivan,
sorry it seems it's already been awhile...
1) That's the thick blue downwards pointing arrow in the Draft workbench
2) Yes
3) Sorry I considered this to be self-explanatory but good to read you found a helpful reference
Regards


All times are GMT -4. The time now is 00:41.