Skip to content

Workflow ‐ FreeCAD Geometry to t8code mesh

Jakob Fußbroich edited this page Feb 29, 2024 · 3 revisions

The integration of FreeCAD geometries with t8code facilitates the transition from CAD modeling to mesh generation and mesh management for various computational applications. This article outlines a systematic workflow for utilizing FreeCAD-generated geometries within t8code. Example files for the presented workflow can be viewed and tested here: https://github.com/DLR-AMR/t8data/tree/main/freecad_to_t8code.

1. CAD Modeling in FreeCAD

Begin by creating the desired geometry using FreeCAD's comprehensive CAD tools. Ensure that each distinct volume within the geometry is represented by a separate body within the FreeCAD project file (.FCStd).

2. Selection and Export

With the geometry adequately modeled, select all bodies that collectively form the final geometry. Hold the 'Ctrl' key while selecting to choose multiple bodies simultaneously. Once the desired bodies are selected, export them as a single geometry file in BREP format (.brep). This can typically be done through the 'File' menu in FreeCAD.

3. Mesh Generation with Gmsh

Utilize Gmsh to convert the exported BREP file into an initial mesh. Open the BREP file in Gmsh and configure the meshing parameters as required for your specific application.

4. Overcoming Gmsh`s Numbering Issue

After the mesh is generated, re-export the BREP file, overwriting the initial file. This step is necessary to address a numbering problem that may arise within Gmsh during the meshing process.

5. Export Mesh File

Export the generated mesh in MSH format (.msh) from Gmsh. Make sure to tick the box "Save parametric coordinates" while exporting. This file contains the mesh data and together with the BREP file, geometry information can be associated with each mesh vertex.

6. Standardized File Naming for t8code

To seamlessly integrate the generated files with the t8code mesh management library, it is crucial to adhere to a standardized naming convention. Ensure that both the BREP and MSH files are named identically, differing only in their file extensions. For example, name the files as 'airfoil.brep' and 'airfoil.msh' to signify the geometry and mesh data of an airfoil, respectively.

Example Files in t8data Repo (https://github.com/DLR-AMR/t8data/tree/main/freecad_to_t8code)

FreeCAD_to_t8code_example_CAD FreeCAD_to_t8code_example_brep FreeCAD_to_t8code_example_mesh

      FreeCAD geometry (FCStd-File)    Geometry opened in Gmsh (BREP-FIle)    Geometry meshed in Gmesh (MSH-File)