Moving interface and remesh across cores in parallel

Dear all,

I am dealing with a moving interface FSI problem, and need to remesh after several steps of moving the old mesh…

For a serial code, I just track the fluid-solid interface using extractborder(), and after several steps I then buildmesh()…

Does anyone have an idea to implement this using of piece of parallel code? is there a template FreeFEM code?

@ mojtaba.barzegari: I am actually modifying your parallel fluid code to implement a FSI problem. Do you have any idea how to build a new mesh after several time step? Do I need to build at (mpirank == 0) first, then broadcast(processor(0), Th) again?

Best,
Yongxing

Thank you very much for the code Pierre.
I now can use the idea in the code to successfully rebuild my new mesh, can broadcast it the other processors.
However, my velocity field on the new mesh is wrong. Do you have an idea to interpolate the old velocity, say [ux, uy], from the old mesh to the new one?
In the code you sent to me, new value is just set to u=0.

The following is my current remeshing code:

if(n%20 == 0){
if (mpirank == 0) Thnew = buildmesh(…);

	Th=Thnew;
	broadcast(processor(0), Th);
	[ux,uy,p]=[ux,uy,p]; [sx,sy]=[sx,sy];		// this does not work unfortunately
	
    Mat Aadapt, Madapt;
	buildDmesh(Th);
	{
	  macro def(i)[i, i#B, i#C]//
	  macro init(i)[i, i, i]//
	  createMat(Th, Aadapt, [P2, P2, P1])
	}
    A = Aadapt;
	{
	  macro def(i)[i, i#B]//
	  macro init(i)[i, i]//
	  createMat(Th, Madapt, [P2, P2])
	}		
    M = Madapt;	
}

You need to centralize your velocity first. Then, interpolate the centralized velocity. And eventually, dispatch the globally interpolated velocity on each subdomain.

You can also search the forum to find other ways to achieve this, e.g., Copy variables between different meshes with PETSc.