To replace Gmsh

Hi all,

In FreeFEM I have problems reading meshes generated by Gmsh as soon as there are labelled surfaces (e.g. Physical Surface(“inlet”, 26) = {7};). Reading the posts in this forum, I have the feeling that no solution has been yet identified (?).
Am I right concerning the problem with labelled surfaces in Gmsh (my version is v4.11.1) ?
Is there another open source candidate to replace Gmsh ?

Thanks
Dominique

Could you please share a small mesh example reproducing the behavior?

Below the gmsh geo file:

SetFactory(“OpenCASCADE”);

// Parameters
r_cylinder = 0.2; // Radius of the main cylinder
h_cylinder = 1.0; // Height of the main cylinder
r_inlet = 0.05; // Radius of the inlet pipe
h_inlet = 0.3; // Length of the inlet pipe
r_outlet_gas = 0.04; // Radius of the gas outlet pipe
h_outlet_gas = 0.4; // Length of the gas outlet pipe
r_outlet_liquid = 0.04; // Radius of the liquid outlet pipe
h_outlet_liquid = 0.3; // Length of the liquid outlet pipe

// Main cylinder
Cylinder(1) = {0, 0, 0, 0, 0, h_cylinder, r_cylinder, 2*Pi};

// Tangential inlet pipe
inlet_offset = r_cylinder - r_inlet; // Offset to ensure tangential alignment
Cylinder(2) = {0, inlet_offset, 2 * h_cylinder / 3, h_inlet, 0, 0, r_inlet, 2*Pi};

// Gas outlet pipe
//Cylinder(3) = {0, 0, h_cylinder + h_outlet_gas, 0, 0, -h_outlet_gas, r_outlet_gas, 2Pi};
Cylinder(3) = {0, 0, h_cylinder, 0, 0, h_outlet_gas, r_outlet_gas, 2
Pi};

// Liquid outlet pipe
Cylinder(4) = {0, 0, -h_outlet_liquid, 0, 0, h_outlet_liquid, r_outlet_liquid, 2*Pi};

BooleanUnion(20) = { Volume{1}; Delete; }{ Volume{2}; Delete; };
BooleanUnion(21) = { Volume{20}; Delete; }{ Volume{3}; Delete; };
BooleanUnion(22) = { Volume{21}; Delete; }{ Volume{4}; Delete; };

Physical Surface(“inlet”, 26) = {7};
Physical Surface(“liqoutlet”, 28) = {8};
Physical Surface(“gasoutlet”, 23) = {9};

In freefem, I tried to read directly the msh file:

mesh3 Th = gmshload3(“glcc.msh”);

or to generate it:

lockOrientation = false;
system(“gmsh -format msh22 -3 -o glcc.msh glcc.geo”);
mesh3 Th = gmshload3(“glcc.msh”);
lockOrientation = true;

Thanks

Can’t copy/paste your code => can’t help. Put everything in between code blocks.

hoping it’s getting better

SetFactory("OpenCASCADE");

// Parameters
r_cylinder = 0.2;         // Radius of the main cylinder
h_cylinder = 1.0;         // Height of the main cylinder
r_inlet = 0.05;           // Radius of the inlet pipe
h_inlet = 0.3;            // Length of the inlet pipe
r_outlet_gas = 0.04;      // Radius of the gas outlet pipe
h_outlet_gas = 0.4;       // Length of the gas outlet pipe
r_outlet_liquid = 0.04;   // Radius of the liquid outlet pipe
h_outlet_liquid = 0.3;    // Length of the liquid outlet pipe

// Main cylinder
Cylinder(1) = {0, 0, 0, 0, 0, h_cylinder, r_cylinder, 2*Pi};

// Tangential inlet pipe
inlet_x_offset = r_cylinder - r_inlet; // Offset to ensure tangential alignment
Cylinder(2) = {0, inlet_x_offset, 2 * h_cylinder / 3, h_inlet, 0, 0, r_inlet, 2*Pi};

// Gas outlet pipe
//Cylinder(3) = {0, 0, h_cylinder + h_outlet_gas, 0, 0, -h_outlet_gas, r_outlet_gas, 2*Pi};
Cylinder(3) = {0, 0, h_cylinder, 0, 0, h_outlet_gas, r_outlet_gas, 2*Pi};

// Liquid outlet pipe
Cylinder(4) = {0, 0, -h_outlet_liquid, 0, 0, h_outlet_liquid, r_outlet_liquid, 2*Pi};

BooleanUnion(20) = { Volume{1}; Delete; }{ Volume{2}; Delete; };
BooleanUnion(21) = { Volume{20}; Delete; }{ Volume{3}; Delete; };
BooleanUnion(22) = { Volume{21}; Delete; }{ Volume{4}; Delete; };

Physical Surface("inlet", 26) = {7};
Physical Surface("liqoutlet", 28) = {8};
Physical Surface("gasoutlet", 23) = {9};

You have not defined the volume to mesh, so Gmsh is not producing a 3D mesh.

The surface is also not well-defined:

Info    :  - Creating surface mesh
Info    : Found two duplicated facets.
Info    :   1st: [62, 137, 142] #5
Info    :   2nd: [62, 137, 142] #5
Error   : Invalid boundary mesh (overlapping facets) on surface 5 surface 5
Error   : No elements in volume 22 
Info    : Done meshing 3D (Wall 0.00305525s, CPU 0.00282s)
Info    : 183 nodes 436 elements
Error   : ------------------------------
Error   : Mesh generation error summary
Error   :     0 warnings
Error   :     2 errors
Error   : Check the full log for details
Error   : ------------------------------

Thank prj, I’m going to investigate

the code below does not provide errors. FreeFem is able to load, but it detects only one label instead of three:

SetFactory("OpenCASCADE");

DefineConstant[
    N = {10,    Name "input/1N"},
    Li = {0.2,  Name "input/2length inlet "},
    ri = {0.05, Name "input/3radius inlet "},   
    hi = {1.0,  Name "input/4height inlet "},
    Lg = {0.2,  Name "input/5length gas out "},
    rg = {0.05, Name "input/6radius gas out "},
    Ll = {0.2,  Name "input/7length liquid out "},
    rl = {0.05, Name "input/8radius liquid out "},
    Lc = {1,    Name "input/9length cylinder "},
    rc = {0.2,  Name "input/10radius cylinder "}
];

Cylinder(1) = {0, 0, 0, 0, 0, Ll, rl, 2*Pi};
Cylinder(2) = {0, 0, Ll, 0, 0, Lc, rc, 2*Pi};
Cylinder(3) = {0, 0, Ll+Lc, 0, 0, Lg, rg, 2*Pi};
Cylinder(4) = {-Li, rc-ri, hi, Li, 0, 0, ri, 2*Pi};

//+
BooleanUnion(5) = { Volume{2}; Delete; }{ Volume{4}; Delete; };
BooleanUnion(6) = { Volume{5}; Delete; }{ Volume{1}; Delete; };
BooleanUnion(7) = { Volume{6}; Delete; }{ Volume{3}; Delete; };

//+
Physical Surface("inlet", 14) = {7};
Physical Surface("liquid", 15) = {8};
Physical Surface("gas", 16) = {9};

You still have no physical volume, so this can’t be used for a mesh3.

same behavior when adding the following line :

Physical Volume("glcc", 17) = {7};

To check whether the labels are considered, I have written the following in the edp file:

int[int] labs = labels(Th);
cout << "List of labelled surfaces:" << endl;
for (int i = 0; i < labs.n; i++) {
    cout << "Label: " << labs[i] << endl;
}

We are starting to get somewhere. Your mesh is not a closed surface, you are missing surface elements everywhere outside of your current three labels.

prj, thanks for your feedback. Below a version where a volume is defined, including all the elements (I think so), but still only one label detected with freefem++.

SetFactory("OpenCASCADE");

DefineConstant[
    N = {10,    Name "input/1N"},
    Li = {0.2,  Name "input/2length inlet "},
    ri = {0.05, Name "input/3radius inlet "},   
    hi = {1.0,  Name "input/4height inlet "},
    Lg = {0.2,  Name "input/5length gas out "},
    rg = {0.05, Name "input/6radius gas out "},
    Ll = {0.2,  Name "input/7length liquid out "},
    rl = {0.05, Name "input/8radius liquid out "},
    Lc = {1,    Name "input/9length cylinder "},
    rc = {0.2,  Name "input/10radius cylinder "}
];

Cylinder(1) = {0, 0, 0, 0, 0, Ll, rl, 2*Pi};
Cylinder(2) = {0, 0, Ll, 0, 0, Lc, rc, 2*Pi};
Cylinder(3) = {0, 0, Ll+Lc, 0, 0, Lg, rg, 2*Pi};
Cylinder(4) = {-Li, rc-ri, hi, Li, 0, 0, ri, 2*Pi};

//+
BooleanUnion(5) = { Volume{2}; Delete; }{ Volume{4}; Delete; };
Coherence;

Physical Volume("glcc", 17) = {3, 5, 1};
Physical Surface("liquid", 18) = {3};
Physical Surface("gas", 19) = {8};
Physical Surface("inlet", 20) = {14};

This is still not a closed surface.

Sorry to bother again. I guess that I have now closed surface (?), but still problem of label with freefem++.

SetFactory("OpenCASCADE");

DefineConstant[
    N = {10,    Name "input/1N"},
    Li = {0.2,  Name "input/2length inlet "},
    ri = {0.05, Name "input/3radius inlet "},   
    hi = {1.0,  Name "input/4height inlet "},
    Lg = {0.2,  Name "input/5length gas out "},
    rg = {0.05, Name "input/6radius gas out "},
    Ll = {0.2,  Name "input/7length liquid out "},
    rl = {0.05, Name "input/8radius liquid out "},
    Lc = {1,    Name "input/9length cylinder "},
    rc = {0.2,  Name "input/10radius cylinder "}
];

Cylinder(1) = {0, 0, 0, 0, 0, Ll, rl, 2*Pi};
Cylinder(2) = {0, 0, Ll, 0, 0, Lc, rc, 2*Pi};
Cylinder(3) = {0, 0, Ll+Lc, 0, 0, Lg, rg, 2*Pi};
Cylinder(4) = {-Li, rc-ri, hi, Li, 0, 0, ri, 2*Pi};

//+
BooleanUnion(5) = { Volume{2}; Delete; }{ Volume{4}; Delete; };
Coherence;

Physical Volume("glcc", 22) = {3, 5, 1};
Physical Surface("liquid", 18) = {3};
Physical Surface("gas", 19) = {8};
Physical Surface("inlet", 20) = {14};
Physical Surface("wall", 21) = {12, 7, 10, 13, 11, 1};

And what is the problem precisely?
Here is what I get as list of labels with your mesh.

4	
	 18	 19	 20	 21

This is OK, isn’t it?

You got those labels using freefem++ ? Below is how I check the labels using freefem++, it might be an error

load "msh3"
load "gmsh"
load "medit"

mesh3 Th = gmshload3("glcc.msh"); 

plot(Th,wait=1);

int[int] labs = labels(Th);

cout << "List of labelled surfaces:" << endl;

for (int i = 0; i < labs.n; i++) {
    cout << "Label: " << labs[i] << endl;
}

medit("glcc",Th,wait=1);

I’ve been able to retrieve the labels using the lines:

lockOrientation = false;
system("gmsh -format msh22 -3 -o glcc.msh glcc.geo");
mesh3 Th = gmshload3("glcc.msh"); 
lockOrientation = true;

prj, many thanks for your patience, you helped a lot