# Interpolation between different meshes in 0.7.1

**URL:** <https://fenicsproject.discourse.group/t/interpolation-between-different-meshes-in-0-7-1/12667>\
**Category:** General\
**Created:** [November 6, 2023, 5:17pm UTC](https://fenicsproject.discourse.group/t/interpolation-between-different-meshes-in-0-7-1/12667 "2023-11-06T17:17:49Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Holzi](https://avatars.discourse-cdn.com/v4/letter/h/5f9b8f/32.png) [@Holzi](https://fenicsproject.discourse.group/u/Holzi)\
**Post date:** [November 6, 2023, 5:17pm UTC](https://fenicsproject.discourse.group/t/interpolation-between-different-meshes-in-0-7-1/12667/1 "2023-11-06T17:17:49Z")

</div>

Hey there,

I just shifted from dolfinx 0.6.0 to the new version 0.7.1 and found some behavior I could not explain myself. In version 0.6.0 I could interpolate between meshes (as in the following MWE)

```auto
from mpi4py import MPI
import dolfinx as dfx
import numpy as np

print("dolfinx version:", dfx. __version__ )
mesh1 = dfx.mesh.create_unit_interval(MPI.COMM_SELF, 10)
V1 = dfx.fem.FunctionSpace(mesh1, ("CG", 1))
mesh2 = dfx.mesh.create_interval(MPI.COMM_WORLD, 5, (0.0, 0.5))
V2 = dfx.fem.FunctionSpace(mesh2, ("CG", 1))

func1 = dfx.fem.Function(V1)
func1.x.array[:] = np.arange(len(V1.tabulate_dof_coordinates()))

print("func1.x.array", func1.x.array)

func2 = dfx.fem.Function(V2)
func2.interpolate(func1)

print("func2.x.array", func2.x.array)

```

and get

```auto
dolfinx version: 0.6.0
func1.x.array [0. 1. 2. 3. 4. 5. 6. 7. 8. 9. 10.]
func2.x.array [0. 1. 2. 3. 4. 5.]

```

Now, in the new version, running the same code as above, I get

```auto
dolfinx version: 0.7.1
func1.x.array [0. 1. 2. 3. 4. 5. 6. 7. 8. 9. 10.]
[0]PETSC ERROR: ------------------------------------------------------------------------
[0]PETSC ERROR: Caught signal number 11 SEGV: Segmentation Violation, probably memory access out of range
[0]PETSC ERROR: Try option -start_in_debugger or -on_error_attach_debugger
[0]PETSC ERROR: or see https://petsc.org/release/faq/#valgrind and https://petsc.org/release/faq/
[0]PETSC ERROR: configure using --with-debugging=yes, recompile, link, and run 
[0]PETSC ERROR: to get more information on the crash.
[0]PETSC ERROR: Run with -malloc_debug to check if memory corruption is causing the crash.
Abort(59) on node 0 (rank 0 in comm 0): application called MPI_Abort(MPI_COMM_WORLD, 59) - process 0

```

Did something change in the interpolation interface from 0.6 to 0.7? I tried looking up the “User facing changes” of v0.7.0 and found [#2414](https://github.com/FEniCS/dolfinx/pull/2414), but I’m not sure what I can do to get my code running again. Specifically, I used the installation via conda for both versions.  
Thanks a lot 🙂

---

<div class="post-metadata">

**Author:** ![dokken](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/dokken/32/1560_2.png) [@dokken](https://fenicsproject.discourse.group/u/dokken)\
**Post date:** [November 6, 2023, 7:59pm UTC](https://fenicsproject.discourse.group/t/interpolation-between-different-meshes-in-0-7-1/12667/2 "2023-11-06T19:59:18Z")

</div>

> [@Holzi](#):
>
> Did something change in the interpolation interface from 0.6 to 0.7? I tried looking up the “User facing changes” of v0.7.0 and found [#2414](https://github.com/FEniCS/dolfinx/pull/2414), but I’m not sure what I can do to get my code running again. Specifically, I used the installation via conda for both versions.  
> Thanks a lot 🙂

As indicated by the changes in the referenced PR, you should supply the interpolation data, i.e.

```python
from mpi4py import MPI
import dolfinx as dfx
import numpy as np

print("dolfinx version:", dfx. __version__ )
mesh1 = dfx.mesh.create_unit_interval(MPI.COMM_SELF, 10)
V1 = dfx.fem.FunctionSpace(mesh1, ("CG", 1))
mesh2 = dfx.mesh.create_interval(MPI.COMM_WORLD, 5, (0.0, 0.5))
V2 = dfx.fem.FunctionSpace(mesh2, ("CG", 1))

func1 = dfx.fem.Function(V1)
func1.x.array[:] = np.arange(len(V1.tabulate_dof_coordinates()))

print("func1.x.array", func1.x.array)

func2 = dfx.fem.Function(V2)
interpolation_data = dfx.fem.create_nonmatching_meshes_interpolation_data(
        func2.function_space.mesh._cpp_object,
        func2.function_space.element,
        func1.function_space.mesh._cpp_object)
func2.interpolate(func1, nmm_interpolation_data=interpolation_data)

print("func2.x.array", func2.x.array)

```
