How to revise mesh using mshmet and mmg in 2d?

Hi everyone,

I have a question regarding the use of mshmet and mmg in FreeFEM++. I’m trying to revise my mesh so that its density gradually increases with the increase of x. Thus, I introduce a P1 variable G1 = x^2. + 0.01 and pass it into function mshmet, trying to get a vector (named met1) containing density that will increase with the increase of x. With this vector, I can call mmg and revise my old mesh to get the new one. Thus, I wrote the following code, where I call mmg2d_O3 as an external command

load "mshmet"
load "medit"
mesh Th1 = square(10,10);
fespace Vh1(Th1,P1);
Vh1 G1,u1sol;
G1 = x^2. + 0.01;
real[int] met1 = mshmet(Th1,G1);
u1sol[] = met1;
savemesh(Th1,"Mesh1.mesh");
savesol("Mesh1.sol",Th1,u1sol);
exec("mmg2d_O3 Mesh1 -met Mesh1.sol");
mesh Th2 = readmesh("Mesh1.o.mesh");
plot(Th1,cmm="mesh before mmg");
plot(Th2,cmm="mesh after mmg");

However, the mesh after calling mmg does not show any variation pattern with respect to x (figures below). I checked the reason, finding that the vector met1 has a pretty uniform distribution, not showing any varied distribution with respect to x.

I wonder what’s is the wrong with my calling of mshmet at line 7? Thank you!

Initial Mesh

After revision

Hi,

I found a tutorial at http://annabellecollin.perso.math.cnrs.fr/TPS/TP_0.pdf (it’s in French sorry). You can download the file at http://annabellecollin.perso.math.cnrs.fr/TPS/Code_TP0.zip. In particular, you will see in adaptLPoisson.edp how that the metric exported as a .sol file is not directly the output of mshmet but is rescaled.

Best,

Lucas