Thank you for the snippet @dokken ! I tried to extend it to my use case that involves a line mesh along x=1 (a 1D mesh in 2D geometry) on which to interpolate another vector-valued Function
object like so :
from setup import *
from dolfinx.mesh import create_mesh
from mpi4py.MPI import COMM_WORLD as comm
from dolfinx.fem import FunctionSpace, Function
cell = ufl.Cell("interval", geometric_dimension=2)
VE = ufl.VectorElement("Lagrange", cell, 2, 3)
domain = ufl.Mesh(VE)
n=3
x = np.vstack((np.ones(n),np.linspace(0,2,n))).T
L = np.arange(n, dtype=np.int32)
cells = np.vstack((L[:-1],L[1:])).T
mesh = create_mesh(comm, cells, x, domain)
u = Function(FunctionSpace(mesh, VE))
But I keep getting errors
Traceback (most recent call last):
File "/usr/local/dolfinx-real/lib/python3.10/dist-packages/dolfinx/mesh.py", line 179, in create_mesh
Traceback (most recent call last):
File "/usr/local/dolfinx-real/lib/python3.10/dist-packages/dolfinx/mesh.py", line 179, in create_mesh
mesh = _cpp.mesh.create_mesh(comm, cells, cmap, x, partitioner)
TypeError: create_mesh(): incompatible function arguments. The following argument types are supported:
1. (comm: MPICommWrapper, cells: dolfinx::graph::AdjacencyList<long>, element: dolfinx::fem::CoordinateElement, x: numpy.ndarray[numpy.float64], partitioner: Callable[[MPICommWrapper, int, int, dolfinx::graph::AdjacencyList<long>], dolfinx::graph::AdjacencyList<int>]) -> dolfinx::mesh::Mesh
Invoked with: <mpi4py.MPI.Intracomm object at 0x7f7d45d7fc30>, array([[0, 1],
[1, 2]], dtype=int32), <dolfinx.cpp.fem.CoordinateElement object at 0x7f7d3e9d5830>, array([[1., 0.],
[1., 1.],
[1., 2.]]), <built-in method of PyCapsule object at 0x7f7d2f8da3d0>
During handling of the above exception, another exception occurred:
mesh = _cpp.mesh.create_mesh(comm, cells, cmap, x, partitioner)
TypeError: create_mesh(): incompatible function arguments. The following argument types are supported:
1. (comm: MPICommWrapper, cells: dolfinx::graph::AdjacencyList<long>, element: dolfinx::fem::CoordinateElement, x: numpy.ndarray[numpy.float64], partitioner: Callable[[MPICommWrapper, int, int, dolfinx::graph::AdjacencyList<long>], dolfinx::graph::AdjacencyList<int>]) -> dolfinx::mesh::Mesh
Invoked with: <mpi4py.MPI.Intracomm object at 0x7f1e60d27c30>, array([[0, 1],
[1, 2]], dtype=int32), <dolfinx.cpp.fem.CoordinateElement object at 0x7f1e4a8644f0>, array([[1., 0.],
[1., 1.],
[1., 2.]]), <built-in method of PyCapsule object at 0x7f1e4a8823d0>
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "ex.py", line 19, in <module>
Traceback (most recent call last):
File "ex.py", line 19, in <module>
mesh = create_mesh(comm, cells, x, domain)
File "/usr/local/dolfinx-real/lib/python3.10/dist-packages/dolfinx/mesh.py", line 181, in create_mesh
mesh = create_mesh(comm, cells, x, domain)
File "/usr/local/dolfinx-real/lib/python3.10/dist-packages/dolfinx/mesh.py", line 181, in create_mesh
mesh = _cpp.mesh.create_mesh(comm, _cpp.graph.AdjacencyList_int64(np.cast['int64'](cells)),
RuntimeError: A facet is connected to more than two cells.
mesh = _cpp.mesh.create_mesh(comm, _cpp.graph.AdjacencyList_int64(np.cast['int64'](cells)),
RuntimeError: A facet is connected to more than two cells.