Hi, I am trying to interpolate between two meshes of different shapes (for visualisation purposes) for which I’m getting an error. I’m able to do this perfectly on an older installation using dolfinx’s v0.6.0 release. However, I have unfortunately had to switch to an installation with python 3.11 which seems to require this fix. I don’t know what updates were made between v0.6.0 and this newer commit that breaks the interpolation. This does not work with an installation using git clones of all the packages at the current main, nor with an installation at the time of that commit (Jan 28th).
Below is an MWE of what I would like to do. This attempts to interpolate data from a unit square to a subdomain rectangle that is 1 x 0.5.
from mpi4py import MPI
from dolfinx import mesh
from dolfinx.fem import FunctionSpace, Function
domain = mesh.create_unit_square(MPI.COMM_WORLD, 20, 20, mesh.CellType.quadrilateral)
subdomain = mesh.create_rectangle(MPI.COMM_WORLD, ((0., 0.), (1., 0.5)), (20, 10), mesh.CellType.quadrilateral)
V = FunctionSpace(domain, ("CG", 2))
W = FunctionSpace(subdomain, ("CG", 2))
uD = Function(V)
uSD = Function(W)
uSD.interpolate(uD)
Here is the error message I get with my new installation (everything runs fine on the older installation):
Traceback (most recent call last):
File "/tmp_user/sator/hmmak/fenicsx-scripts/3D/test5.py", line 14, in <module>
uSD.interpolate(uD)
File "/tmp_user/sator/hmmak/conda/envs/fx-real/lib/python3.11/site-packages/dolfinx/fem/function.py", line 370, in interpolate
_interpolate(u, cells)
File "/tmp_user/sator/hmmak/conda/envs/fx-real/lib/python3.11/functools.py", line 909, in wrapper
return dispatch(args[0].__class__)(*args, **kw)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/tmp_user/sator/hmmak/conda/envs/fx-real/lib/python3.11/site-packages/dolfinx/fem/function.py", line 351, in _
self._cpp_object.interpolate(u._cpp_object, cells, nmm_interpolation_data)
RuntimeError: In order to interpolate on nonmatching meshes, the user needs to provide the necessary interpolation data. This can be computed with fem::create_nonmatching_meshes_interpolation_data.