How to define boundary when mesh is imported from gmsh?

Hi,

I have been struggling with this question for quite a while now and it seems I am no closer to solving it than I was 14 days ago.

So the issue is, I want to import the *.msh file available HERE using the

load "msh3"
load "gmsh"

// Load mesh.
mesh3 Th = gmshload3("../processed_data/EPC.msh");

and this works just fine however the following two lines

cout << "Volume = " << Th.measure << ", border area = " << Th.bordermeasure << endl;
cout << "Number of vertices = " << Th.nv << endl;

print out that the border area is zero. Of course it is zero, I have not defined it and that is the issue. I do not know how to define/label the borders.

So my question:

  • How do I define/label borders when the mesh is imported from gmsh?
  • Should I modify the gmsh file? In that case, do you have an idea how?

Thank you.

can I see the gmsh data file to create EPC.msh file, to see where is the mistake

The file is generated by some python script. The workflow is as follows:
The original data is written in Abaqus ODB file. From that data, geometry somehow needs to be extracted and the only way I found reasonable to do that was by writing a python script that reads the ODB and saves relevant geometry data to MSH.

So I guess:

  • Either there is something missing in the MSH or
  • I am missing to see a way to assign label to specific nodes within the FreeFem++

Because all I actually need is to just assign some label at the bottom nodes, so I can fix their displacement to 0.

I am not complet sure, theoretically the boudary is reconstructed by freefem.

to be sure try put verbosity = 5; before loadgmsh3

or your freefem version is to old …

after that what is the label boundary numbering ???

you can use change function to change the label number with :

 real[int] bb[6];
 boundingbox(Th,bb);
 real zmin = bb[4]; 
 real eps = (bb[5]-bb[4])*0.0001; 
 Th = change(Th,flabel  =   z <= zmin+eps ? 1: 0);  

now you can take your B.C of label 1 …

Hi,

Sorry but I am getting compile error at line 11 (the real[int] bb[6]).

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

// Load mesh.
verbosity = 5;
mesh3 Th = gmshload3("../processed_data/EPC.msh");
cout << "Volume = " << Th.measure << ", border area = " << Th.bordermeasure << endl;
cout << "Number of vertices = " << Th.nv << endl;

real[int] bb[6];
boundingbox(Th,bb);
real zmin = bb[4]; 
real eps = (bb[5]-bb[4])*0.0001; 
Th = change(Th,flabel  =   z <= zmin+eps ? 1: 0);  

Also the verbosity = 5; did not change anything. I am using the latest version, that is version 4.6 on Windows.

Try bb(6) instead of bb[6], and 4.6 is not the latest version, 4.9 is, see Releases · FreeFem/FreeFem-sources · GitHub.

Thank you both for helping, but I tried to print the labels and somehow I am not convinced this works. Btw I also upgraded to version 4.9.

So my code is as suggested:

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

// Load mesh.
verbosity = 5;
mesh3 Th = gmshload3("../processed_data/EPC.msh");

real[int] bb(6);
boundingbox(Th,bb);
real zmin = bb[4]; 
real eps = (bb[5]-bb[4])*0.0001; 
cout << zmin+eps << endl;
Th = change(Th,flabel  =   z <= zmin + eps ? 5: 1);  

However, when I wanted to print out the vertices with label 5:

int NbVertices = Th.nv;
cout << "Number of verticesssssss = " << NbVertices << endl;

for (int i = 0; i < NbVertices; i++){
    if (Th(i).label != 1){
        cout << "hello" << endl;
        cout << "Th(" << i << ") : " << Th(i).x << " " << Th(i).y << " " << Th(i).z << " " << Th(i).label << endl;
    }
}

There is no output, nothing is printed. Which makes me seriously doubt if the labels were actually changed. Am I getting this wrong or better said, how can I be sure the labels were actually modified?