# Question about movemesh in parallel

**URL:** <https://community.freefem.org/t/question-about-movemesh-in-parallel/4113>\
**Category:** General Discussion\
**Created:** [October 24, 2025, 3:24pm UTC](https://community.freefem.org/t/question-about-movemesh-in-parallel/4113 "2025-10-24T15:24:46Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![zxss](https://avatars.discourse-cdn.com/v4/letter/z/bc8723/32.png) [@zxss](https://community.freefem.org/u/zxss)\
**Post date:** [October 24, 2025, 3:24pm UTC](https://community.freefem.org/t/question-about-movemesh-in-parallel/4113/1 "2025-10-24T15:24:46Z")

</div>

Dear all,

I am implementing Navier Stokes equations with moving boundary using ALE method. I want to parallelize it. Firstly, I directly movemesh in parallel without ‘move the global mesh in a single processor‘, and the result seems normal.

[parallel\_moving\_boundary.edp](https://community.freefem.org/uploads/short-url/vX6qpF3xMa5rPeCTGefEhPyFAPR.edp) (3.0 KB)

However, when I you try to centralize mesh velocity function, move global mesh in a single process, and re-decompose, something strange happened. The rigid cylinder deforms

 ![Screenshot from 2025-10-24 16-18-04](https://canada1.discourse-cdn.com/flex030/uploads/freefem/original/2X/f/fb053a6f40d6030d28828f6e15f0df3d9304b801.png)

The changed code is

[withRediscompose.edp](https://community.freefem.org/uploads/short-url/abSVnXJRwjpC3Dlh34NRzwQU0tE.edp) (4.4 KB)

I suspect that there is something wrong of my changed code about redecompose part. Because when I choose 1 processor, the rigid circle still deforms.

---

<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:** [October 24, 2025, 3:32pm UTC](https://community.freefem.org/t/question-about-movemesh-in-parallel/4113/2 "2025-10-24T15:32:52Z")

</div>

If the code does not produce the desired results even with a single process, then that needs to be fixed first and foremost.

---

<div class="post-metadata">

**Author:** ![zxss](https://avatars.discourse-cdn.com/v4/letter/z/bc8723/32.png) [@zxss](https://community.freefem.org/u/zxss)\
**Post date:** [October 28, 2025, 1:26pm UTC](https://community.freefem.org/t/question-about-movemesh-in-parallel/4113/3 "2025-10-28T13:26:41Z")

</div>

Sorry for my late reply. I am still debugging. And I find something intersting when I use composite fespace in my sequential code

[Composite\_fespace.edp](https://community.freefem.org/uploads/short-url/1Y6tp1yNUpLPb0X9jifswUAOQVc.edp) (2.1 KB)

That is, when I solve the linear equation, if I make the arrays of two composite function equal

> ```auto
> Rh [ut, vt, pt]; // intermediate function
> ut[]=A^-1 * rhs;
> u[] = ut[];
> 
> ```

 ![Screenshot from 2025-10-28 13-22-35](https://canada1.discourse-cdn.com/flex030/uploads/freefem/original/2X/2/2c39db6bf0f39eb9da21d54ec28f488b39ebbd1b.png)

and when I do interpolation

```auto
Rh [ut, vt, pt]; // intermediate function
ut[]=A^-1 * rhs;
[u, v, p]=[ut, vt, pt]; 

```

 ![Screenshot from 2025-10-28 13-26-05](https://canada1.discourse-cdn.com/flex030/uploads/freefem/original/2X/f/f1c7e5fd1ec6f70be659e485ee3d4ee8673bc5e5.png)

these two results are different. And the latter is the same with using single fespace function.

[single\_fespace.edp](https://community.freefem.org/uploads/short-url/rTOI2qX2ZCP2ceYimm7ZTGlGYAn.edp) (2.0 KB)

My question is what cause such a big difference with changing just one line from

```auto
u[] = ut[]; 

```

to

```auto
[u, v, p]=[ut, vt, pt]; 

```

Is it becuase the different ordering or something else?

---

<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:** [October 28, 2025, 3:14pm UTC](https://community.freefem.org/t/question-about-movemesh-in-parallel/4113/4 "2025-10-28T15:14:58Z")

</div>

The figures you are plotting are not the ones from the `.edp` (which have no title). I don’t see a difference between both figures when I run your `.edp`.

---

<div class="post-metadata">

**Author:** ![zxss](https://avatars.discourse-cdn.com/v4/letter/z/bc8723/32.png) [@zxss](https://community.freefem.org/u/zxss)\
**Post date:** [October 28, 2025, 3:50pm UTC](https://community.freefem.org/t/question-about-movemesh-in-parallel/4113/5 "2025-10-28T15:50:23Z")

</div>

Sorry, this time…

These two codes are the same except line 53, 54

> [u, v, p]=[ut, vt, pt];
> 
> //u = ut;

[Interpolation.edp](https://community.freefem.org/uploads/short-url/dkjbEQ6FWSOlxZovb8WcrinQsL0.edp) (2.1 KB)

[Array.edp](https://community.freefem.org/uploads/short-url/4oxBATQLoXRsaG77zIqaM5k3qPD.edp) (2.1 KB)

And the results are

 ![Screenshot from 2025-10-28 15-49-47](https://canada1.discourse-cdn.com/flex030/uploads/freefem/original/2X/d/dbd8844cfa08200d489adcb2b136127e469a6803.png)

---

<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:** [October 28, 2025, 4:06pm UTC](https://community.freefem.org/t/question-about-movemesh-in-parallel/4113/6 "2025-10-28T16:06:34Z")

</div>

If you `cout` the solution, you’ll see they are the same, there is an issue with the plotting though, not really sure what’s going on.

---

<div class="post-metadata">

**Author:** ![zxss](https://avatars.discourse-cdn.com/v4/letter/z/bc8723/32.png) [@zxss](https://community.freefem.org/u/zxss)\
**Post date:** [October 28, 2025, 4:28pm UTC](https://community.freefem.org/t/question-about-movemesh-in-parallel/4113/7 "2025-10-28T16:28:17Z")

</div>

Thanks for your prompt reply, I try to cout u, v and uu, at the end

with

> cout\<\<u\<\<endl; cout\<\<v\<\<endl; cout\<\<uu\<\<endl;

and find that u and v are the same from both codes, uu is different.

 ![Screenshot from 2025-10-28 16-25-57](https://canada1.discourse-cdn.com/flex030/uploads/freefem/original/2X/0/042f70415da76b474cde666fed465b6b39c956ca.png)

Maybe there exists something wrong from this line

> uu=sqrt(u^2+v^2);

where u,v are function from composite fespace Rh [u,v,p]

---

<div class="post-metadata">

**Author:** ![zxss](https://avatars.discourse-cdn.com/v4/letter/z/bc8723/32.png) [@zxss](https://community.freefem.org/u/zxss)\
**Post date:** [October 28, 2025, 6:15pm UTC](https://community.freefem.org/t/question-about-movemesh-in-parallel/4113/8 "2025-10-28T18:15:48Z")

</div>

Dear professor, I have a further question, now I upgrade my sequential code into parallel code,

[sequential.edp](https://community.freefem.org/uploads/short-url/47svO9rH1iUVzn8jr1FKLAORz9G.edp) (2.1 KB)

[parallel.edp](https://community.freefem.org/uploads/short-url/bJxYhybotdGsI33zJlQAGN3CzSO.edp) (2.8 KB)

then I run them with FreeFem++ and ff-mpirun -n 1 (which is also sequential since only one processor is uses)respectively.

I find there exists a little bi difference from the plots of uu = sqrt(u^2+v^2);

 ![Screenshot from 2025-10-28 18-08-54](https://canada1.discourse-cdn.com/flex030/uploads/freefem/original/2X/b/bfa684ea24d53db11d4661949b455312d17e3e9d.png)

 ![Screenshot from 2025-10-28 18-09-09](https://canada1.discourse-cdn.com/flex030/uploads/freefem/original/2X/8/857a8e4df1f159011435f3f9cc15602a881d2f12.png)

the up is from sequential code and the bottom is from parallel code. I find the maxium values are different and the up looks smoother.

Is it because of different solvers? For sequential code, I choose

> set(A,solver=GMRES);  
> set(Ae,solver=GMRES);

while for the parallel code, from -ksp\_solve, I use ‘gmres’ with ‘lu’ for preconditioner.

I am not sure which one is more accurate.

---

<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:** [October 28, 2025, 7:39pm UTC](https://community.freefem.org/t/question-about-movemesh-in-parallel/4113/9 "2025-10-28T19:39:26Z")

</div>

Switch from `plotD` to `plot` (or `plotMPI`) and you should get the same output (`plotD` only plots P\_1 functions).

---

<div class="post-metadata">

**Author:** ![zxss](https://avatars.discourse-cdn.com/v4/letter/z/bc8723/32.png) [@zxss](https://community.freefem.org/u/zxss)\
**Post date:** [October 29, 2025, 11:21am UTC](https://community.freefem.org/t/question-about-movemesh-in-parallel/4113/10 "2025-10-29T11:21:21Z")

</div>

Many thinks, I got the same plots with

> ```
> macro def(u)u// EOM
> 
> plotMPI(Thf, uu, P2, def, real, cmm = "magnitude of velocity");
> 
> ```

Although I don’t know why a macro needs to be defined here…

---

<div class="post-metadata">

**Author:** ![zxss](https://avatars.discourse-cdn.com/v4/letter/z/bc8723/32.png) [@zxss](https://community.freefem.org/u/zxss)\
**Post date:** [October 29, 2025, 8:30pm UTC](https://community.freefem.org/t/question-about-movemesh-in-parallel/4113/11 "2025-10-29T20:30:02Z")

</div>

Dear, professor,

I want to do some numerical experiments to show the error when I directly use ‘movemesh‘ in parallel, and from the results, I find in this case, ‘movemesh‘ works well using 50 processors(maybe just a coincidence). The codes are

[sequential.edp](https://community.freefem.org/uploads/short-url/5X9Mk6nMbTxNNGR1OLPGldkjxXT.edp) (2.1 KB)

[parallel.edp](https://community.freefem.org/uploads/short-url/nsqrkLHkmMgRfVTJVxTgR9hlMZ2.edp) (3.2 KB)

where the solvers are UMFPACK in sequential code and GMRES with LU (preconditioner)in parallel code. First of all, I got three plots using

 ![Screenshot from 2025-10-29 19-10-01](https://canada1.discourse-cdn.com/flex030/uploads/freefem/original/2X/d/d3d57a5045220aa86b0cc51b7d8b38a6fe763491.png)

> FreeFem++ sequential.edp -wg -v 0
> 
> ff-mpirun -n 1 parallel.edp -wg -v 0
> 
> ff-mpirun -n 50 parallel.edp -wg -v 0

respectively (in order to magnify the error, under the assumption that more subdomains, more error, I choose 50 processors as comparison). From these three plots, they share the same maximum and minimum values. Since it’s just qualitative comparison. I try to do some quantitative comparisons in Paraview with .vtu files generated using ‘savevtk’ command.

for the sake of simplicity, here I only show one node of the last vtu/pvd file.

 ![image0](https://canada1.discourse-cdn.com/flex030/uploads/freefem/original/2X/7/72c7fab9cc0ed41cb4d15ff047f4c807fec6592d.jpeg)

 ![image2](https://canada1.discourse-cdn.com/flex030/uploads/freefem/original/2X/d/d390b6089140a07f36dff456c38bf2fd4a5cdfe2.jpeg)

 ![image1](https://canada1.discourse-cdn.com/flex030/uploads/freefem/original/2X/6/625f714c15612322d34c945d2873b4c809e3ed80.jpeg)

They share the same values of ‘u v w1 w2‘, and the only difference is the node index of 50 processors is different from others.

I want to figure out more details of

> x=A^-1 \* b;

where A is the distributed matrix. I want to talk about my understanding(maybe not correct), I use 2 processors and P1 element as an example

 ![IMG_4507](https://canada1.discourse-cdn.com/flex030/uploads/freefem/original/2X/f/f8e2d4add8d50846ac73dea55f8896b8ffc43635.jpeg)

Since the ghost element actually belongs to one processor(here I assume it belongs to processor # 1), the distributed matrix A is a 5\*5 matrix, after solving the linear system. The values of ghost element in processor # 2 are unknown. Are they given randomly?

---

<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:** [October 29, 2025, 8:34pm UTC](https://community.freefem.org/t/question-about-movemesh-in-parallel/4113/12 "2025-10-29T20:34:02Z")

</div>

Of course they are not given randomly. Ghost values are consistent among processes after operations such as matrix-vector product and solution of linear systems.

---

<div class="post-metadata">

**Author:** ![zxss](https://avatars.discourse-cdn.com/v4/letter/z/bc8723/32.png) [@zxss](https://community.freefem.org/u/zxss)\
**Post date:** [October 30, 2025, 10:07am UTC](https://community.freefem.org/t/question-about-movemesh-in-parallel/4113/13 "2025-10-30T10:07:43Z")

</div>

Cool, then it can be explained why movemesh works well in this case,

because in

> Thf = movemesh(Thf, [x+w1\*dt, y+w2\*dt]);

w1,w2 are mesh velocity function solved by an pseudo-elastic equation

> varf elastic([w1,w2],[w1h,w2h])= int2d(Thf)(
> 
> ```
> trace(DD(w1,w2)\*DD(w1h,w2h)') + 10\*div(w1,w2)\*div(w1h,w2h) )
> 
> ```
> 
> + on(5,w1=4\*sin(pi\*t),w2=0)+on(1,3,w2=0)+ on(2,4,w1=0);

they are consistent over ghost elements.
