Dear all,

I am trying to run an example involving the resolution of several time-dependent pdes on meshes adapted at each time step, and I very soon get stuck with problems related to bad memory allocation. After some checks, I found a weird behavior related to the adaptmesh function which might explain my troubles: the finite element functions defined on the mesh are not automatically resized (or they are sometimes, but a little bit unpredicatably…).

Here is a minimal example:

/* Mesh of the domain */

border left(t=0.0,1.5){x=0.0; y=1.5-t; label=0;};

border bot(t=0.0,1.0){x=t; y=0; label=1;};

border right(t=0.0,1.5){x=1.0; y=t; label=0;};

border top(t=0.0,1.0){x=1.0-t; y=1.5; label=1;};

mesh Th = buildmesh(left(75)+bot(50)+right(75)+top(50));

/* Finite element spaces */

fespace Ph(Th,P1);

fespace Ph0(Th,P0);

/* Finite element functions */

Ph u;

Ph0 p;

/* Before adaptation; the number of vertices coincide from both sources */

cout<<"Number of vertices “<<Th.nv<<” in u "<<u[].n<<endl;

cout<<"Number of trias “<<Th.nt<<” in p "<<p[].n<<endl;

/* Adaptation */

Th = adaptmesh(Th,hmin=0.01,hmax=0.01,nbvx=30000,iso=1);

/* After adaptation; the size of u and p is not changed (in some of my examples, it is

quite randomly */

cout<<"Number of vertices “<<Th.nv<<” in u "<<u[].n<<endl;

cout<<"Number of trias “<<Th.nt<<” in p "<<p[].n<<endl;

Is there something I am missing about this?

Thank you so much for your help in advance, and have a good day!