dolfinx
dolfinx copied to clipboard
Manifold meshes from XDMF broken
Broken by PR #2301 Reported at: https://fenicsproject.discourse.group/t/triangle-elements-in-3d-broken-in-dolfinx/9426 MWE: XDMFFile:
<Xdmf Version="3.0">
<Domain>
<Grid Name="Grid">
<Geometry GeometryType="XYZ">
<DataItem DataType="Float" Dimensions="3 2" Format="XML" Precision="8">
0.0 0.0 0.0
1.0 0.0 0.0
0.0 1.0 0.0
</DataItem>
</Geometry>
<Topology NodesPerElement="3" NumberOfElements="1" TopologyType="triangle">
<DataItem DataType="Int" Dimensions="1 3" Format="XML" Precision="4">
0 1 2
</DataItem>
</Topology>
</Grid>
</Domain>
</Xdmf>
and code
#!/usr/bin/env python3
from mpi4py import MPI
from dolfinx import fem, io
import ufl
comm = MPI.COMM_WORLD
meshname = 'mesh.xdmf'
with io.XDMFFile(comm, meshname, 'r', encoding=io.XDMFFile.Encoding.ASCII) as infile:
mesh = infile.read_mesh(name="Grid")
V_s = fem.FunctionSpace(mesh, ("P", 1))
V_v = fem.VectorFunctionSpace(mesh, ("P", 1))
V_t = fem.TensorFunctionSpace(mesh, ("P", 1))
print(mesh.geometry.dim, mesh.topology.dim)
yields error:
Non-matching cell of finite element and domain.
ERROR:UFL:Non-matching cell of finite element and domain.
Traceback (most recent call last):
File "/root/shared/debug/mwe_gmsh.py", line 15, in <module>
V_v = fem.VectorFunctionSpace(mesh, ("P", 1))
File "/root/shared/dolfinx/python/dolfinx/fem/function.py", line 578, in VectorFunctionSpace
return FunctionSpace(mesh, ufl_element)
File "/root/shared/dolfinx/python/dolfinx/fem/function.py", line 452, in __init__
super().__init__(mesh.ufl_domain(), element)
File "/root/shared/ufl/ufl/functionspace.py", line 45, in __init__
error("Non-matching cell of finite element and domain.")
File "/root/shared/ufl/ufl/log.py", line 158, in error
raise self._exception_type(self._format_raw(*message))
ufl.log.UFLException: Non-matching cell of finite element and domain.
I suspect this issue might be fixed by https://github.com/FEniCS/dolfinx/pull/2386
This is not fixed yet. There are issues with the sub-spaces, i.e.
V.sub(i) does not work.
Is the issue related to this by any chance? i.e. does specifying dim=mesh.geometry.dim when creating the vector function space fix the problem?
Is the issue related to this by any chance? i.e. does specifying
dim=mesh.geometry.dimwhen creating the vector function space fix the problem?
I've opened a PR in Basix to fix that and maybe fix this
@mscroggs is this resolved?
@mscroggs, @jorgensd is this fixed now?
No, this is still not resolved.
You get the issue by adding V_v.sub(i) i being 0, 1 or 2 to the example above. You then get
issues when creating the sub function space, as the sub elements are using the wrong cell type
Is there a sensible test we can add to DOLFINx that will check that we don't break this in future?
This may have been fixed by https://github.com/FEniCS/basix/pull/617
Is there a sensible test we can add to DOLFINx that will check that we don't break this in future?
Good question, maybe we need to solve a PDE on a manifold, or do something similar to what we do above. I guess we could use locate_dofs_topological on a subspace to compare it to what one gets on the collapsed sub space.