Hello all,
I am a little stuck with the following code and I haven’t found any useful examples.
I made a 2D Gmsh mesh with some physical groups.
I used the following code to retrieve the facets and the mesh itself:
Wri_path = "./Gmsh_meshes/"
msh = meshio.read(Wri_path+'SinglePBR.msh')
meshio.write(Wri_path+"md_.xdmf",
meshio.Mesh(points=msh.points,
cells={"triangle": msh.cells["triangle"]}))
meshio.write(Wri_path+"mf_.xdmf",
meshio.Mesh(points=msh.points,
cells={"line": msh.cells["line"]},
cell_data={"line": {"name_to_read": msh.cell_data["line"]["gmsh:physical"]}}))
# Reading mesh data stored in .xdmf files.
mesh = Mesh()
with XDMFFile(Wri_path+"md_.xdmf") as infile:
infile.read(mesh)
mvc = MeshValueCollection("size_t", mesh, 1)
with XDMFFile(Wri_path+"mf_.xdmf") as infile:
infile.read(mvc, "name_to_read")
mf = cpp.mesh.MeshFunctionSizet(mesh, mvc)
However, the following lines make it fails:
# Define function spaces for PDEs variational formulation.
P1 = FiniteElement('P', triangle, 1) # Lagrange 1-order polynomials family
element = MixedElement([P1, P1, P1, P1])
V = FunctionSpace(mesh, element) # Test functions
function_space = FunctionSpace(mesh, P1)
It seems to be that it works just fine when there is only one finite element function, but I haven’t been able to make it runs when there are multiple PDEs. I always obtain the following error message:
File “Reading_Gmsh.py”, line 76, in
V = FunctionSpace(mesh, element)
File “/usr/lib/python3/dist-packages/dolfin/function/functionspace.py”, line 31, in init
self._init_from_ufl(*args, **kwargs)
File “/usr/lib/python3/dist-packages/dolfin/function/functionspace.py”, line 39, in _init_from_ufl
ufl.FunctionSpace.init(self, mesh.ufl_domain(), element)
File “/usr/lib/python3/dist-packages/ufl/functionspace.py”, line 58, in init
error(“Non-matching cell of finite element and domain.”)
File “/usr/lib/python3/dist-packages/ufl/log.py”, line 172, in error
raise self._exception_type(self._format_raw(*message))
ufl.log.UFLException: Non-matching cell of finite element and domain.
I really appreciate your help on this issue or any feedback.
Regards,
Santiago