Hello together,
I’ve got a short but for me cryptic error while trying to use create_nonmatching_meshes_interpolation_data function in DOLFINx version 0.7.3. I want to do interpolation of functions defined on different vector-spaces and meshes. I’ve search all related topics
-
runtime-error-when-interpolating-between-non-matching-meshes
-
interpolation-on-non-matching-meshes and had a look into the test files
I tried to validate the following test:
from dolfinx.mesh import create_unit_square, create_unit_cube, CellType
from dolfinx.fem import FunctionSpace, Function, create_nonmatching_meshes_interpolation_data
from basix.ufl import element
from mpi4py import MPI
import numpy as np
xtype = np.float64
cell_type0 = CellType.hexahedron
cell_type1 = CellType.triangle
mesh0 = create_unit_cube(MPI.COMM_WORLD, 5, 6, 7, cell_type=cell_type0, dtype=xtype)
mesh1 = create_unit_square(MPI.COMM_WORLD, 5, 4, cell_type=cell_type1, dtype=xtype)
def f(x):
return (7 * x[1], 3 * x[0], x[2] + 0.4)
el0 = element("Lagrange", mesh0.basix_cell(), 1, shape=(3, ))
V0 = FunctionSpace(mesh0, el0)
el1 = element("Lagrange", mesh1.basix_cell(), 1, shape=(3, ))
V1 = FunctionSpace(mesh1, el1)
# Interpolate on 3D mesh
u0 = Function(V0, dtype=xtype)
u0.interpolate(f)
u0.x.scatter_forward()
# Interpolate 3D->2D
u1 = Function(V1, dtype=xtype)
u1.interpolate(u0, nmm_interpolation_data=create_nonmatching_meshes_interpolation_data(
u1.function_space.mesh._cpp_object,
u1.function_space.element,
u0.function_space.mesh._cpp_object))
u1.x.scatter_forward()
But it gives me the error message:
Traceback (most recent call last):
File "~/02z_test_dolfinx.py", line 31, in <module>
u1.interpolate(u0, nmm_interpolation_data=create_nonmatching_meshes_interpolation_data(
TypeError: create_nonmatching_meshes_interpolation_data(): incompatible function arguments. The following argument types are supported:
1. (mesh0: dolfinx.cpp.mesh.Mesh_float32, element0: dolfinx.cpp.fem.FiniteElement_float32, mesh1: dolfinx.cpp.mesh.Mesh_float32, padding: float) -> Tuple[List[int], List[int], List[float], List[int]]
2. (geometry0: dolfinx.cpp.mesh.Geometry_float32, element0: dolfinx.cpp.fem.FiniteElement_float32, mesh1: dolfinx.cpp.mesh.Mesh_float32, cells: numpy.ndarray[numpy.int32], padding: float) -> Tuple[List[int], List[int], List[float], List[int]]
3. (mesh0: dolfinx.cpp.mesh.Mesh_float64, element0: dolfinx.cpp.fem.FiniteElement_float64, mesh1: dolfinx.cpp.mesh.Mesh_float64, padding: float) -> Tuple[List[int], List[int], List[float], List[int]]
4. (geometry0: dolfinx.cpp.mesh.Geometry_float64, element0: dolfinx.cpp.fem.FiniteElement_float64, mesh1: dolfinx.cpp.mesh.Mesh_float64, cells: numpy.ndarray[numpy.int32], padding: float) -> Tuple[List[int], List[int], List[float], List[int]]
Invoked with: <dolfinx.cpp.mesh.Mesh_float64 object at 0x7f8d60bee3e0>, <dolfinx.cpp.fem.FiniteElement_float64 object at 0x7f8d607a91b0>, <dolfinx.cpp.mesh.Mesh_float64 object at 0x7f8d604b8590>
The “Invoked with” line says that I’m in the Input-case 3, so why does this give me an error? Thanks for any help in advance,
Best