dolfinx icon indicating copy to clipboard operation
dolfinx copied to clipboard

Manifold meshes from XDMF broken

Open jorgensd opened this issue 3 years ago • 11 comments

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.

jorgensd avatar Oct 03 '22 08:10 jorgensd

I suspect this issue might be fixed by https://github.com/FEniCS/dolfinx/pull/2386

jpdean avatar Oct 03 '22 08:10 jpdean

This is not fixed yet. There are issues with the sub-spaces, i.e. V.sub(i) does not work.

jorgensd avatar Oct 04 '22 09:10 jorgensd

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?

jpdean avatar Oct 04 '22 10:10 jpdean

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?

I've opened a PR in Basix to fix that and maybe fix this

mscroggs avatar Oct 04 '22 10:10 mscroggs

@mscroggs is this resolved?

jorgensd avatar Oct 14 '22 08:10 jorgensd

@mscroggs, @jorgensd is this fixed now?

garth-wells avatar Nov 09 '22 13:11 garth-wells

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

jorgensd avatar Nov 09 '22 14:11 jorgensd

Is there a sensible test we can add to DOLFINx that will check that we don't break this in future?

mscroggs avatar Nov 10 '22 08:11 mscroggs

This may have been fixed by https://github.com/FEniCS/basix/pull/617

mscroggs avatar Nov 10 '22 09:11 mscroggs

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.

jorgensd avatar Nov 10 '22 20:11 jorgensd

This may have been fixed by FEniCS/basix#617

Is this issue now fixed?

garth-wells avatar Apr 21 '24 16:04 garth-wells