1

I am currently trying to do a magnetostatic FEM simulation and I want to mesh my geometry using GMSH. The geometry is shown below: in Magnetic-Circuit

I create the geometry using FreeCAD and import into GMSH as a .STEP File. In GMSH I define 3 physical groups, resulting in the following script:

Merge "yoke_simulation.step";
Physical Volume("iron") = {1, 7, 9, 6, 3, 2, 4};
//+
Physical Volume("current") = {5};
//+
Physical Volume("air") = {8};

When I create the Mesh, I get the following result: enter image description here

The problem is that GMSH seems to be creating a seperate mesh for each body without connecting these meshes with one another. If one looks at the region between the two cones for example, it is evident that the mesh of the two cones is not connected to the mesh of the air:enter image description here

How can I get GMSH to create a single, connected mesh for all bodies?

Mantabit
  • 269
  • 1
  • 4
  • 14

3 Answers3

2

It seems that right now the Air volume 8 is just the overall bounding box, without necessary subtraction of volumes for Iron and Current. Thus, it creates a tetrahedral mesh for the entire bounding box without taking other bodies into the account.

I am not a FreeCAD expert, so I don't really know how to setup it properly there. Possibly, try specifying the Air volume there making sure it does not contain your detail.

Another approach could involve slight modifications at the GMSH level. For example, creating the proper Air volume before making it physical. You have volumes 1, 7, 9, 6, 3, 2, 4, 5 which you want to subtract from volume 8. That can be achieved by

BooleanDifference(100) = { Volume{8}; Delete; }{ Volume{1,7,9,6,3,2,4,5}; };
Physical Volume("air") = {100};

Notice, that the previous code will work only if OpenCASCADE kernel inside GMSH is used. Please, see the following sample code in GMSH for reference:

SetFactory("OpenCASCADE");

Box(1) = {0,0,0, 1,1,1};

Box(2) = {0.1,0.1,0.1, 0.2,0.2,0.2};
Box(3) = {0.5,0.5,0.5, 0.2,0.2,0.2};

BooleanDifference(100) = { Volume{1}; Delete; }{ Volume{2,3}; };
Physical Volume ("air") = {100};
Physical Volume ("iron") = {2,3};
Anton Menshov
  • 2,266
  • 14
  • 34
  • 55
  • Thanks for your response. You are correct, when I use the BooleanDifference command I am able to create a Mesh as intended. Maybe as a follow-up question (it seems like you´re a gmsh user as well): Do you normally model your geometries entirely in gmsh or do you use another CAD program and import it into gmsh? – Mantabit Dec 25 '18 at 14:14
  • @Mantabit I personally use GMSH only. However, its modeling capabilities are limited, so I am looking for nice ways of including a proper CAD in the loop for modeling and leave GMSH only for meshing. – Anton Menshov Dec 25 '18 at 16:30
  • @AntonMenshov out of curiosity, did you manage to find a CAD software that fit your needs? – gnikit Jan 14 '21 at 18:25
  • @nikjohn for industry work, we are mostly using our custom-written solutions now, which suffices our immediate needs, as we are not focused on solid CAD modelling in particular. For academic research outside of my day work, I am mostly with GMSH. – Anton Menshov Jan 14 '21 at 20:31
1

Dropping the command Coherence; after the merge line will force GMSH to form a coherent mesh without overlapping volumes.

LAPEMAG
  • 11
  • 3
0

I have created a set of free-and-open-source tools to generate partitioned meshes for multi-material FEM. They are available here github.com/NH89/SOFA_mesh_partitioning_tools

The are based on the CGAL geometry library, and generate a partitioned tetrahedral mesh from arbitrary intersecting triangulated surface meshes.

They are conceived for use with the SOFA real-time soft matter FEM framework, but could be used for any partitioned FEM application.

Dharman
  • 30,962
  • 25
  • 85
  • 135