# Moving interface and remesh across cores in parallel

**URL:** https://community.freefem.org/t/moving-interface-and-remesh-across-cores-in-parallel/1023
**Category:** General Discussion
**Created:** [June 9, 2021, 6:10pm UTC](https://community.freefem.org/t/moving-interface-and-remesh-across-cores-in-parallel/1023 "2021-06-09T18:10:57Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![yongxing](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/yongxing/32/3632_2.png) [@yongxing](https://community.freefem.org/u/yongxing)
#### Post date: [June 9, 2021, 6:10pm UTC](https://community.freefem.org/t/moving-interface-and-remesh-across-cores-in-parallel/1023/1 "2021-06-09T18:10:57Z")

</div>

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](https://community.freefem.org/u/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

---

<div class="post-metadata">

### Author: ![prj](https://avatars.discourse-cdn.com/v4/letter/p/ecae2f/32.png) [@prj](https://community.freefem.org/u/prj)
#### Post date: [June 10, 2021, 5:12am UTC](https://community.freefem.org/t/moving-interface-and-remesh-across-cores-in-parallel/1023/2 "2021-06-10T05:12:44Z")

</div>

> <https://github.com/FreeFem/FreeFem-sources/blob/develop/examples/hpddm/laplace-adapt-3d-PETSc.edp>

---

<div class="post-metadata">

### Author: ![yongxing](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/yongxing/32/3632_2.png) [@yongxing](https://community.freefem.org/u/yongxing)
#### Post date: [June 10, 2021, 12:59pm UTC](https://community.freefem.org/t/moving-interface-and-remesh-across-cores-in-parallel/1023/4 "2021-06-10T12:59:02Z")

</div>

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(…);

```auto
	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;	
}

```

---

<div class="post-metadata">

### Author: ![prj](https://avatars.discourse-cdn.com/v4/letter/p/ecae2f/32.png) [@prj](https://community.freefem.org/u/prj)
#### Post date: [June 10, 2021, 1:00pm UTC](https://community.freefem.org/t/moving-interface-and-remesh-across-cores-in-parallel/1023/5 "2021-06-10T13:00:20Z")

</div>

> <https://github.com/FreeFem/FreeFem-sources/blob/develop/examples/hpddm/newton-adaptmesh-2d-PETSc.edp>

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](https://community.freefem.org/t/copy-variables-between-different-meshes-with-petsc/390).

---

<div class="post-metadata">

### Author: ![qingYang](https://avatars.discourse-cdn.com/v4/letter/q/9f8e36/32.png) [@qingYang](https://community.freefem.org/u/qingYang)
#### Post date: [January 14, 2024, 3:38am UTC](https://community.freefem.org/t/moving-interface-and-remesh-across-cores-in-parallel/1023/6 "2024-01-14T03:38:42Z")

</div>

Dear developer：  
I would like to ask you a question. for layermesh , through :  
mesh3 Th3 = buildlayers(Th, MaxLayer, zbound=[zmin,zmax],labelmid, labelup , labeldown );  
we can get the label of the surface grid. Is there any method to set the label for each internal layer grid?  
for example: MaxLayer=5,Is there any way to obtain the label of the second layer grid？
