How to apply the GMSH boundary label in FreeFEM

Dear developers,

How to apply the boundary labels from an external mesh generator such as GMSH?
The boundary patches are identified in the Gmsh step using its Physical Surface command.
I import the gmsh to freefem++, but it can’t catch the labels I had identified.

Thanks a lot!

What mesh format are you using? In Gmsh, if you export using INRIA Medit (.mesh) format, you should automatically get the correct labels (as set in Gmsh). See this post to verify the labels of your imported mesh.

What mesh format are you using?

I use gmsh .msh.

OK, does my suggestion (switching to .mesh) fix your issue?

I am a beginner of freefem. I can’t import the .mesh.
I use the GMSH to draw the mesh, and export the file using INRIA Medit(.mesh).
How to import the file(.mesh) to the freefem, and use the labels that I have identified?

Thank you for help!

In my previous solution, replace

mesh Th = square(10, 10);

by

mesh Th("my2DMesh.mesh");

or

mesh3 Th("my3DMesh.mesh");

int[int] lab = labels(Th);
varf onG(u, v) = on(lab, u = label);

I don’t understand this part. what is the difference between lab and label?
If my file(.mesh) is a square. The left side is 1, top is 2, right is 3, bottom is 4.
The left side don’t move(u=0).
How to enter the code for this problem?

Thank you for help!

Please read the documentation. lab is an array of integers corresponding to labels on which you want to impose boundary conditions. label is a reserved keyword in the FreeFEM grammar that returns the label of the current boundary element.

I use the code to test my problem,

1 mesh Th(“test.mesh”);
2 plot(Th);

It’s error.

– Mesh::read On file “test.mesh”
current line = 1
Assertion fail : (f.good() && nt && nv)
line :668, in file …/femlib/fem.cpp
Assertion fail : (f.good() && nt && nv)
line :668, in file …/femlib/fem.cpp
err code 6 , mpirank 0

How can I to solve the problem?

Thank you for help!

Is test.mesh in the same folder as your script? Could you send your mesh file?

https://drive.google.com/open?id=1pfFOF79VirmdyynFWTO8xSHcYgn22vWg

The test.mesh is in the same folder.

Could you try to mesh your .geo with the following command, please?

gmsh -2 -format msh2 -string 'Mesh.SaveElementTagType=2;' input.geo

If it doesn’t work, put your .geo in the Google Drive as well, please.

When I enter the command "gmsh -2 -format msh2 -string ‘Mesh.SaveElementTagType=2;’ input.geo ", it generated the .msh file not .mesh.
I use the command " gmshload test.msh ", it is successful.
But the numbers of mesh is a bit less.(picture in the Google Drive)
How to generate more numbers of mesh?

Thank you for help!