Creating a sliced 2D geometry in FreeCAD for a differentiated mesh in Gmsh

FreeCAD makes it easy to create a mesh on a single body or surface. However if we want one body or surface that is a combination of multiple solids or surfaces that share the same boundaries isn’t so direct. This is fundamental when creating more detailed meshes for example. In this article I will be exploring how we go about creating this in FreeCAD, slicing and joining surfaces to finally export the final geometry to create a differentiated mesh in Gmsh.

  1. SOFTWARE USED 
  2. CREATING GEOMETRY
  3. SPLITING AND CONNECTING
  4. EXPORTING AND MULTIZONE
  5. FINAL COMMENTS

 

1. SOFTWARE USED 

For this article two main softwares were used. FreeCAD and Gmsh.  However I suspect that under the hood we use OPENCASCADE for the geometry importing and exporting.

2. CREATING GEOMETRY

The first think to do is to create a 2D sketch (sketcher workbench) with the geometry you wish to study.

FreeCAD 2D Sketch

FreeCAD 2D Sketch

After creating this geometry you need to create a surface from the sketch. This for me was a bit tricky. I went to the Surface workbench and selected the “Create surface from …” icon.

Surface icon in FreeCAD

Surface icon in FreeCAD

After clicking a new menu appears on the left and you have to select the lines bounding the surface. This did not run that smoothly but I managed to select all bounding surfaces.

Selecting lines FreeCAD

Selecting lines FreeCAD

If successful  when hovering the geometry you will get a green highlight surface. After this is successful you need to create the splitting lines in a new sketch. I placed this sketch in the same part of the main geometry.

FreeCAD 2D sketch split lines

FreeCAD 2D sketch split lines

The resulting imagine can be seen bellow.

Target surface with cutting lines in FreeCAD

Target surface with cutting lines in FreeCAD

Now we are ready to split the surface of the 2D geometry we created. To do this we will need the Part Workbench. We will need to slice the target surface according to the lines we built on the second sketch. You first select the target surface and the select the reference cutting geometry. Then click Slice apart.

Slice object according to references in FreeCAD

Slice object according to references in FreeCAD

You should now get 4 independent areas. and at the left in the tree view a exploded slice folder with the four surfaces.

FreeCAD Sliced Geometry

FreeCAD Sliced Geometry

After having a sliced geometry we need to connect everything together. For this in the Part Workbench we need to select Connect objects.

Fuse object together in FreeCAD

together

 

FreeCAD Connected Surfaces

FreeCAD Connected Surfaces

Congratulations. We now have the geometry prepared for simulation. I think that up to here you can use a instead of a planar 2D surface you could use actually any geometry from line, 3D surface or a solid body.

3. SPLITING AND CONNECTING

In another post I have explained how to export this geometry to Gmsh and receive it back to use in the internal FEM workbench workflow. The link bellow will guide you to achieve this purpose. Follow it, for it is very easy.

http://using-freecad-fem-workbench-with-external-gmsh-mesh

In Gmsh to create a mesh with different meshing attributes in each segmented area is the focus next.

A normal mesh will create a more homogeneous line divisions as can be seen bellow.

Gmsh generic Hex mesh

Gmsh generic Hex mesh

In this surface I decided to use a Hex mesh with the following configuration:

Gmsh Hex mesh config

Gmsh Hex mesh config

To mesh independently one specific line we need to go to the tree view, select Mesh -> Define -> Transfinite -> Curve.

Gmsh Tranfinite options

Gmsh Tranfinite options

In this spot I had a lot of troubles. I could not select the lines. To solve this you need to 

Gmsh Transfinite curve menu

Gmsh Transfinite curve menu

To select the lines you need to click no the red box with an S. If you are successful the red box will change colour and you now can select the lines you want to change. In the menu box is the value you can influence the number of segments on the defined line. The image above show different number of divisions on the left and right diagonals. 

From here you follow the same flow from my previous post:

http://using-freecad-fem-workbench-with-external-gmsh-mesh

From here if you have imported correctly the unv file you should now be able to add it to you FEM project.

Imported mesh in FEM project in FreeCAD

Imported mesh in FEM project in FreeCAD

 

Boundary connections with new mesh in FreeCAD

Boundary connections with new mesh in FreeCAD

And calculation runs without any problems.

Calculix result with no errors in FreeCAD

Calculix result with no errors in FreeCAD

 

4. FINAL COMMENTS

Everything ran smoothly from slicing, connecting, transferring from FreeCAD to Gmsh and back and finally integrating the import with the base simulation.