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

**URL:** <https://community.freefem.org/t/interpolate-between-local-non-overlap-mesh-to-local-overlap-mesh/925>\
**Category:** General Discussion\
**Created:** [April 16, 2021, 4:57pm UTC](https://community.freefem.org/t/interpolate-between-local-non-overlap-mesh-to-local-overlap-mesh/925 "2021-04-16T16:57:14Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![KBarrett](https://avatars.discourse-cdn.com/v4/letter/k/96bed5/32.png) [@KBarrett](https://community.freefem.org/u/KBarrett)\
**Post date:** [April 16, 2021, 4:57pm UTC](https://community.freefem.org/t/interpolate-between-local-non-overlap-mesh-to-local-overlap-mesh/925/1 "2021-04-16T16:57:14Z")

</div>

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.

---

<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:** [April 16, 2021, 5:01pm UTC](https://community.freefem.org/t/interpolate-between-local-non-overlap-mesh-to-local-overlap-mesh/925/2 "2021-04-16T17:01:23Z")

</div>

That’s trivial to do with `buildDmesh`, see [FreeFem-sources/minimal-surface-Tao-2d-PETSc.edp at develop · FreeFem/FreeFem-sources · GitHub](https://github.com/FreeFem/FreeFem-sources/blob/develop/examples/hpddm/minimal-surface-Tao-2d-PETSc.edp).

---

<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:** [April 16, 2021, 5:22pm UTC](https://community.freefem.org/t/interpolate-between-local-non-overlap-mesh-to-local-overlap-mesh/925/3 "2021-04-16T17:22:30Z")

</div>

Here is a MWE.

```auto
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)")

```

---

<div class="post-metadata">

**Author:** ![KBarrett](https://avatars.discourse-cdn.com/v4/letter/k/96bed5/32.png) [@KBarrett](https://community.freefem.org/u/KBarrett)\
**Post date:** [April 16, 2021, 8:21pm UTC](https://community.freefem.org/t/interpolate-between-local-non-overlap-mesh-to-local-overlap-mesh/925/4 "2021-04-16T20:21:17Z")

</div>

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?

---

<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:** [April 16, 2021, 8:31pm UTC](https://community.freefem.org/t/interpolate-between-local-non-overlap-mesh-to-local-overlap-mesh/925/5 "2021-04-16T20:31:25Z")

</div>

No, I would recommend using PETSc/macro\_ddm.idp.

---

<div class="post-metadata">

**Author:** ![KBarrett](https://avatars.discourse-cdn.com/v4/letter/k/96bed5/32.png) [@KBarrett](https://community.freefem.org/u/KBarrett)\
**Post date:** [April 16, 2021, 8:32pm UTC](https://community.freefem.org/t/interpolate-between-local-non-overlap-mesh-to-local-overlap-mesh/925/6 "2021-04-16T20:32:30Z")

</div>

Ah okay. Thank you very much for the advice.

---

<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:** [April 16, 2021, 8:53pm UTC](https://community.freefem.org/t/interpolate-between-local-non-overlap-mesh-to-local-overlap-mesh/925/7 "2021-04-16T20:53:10Z")

</div>

If you are new to parallel computing with FreeFEM, you may be interested in these two tutorial videos: [[1](https://www.youtube.com/watch?v=-Aw2O46V2bo), [2](https://www.youtube.com/watch?v=Hx57gxTOnvE)].
