Import 3D Geometry/Mesh

Hello everyone,

Although there are a lot of topics on this subject I have a few questions about 3D files. I am using Salome to create a geometry and its module “SMESH” to create meshes with tetra elements. So far, I managed to import the mesh into FreeFEM++ using GMSH version 4.8.4 for Windows but I have some problems with the labels. Here are the steps I follow: Create mesh and boundary group faces into Salome, export the mesh.UNV file and I import it into GMSH. From GMSH I export the mesh.MESH file (export as Mesh - INRIA Medit).

If I try to check the labels in FreeFEM++ as:

load “iovtk”
load “msh3”
load"gmsh"

mesh3 Th=readmesh3(“Mesh.mesh”);
plot(Th, wait=true);
int[int] lab = labels(Th);
cout<<labels(Th)<<endl:

it says that the command “labels” is unknown.
In GMSH I don’t (or I don’t know how to) see any labels in the Visibility field but something called “Discrete surface 2” and “Physical Surface 1” so I believe they couldn’t be exported from Salome.
Is it possible to create labels in GMSH if I don’t have the original geometry or is it possible to import CAD files straight to FreeFEM++ and create the mesh? I would leave importing CAD in GMSH and meshing there as a last option.

Best regards,
Robert

In Salome you can export directly to Mesh INRIA format exporting as GMF file (.mesh extension) that can be readed by FreeFem. Usually I have no problems with labels, they are also correctly exported.

Thank you Ernesto, it works. May I ask how are you setting your boundary conditions in FreeFEM++ using the mesh exported from Salome?
For example, I create the geometry, explode it into faces and I create groups with faces corresponding to the “Inlet”, “Outlet” and “Wall”. Then I create the mesh and I add the groups created earlier, with the same names. However, when I import the mesh in FreeFEM++, “Inlet”, “Outlet” and “Wall” groups are inexistent.
To make it run, I have to go back to the Geometry Module and check the index of each face and, if one group has 10 faces, I have to write all of them. Is there anyway to use the groups from the mesh module if the original geometry is lost?

Regards,
Robert

Some time ago, I wrote a Python script to rewrite the mesh, grouping a set of labels. But I think it is also possible using “change” function in FreeFem.

If you only have a mesh file, you can export it from FreeFem to VTK format, and see the labels with Paraview. The labels are associated to a “material” field in the VTK file.
Regards,
Ernesto

Thank you for the information! Unfortunately I didn’t manage to see the labels by exporting the mesh in paraview. For the moment I created another simple geometry for some tests. Anyway it seems that if I use the “Divided geometry types” (the ones with internal faces suitable to create hexahedronal mesh) the boundaries imported in FreeFEM are messed up (the inlet is an internal face, the outlet is a part of the wall etc). For the moment I will use some geometries without internal faces.

Regards,
Robert