# Interpolate between local non-overlap mesh to local overlap mesh

Hello FF community,

I have created two sets of local meshes: one where there is overlap and one with no overlap, and I’m using ffddmbuildDmesh function to create my decomposed mesh. I need a local mesh with no overlap to calculate integrals and execute an optimizer function, so I interpolate from the local overlap mesh (which is the domain of the solutions to my varf) to the non-overlap via direct interpolation, and this seems to work fine as my integrals are correct.

But is there a way to go from the local non-overlap to the local overlap without having to send the local non-overlap data to the global mesh and then re-distribute to local overlap again? The output of my optimizer is data on the local non-overlap mesh, but when I iterate my optimization, I need the data back on the local overlap mesh.

Thank you for any guidance you can share.

That’s trivial to do with `buildDmesh`, see FreeFem-sources/minimal-surface-Tao-2d-PETSc.edp at develop · FreeFem/FreeFem-sources · GitHub.

Here is a MWE.

``````load "PETSc"
include "macro_ddm.idp"

mesh ThNo, Th = square(getARGV("-global", 80), getARGV("-global", 80));
fespace Ph(Th, P0);
Ph part;
Mat A;
func Pk = P2;
buildDmesh(Th)
createMat(Th, A, Pk)
createPartition(Th, part[], P0)
int[int] n2o;
ThNo = trunc(Th, abs(part - 1.0) < 1e-1, new2old = n2o);

fespace Vh(Th, Pk);
Vh u = x^2+cos(4*pi*y);
real reduce, sum = int2d(ThNo)(u);
mpiReduce(sum, reduce, processor(0), mpiSUM);
if(mpirank == 0)
cout << reduce << endl;

fespace VhNo(ThNo, Pk);
VhNo uNo = u;
int[int] rest = restrict(VhNo, Vh, n2o);
u[] = 0;
u[](rest) = uNo[];
plotD(Th, u, cmm = "From no overlap to overlap (not synchronized => wrong)")
exchange(A, u[], scaled = true);
plotD(Th, u, cmm = "From no overlap to overlap (synchronized => correct)")
``````

Thank you very much. I noticed that the newer examples, as well as your recommendation now, uses buildDmesh - does this mean that ffddmbuildDmesh will not work for the rest of this method?

No, I would recommend using PETSc/macro_ddm.idp.

Ah okay. Thank you very much for the advice.

If you are new to parallel computing with FreeFEM, you may be interested in these two tutorial videos: [1, 2].

1 Like