# Recover correspondence between 2d mesh and sufrace mesh

**URL:** <https://community.freefem.org/t/recover-correspondence-between-2d-mesh-and-sufrace-mesh/496>\
**Category:** General Discussion\
**Created:** [July 7, 2020, 1:30pm UTC](https://community.freefem.org/t/recover-correspondence-between-2d-mesh-and-sufrace-mesh/496 "2020-07-07T13:30:22Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![BeniaminBogosel](https://avatars.discourse-cdn.com/v4/letter/b/3ec8ea/32.png) [@BeniaminBogosel](https://community.freefem.org/u/BeniaminBogosel)\
**Post date:** [July 7, 2020, 1:30pm UTC](https://community.freefem.org/t/recover-correspondence-between-2d-mesh-and-sufrace-mesh/496/1 "2020-07-07T13:30:22Z")

</div>

Hello,  
as seen in the FreeFEM documentation, it is possible to construct surface meshes starting from two dimensional meshes using the command `movemesh23`. When doing this (for example in the case of a sphere) some points may merge.

I would like to be able to recover the correspondence between the points in the 2d mesh and the surface mesh in order to transport some finite element function from one mesh to another (e.g. the parametrization angles theta and phi). Is it possible to recover the correspondence between vertices in the 2d mesh and vertices on the surface mesh?

Thank you,  
Beniamin

---

<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:** [July 7, 2020, 4:19pm UTC](https://community.freefem.org/t/recover-correspondence-between-2d-mesh-and-sufrace-mesh/496/2 "2020-07-07T16:19:01Z")

</div>

Can’t you use `interpolate` between two P\_1 `fespace`, one defined on your `meshS`, the other on your `mesh`? For sure this works between `meshL` and `mesh`, see [this](https://github.com/FreeFem/FreeFem-sources/blob/develop/examples/hpddm/helmholtz-coupled-2d-PETSc-complex.edp#L99) example.

---

<div class="post-metadata">

**Author:** ![BeniaminBogosel](https://avatars.discourse-cdn.com/v4/letter/b/3ec8ea/32.png) [@BeniaminBogosel](https://community.freefem.org/u/BeniaminBogosel)\
**Post date:** [July 10, 2020, 8:40am UTC](https://community.freefem.org/t/recover-correspondence-between-2d-mesh-and-sufrace-mesh/496/3 "2020-07-10T08:40:48Z")

</div>

Thank you for your answer. I thought that interpolate is used for interpolation. Does it still work between a 2d mesh and a surface mesh? I will check it out.

---

<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:** [July 10, 2020, 9:09am UTC](https://community.freefem.org/t/recover-correspondence-between-2d-mesh-and-sufrace-mesh/496/4 "2020-07-10T09:09:00Z")

</div>

A restriction (from a 2D to a surface mesh) is indeed a special kind of interpolation, but an interpolation nonetheless.

---

<div class="post-metadata">

**Author:** ![BeniaminBogosel](https://avatars.discourse-cdn.com/v4/letter/b/3ec8ea/32.png) [@BeniaminBogosel](https://community.freefem.org/u/BeniaminBogosel)\
**Post date:** [July 10, 2020, 2:47pm UTC](https://community.freefem.org/t/recover-correspondence-between-2d-mesh-and-sufrace-mesh/496/5 "2020-07-10T14:47:58Z")

</div>

I tried the suggestion, but it doesn’t seem to work:

Here’s what I get (in my code ThS is the surface mes obtained from Th with movemesh23):

101 : fespace VhS(ThS,P1); // surface Finite elements  
102 : VhS uS;  
103 :  
104 : fespace VhFlat(Th,P1,periodic=perio); // 2d finite elements  
105 : VhFlat u;  
106 :  
107 : matrix Rest = interpolate(VhS,VhFlat) error operator ( \<PP6v\_fesS\>, \<PP5v\_fes\>  
List of choices  
( \<N19MatrixInterpolationIP5v\_fesS1\_E2OpE\> : \<PP5v\_fes\>, \<PP5v\_fes\> )  
( \<N19MatrixInterpolationIP6v\_fesLP6v\_fesSE2OpE\> : \<PP6v\_fesL\>, \<PP6v\_fesS\> )  
( \<N19MatrixInterpolationIP6v\_fesLP5v\_fesE2OpE\> : \<PP6v\_fesL\>, \<PP5v\_fes\> )  
( \<N19MatrixInterpolationIP6v\_fesSP6v\_fes3E2OpE\> : \<PP6v\_fesS\>, \<PP6v\_fes3\> )  
( \<N19MatrixInterpolationIP6v\_fesLS1\_E2OpE\> : \<PP6v\_fesL\>, \<3KN\_IdE\>, \<3KN\_IdE\>, \<3KN\_IdE\> )  
( \<N19MatrixInterpolationIP6v\_fesLS1\_E2OpE\> : \<PP6v\_fesL\>, \<PP6v\_fesL\> )  
( \<N19MatrixInterpolationIP6v\_fesSS1\_E2OpE\> : \<PP6v\_fesS\>, \<3KN\_IdE\>, \<3KN\_IdE\>, \<3KN\_IdE\> )  
( \<N19MatrixInterpolationIP6v\_fesSS1\_E2OpE\> : \<PP6v\_fesS\>, \<PP6v\_fesS\> )  
( \<N19MatrixInterpolationIP6v\_fes3S1\_E2OpE\> : \<PP6v\_fes3\>, \<3KN\_IdE\>, \<3KN\_IdE\>, \<3KN\_IdE\> )  
( \<N19MatrixInterpolationIP6v\_fes3S1\_E2OpE\> : \<PP6v\_fes3\>, \<PP6v\_fes3\> )  
( \<N19MatrixInterpolationIP5v\_fesS1\_E2OpE\> : \<PP5v\_fes\>, \<3KN\_IdE\>, \<3KN\_IdE\> )

---

<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:** [July 10, 2020, 3:01pm UTC](https://community.freefem.org/t/recover-correspondence-between-2d-mesh-and-sufrace-mesh/496/6 "2020-07-10T15:01:44Z")

</div>

> [@BeniaminBogosel](#):
>
> ( \<N19MatrixInterpolationIP6v\_fesLP6v\_fesSE2OpE\> : \<PP6v\_fesL\>, \<PP6v\_fesS\> )  
> ( \<N19MatrixInterpolationIP6v\_fesLP5v\_fesE2OpE\> : \<PP6v\_fesL\>, \<PP5v\_fes\> )  
> ( \<N19MatrixInterpolationIP6v\_fesSP6v\_fes3E2OpE\> : \<PP6v\_fesS\>, \<PP6v\_fes3\> )

Indeed, looks like it can only do `meshL` ↔ `meshS`, `meshL` ↔ `mesh`, or `meshS` ↔ `mesh3`.
