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

[CAD formats] Freecad: how to prepare a mesh suitable for OpenFOAM?

Register Blogs Community New Posts Updated Threads Search

Like Tree5Likes
  • 4 Post By NablaDyn
  • 1 Post By samiam1000

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   October 20, 2017, 10:54
Default Freecad: how to prepare a mesh suitable for OpenFOAM?
  #1
Senior Member
 
Samuele Z
Join Date: Oct 2009
Location: Mozzate - Co - Italy
Posts: 520
Rep Power: 18
samiam1000 is on a distinguished road
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

Last edited by samiam1000; October 24, 2017 at 08:18. Reason: The issue has been solved
samiam1000 is offline   Reply With Quote

Old   October 23, 2017, 02:46
Default
  #2
Senior Member
 
NablaDyn's Avatar
 
Join Date: Oct 2015
Location: Germany
Posts: 100
Rep Power: 10
NablaDyn is on a distinguished road
Quote:
Originally Posted by samiam1000 View Post
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
bigphil, nepomnyi, SharpS and 1 others like this.

Last edited by NablaDyn; October 23, 2017 at 04:12.
NablaDyn is offline   Reply With Quote

Old   October 23, 2017, 04:08
Default
  #3
Senior Member
 
Samuele Z
Join Date: Oct 2009
Location: Mozzate - Co - Italy
Posts: 520
Rep Power: 18
samiam1000 is on a distinguished road
That's a great help: thanks a lot Martin, I'll follow your advice.


Samuele
samiam1000 is offline   Reply With Quote

Old   October 25, 2017, 09:37
Default
  #4
Senior Member
 
Samuele Z
Join Date: Oct 2009
Location: Mozzate - Co - Italy
Posts: 520
Rep Power: 18
samiam1000 is on a distinguished road
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
samiam1000 is offline   Reply With Quote

Old   October 25, 2017, 11:35
Default
  #5
Senior Member
 
NablaDyn's Avatar
 
Join Date: Oct 2015
Location: Germany
Posts: 100
Rep Power: 10
NablaDyn is on a distinguished road
Quote:
Originally Posted by samiam1000 View Post
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
NablaDyn is offline   Reply With Quote

Old   October 26, 2017, 03:36
Default
  #6
Senior Member
 
Samuele Z
Join Date: Oct 2009
Location: Mozzate - Co - Italy
Posts: 520
Rep Power: 18
samiam1000 is on a distinguished road
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
samiam1000 is offline   Reply With Quote

Old   October 26, 2017, 03:50
Default
  #7
Senior Member
 
NablaDyn's Avatar
 
Join Date: Oct 2015
Location: Germany
Posts: 100
Rep Power: 10
NablaDyn is on a distinguished road
Quote:
Originally Posted by samiam1000 View Post
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.

Last edited by NablaDyn; November 6, 2017 at 06:13.
NablaDyn is offline   Reply With Quote

Old   October 26, 2017, 08:24
Default
  #8
Senior Member
 
Samuele Z
Join Date: Oct 2009
Location: Mozzate - Co - Italy
Posts: 520
Rep Power: 18
samiam1000 is on a distinguished road
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
NablaDyn likes this.
samiam1000 is offline   Reply With Quote

Old   August 19, 2020, 22:07
Default A little correction
  #9
Member
 
Ivan Nepomnyashchikh
Join Date: Sep 2019
Location: USA
Posts: 30
Blog Entries: 1
Rep Power: 6
nepomnyi is on a distinguished road
Quote:
Originally Posted by NablaDyn View Post
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

Last edited by nepomnyi; August 20, 2020 at 12:35.
nepomnyi is offline   Reply With Quote

Old   February 19, 2021, 12:38
Default
  #10
Senior Member
 
NablaDyn's Avatar
 
Join Date: Oct 2015
Location: Germany
Posts: 100
Rep Power: 10
NablaDyn is on a distinguished road
Quote:
Originally Posted by nepomnyi View Post
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
NablaDyn 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
Suitable mesh resolution for Deteched Eddy Simulations siw CFX 8 October 29, 2023 03:18
Setting the height of the stream in the free channel kevinmccartin CFX 12 October 13, 2022 21:43
[snappyHexMesh] Creating multiple multiple cell zones with snappyHexMesh - a newbie in deep water! divergence OpenFOAM Meshing & Mesh Conversion 0 January 23, 2019 04:17
[snappyHexMesh] SnappyHexMesh no layers and no decent mesh for complex geometry pizzaspinate OpenFOAM Meshing & Mesh Conversion 1 February 25, 2015 07:05
[ICEM] Generating Mesh for STL Car in Windtunnel Simulation tommymoose ANSYS Meshing & Geometry 48 April 15, 2013 04:24


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