Issue with ghost elements

Dear All,

I am having an issue with the transfer of my variable from one iteration to the next while implementing a number of processes (n)>1.
My problem has the addition of material and moving heat source with each iteration. From the youtube videos of freefem, I got to know about some highly efficient functionality such as ‘’’ restrict & macro Th1N2O() myn2o// ‘’’ . However, what I lack currently in my code is a way to handle the ghost nodes in my global solution.
With n=1, I am getting good results, whereas, with n=4 as soon my heat source is coming near the ghost nodes, its giving some faulty results.
Is there some macros or function that can be implemented to handle this?

I am writing some important sections of my code for your understanding.
Thank you in advance for your help.


ThGlobal= readmesh3(“Global.mesh”); // Global Mesh

Material addition for loop {
mesh3 Th1 = trunc(ThGlobal…
mesh3 backupTh=Th1;

fespace Vhbackup(backupTh,P1);
int[int] subIDx1=restrict(Vhbackup,Vhglobal,n2o);
Vhbackup Tbackup;

macro dimension()3// EOM
include “macro_ddm.idp”
int[int] myn2o;
macro Th1N2O() myn2o//
fespace Vh(Th1,P1);

int[int] subIDx2=restrict(Vh,Vhbackup,myn2o);
Vh T, TT;

load “PETSc”
Mat A;
T[] = A^-1*b[];

1 Like

Could you please copy/paste a fully runnable example? I think I get what you want to do, but it will much faster for me to help you out if I can actually run your code.

Thank you for your reply.
I hereby attach the link for my .edp and mesh file.

Let me know if the files are not properly shared;


Right, you are missing the partition of unity. You can check this tutorial which explains this. If you don’t succeed at applying this to your code, let me know and I’ll do it myself. Thanks.

Dear Prj,
Thank you for your reply. I have added the partition of unity to my problem and thanks to the partition of unity, ghost nodes are not giving me any issue.
However, I believe I am having a problem when I am storing the data (in this case T ) from my previous iteration.
In my case, my T from the previous iteration acts as an initial condition for my next iteration and there is also an addition of elements at each iteration.

When I compare my result from the iter=0 to the initial condition at iter=1, I am getting a completely different T. Normally, both of them should be equal except for the elements that I added to encounter the material addition.
When I run for the number of processors (n) 1, the initial condition of my current iteration (Tcurrent.vtu) is the same as my results from the previous iteration (Tbackup.vtu).
However, for n other than 1, giving faulty result.
I am certain that it is something trivial issue, I must be doing something foolish.
Would you be able to see this issue and tell me where I am doing wrong?

Here is the link to my .edp and .mesh file.


You are missing a reduction operation, which I believe is covered in the video tutorial I sent earlier.


should become something like

real[int] reduction(Tbackup[].n);

Otherwise, the processes don’t share the same values (when mpisize > 1) and you get garbage for the next iteration.

Thanks a lot for your quick reply. Indeed, I missed the reduction operator.

Thank you for your help, everything is working perfectly.

Have a good day ahead. Sincere Regards.