Upload with gmsh and plot mesh

Hi everyone,

I am generating a *.msh file with python (please see this link). The same file is then supposed to be imported in the FreeFem++ and I do that with:

load "medit"
load "gmsh"

mesh3 Th = gmshload3("../processed_data/EPC.msh");
fespace Vh  (Th, P1);
Vh us;

plot(Th, wait=1);
medit("sol1", Th, us, wait=1);

Now the mesh gets imported successfully, it also prints that 13342 tetrahedrons were imported which is perfect. However, when I try to plot the mesh things go bad:

  • the plot function works, but it only plots the nodes, not the finite elements which I want to see
  • while the medit function fails with segmentation error so no image is returned.

It is really important for me to know if I am using the medit function in a wrong way or the *.msh file is broken and I have to fix it somehow. I have no idea how, but at least I would know what the issue is.

BTW: Gmsh, opens the *.msh normally.

Thank you!

Hi !

I tried to load and open your mesh - I can do it without a problem both using plot(...) and medit(...). Maybe your medit is outdated ?

Also, I see you are trying to plot function us with medit, but you did not define it prior to that. Maybe this is the problem as well (although, it works fine for me, just plots the mesh). Try this e.g.

us = x;
medit("us",Th,us,wait=1);

or just

medit("mesh only",Th,wait=1);

Unrelated (but maybe useful), I noticed that you only have one label of the boundary on the mesh. I don’t have much experience with gmsh but as far as I know you can define boundary label with physical labels withing gmsh. One way to check your mesh labels in freefem is

int[int] labs = labels(Th);
cout << labs << endl;

if

1 Like

Oh thank you, that was extremely helpful. At least now I know the *.msh file should work.

The

medit("mesh only",Th,wait=1);

still finishes in segmentation fault while

us = x;
medit("us",Th,us,wait=1);

doesn’t but at the same time no window is opened - the program just finished execution.

Isn’t medit supposed to be included in the FreeFem? Is there a special way to update it? My FreeFem version is probably the latest (4.6 installed on Windows yesterday), and since I believed medit is included I thought I have the latest version of it as well.

Not sure how things work on Windows - currently, I run ff version 4.9 on Linux where it is easier (at least for me) to link and update different software. I have no idea how Windows is handling these kind of thing.

Maybe just try to export your mesh from FreeFem++ to .vtu / .vtk file and check how things are in Paraview. Probably easiest detailed visualization option. Or better, solve some trivial example on this mesh and check solution in Paraview. This should give you some answers.

if

1 Like