# Different mesh interpolation TypeError

**URL:** <https://fenicsproject.discourse.group/t/different-mesh-interpolation-typeerror/10436>\
**Category:** General\
**Created:** [February 16, 2023, 11:15am UTC](https://fenicsproject.discourse.group/t/different-mesh-interpolation-typeerror/10436 "2023-02-16T11:15:31Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![MPenaR](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/mpenar/32/2985_2.png) [@MPenaR](https://fenicsproject.discourse.group/u/MPenaR)\
**Post date:** [February 16, 2023, 11:15am UTC](https://fenicsproject.discourse.group/t/different-mesh-interpolation-typeerror/10436/1 "2023-02-16T11:15:31Z")

</div>

Im trying to interpolate one `Function` between two different meshes. Basically, what I’m doing is (assuming I already have computed `T` in )

```auto
H = FunctionSpace(mesh,('Lagrange',2))
T_int = Function(H)
T_int.interpolate(T, nmm_interpolation_data=create_nonmatching_meshes_interpolation_data( T._V, H))

```

However, I get the following error:

```auto
TypeError: create_nonmatching_meshes_interpolation_data(): incompatible function arguments. The following argument types are supported:
    1. (Vu: dolfinx::fem::FunctionSpace, Vv: dolfinx::fem::FunctionSpace) -> Tuple[List[int], List[int], List[float], List[int]]
    2. (Vu: dolfinx::fem::FunctionSpace, Vv: dolfinx::fem::FunctionSpace, cells: numpy.ndarray[numpy.int32]) -> Tuple[List[int], List[int], List[float], List[int]]

Invoked with: FunctionSpace(Mesh(VectorElement(Basix element (P, triangle, 1, equispaced, unset, False), 2), 5), Basix element (P, triangle, 2, gll_warped, unset, False)), FunctionSpace(Mesh(VectorElement(Basix element (P, triangle, 1, equispaced, unset, False), 2), 6), Basix element (P, triangle, 2, gll_warped, unset, False))

```

I am using `dolfinx 0.6.0`, thank you very much

EDIT: if I chage the order of the funcion spaces, i.e. if I call

```auto
create_nonmatching_meshes_interpolation_data( H, T._V)

```

I get exactly the same error

---

<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:** [February 16, 2023, 12:07pm UTC](https://fenicsproject.discourse.group/t/different-mesh-interpolation-typeerror/10436/2 "2023-02-16T12:07:24Z")

</div>

See for instance the test: [dolfinx/test\_function.py at 8d55f950ca427228a96e96d43893b52b5071bf35 · FEniCS/dolfinx · GitHub](https://github.com/FEniCS/dolfinx/blob/8d55f950ca427228a96e96d43893b52b5071bf35/python/test/unit/fem/test_function.py#L199-L202)

---

<div class="post-metadata">

**Author:** ![dg0609](https://avatars.discourse-cdn.com/v4/letter/d/ad7895/32.png) [@dg0609](https://fenicsproject.discourse.group/u/dg0609)\
**Post date:** [March 3, 2023, 8:59pm UTC](https://fenicsproject.discourse.group/t/different-mesh-interpolation-typeerror/10436/3 "2023-03-03T20:59:21Z")

</div>

Is there a trick to using `create_nonmatching_meshes_interpolation_data`? I attempt a simple`from dolfinx.fem import create_nonmatching_meshes_interpolation_data` and get the following error:

```auto
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
Cell In[7], line 1
----> 1 from dolfinx.fem import create_nonmatching_meshes_interpolation_data

ImportError: cannot import name 'create_nonmatching_meshes_interpolation_data' from 'dolfinx.fem' (/usr/local/anaconda3/envs/fenicsx-env/lib/python3.10/site-packages/dolfinx/fem/ __init__.py)

```

---

<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:** [March 3, 2023, 9:24pm UTC](https://fenicsproject.discourse.group/t/different-mesh-interpolation-typeerror/10436/4 "2023-03-03T21:24:12Z")

</div>

What version of DOLFINx do you have installed ?

---

<div class="post-metadata">

**Author:** ![dg0609](https://avatars.discourse-cdn.com/v4/letter/d/ad7895/32.png) [@dg0609](https://fenicsproject.discourse.group/u/dg0609)\
**Post date:** [March 3, 2023, 9:29pm UTC](https://fenicsproject.discourse.group/t/different-mesh-interpolation-typeerror/10436/5 "2023-03-03T21:29:04Z")

</div>

conda version 0.6.0. I’m in the process of updating because I saw [here](https://anaconda.org/conda-forge/fenics-dolfinx) that was an update 11 days ago. Hopefully that’s the problem.

EDIT. Updating didn’t help

---

<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:** [March 3, 2023, 10:31pm UTC](https://fenicsproject.discourse.group/t/different-mesh-interpolation-typeerror/10436/6 "2023-03-03T22:31:31Z")

</div>

This functionality was added after the 0.6.0 release.

> <https://github.com/FEniCS/dolfinx/pull/2414>
>
> After merging #2245 dolfinx can interpolate discrete functions defined on differ…ent meshes. This is, however, quite costly.
> This PR adds a class that performs this interpolation caching as much data as possible so that interpolating again between the same two functions, when their meshes haven't moved, is much cheaper.
> 
> Some timings for the same example as in the discussion of #2245 \[mesh with 750'000 cells\]
> \`\`\`
> serial
> Interpolating 7.311494
> Interpolating again 0.572593
> 
> n = 6 processes
> Interpolating 1.772976
> Interpolating again 0.164332
> \`\`\`

The 0.6.0 release supports interpolation between meshes, but does not offer the Pre-compute interpolation data step.
