Dimension changes when reading in a 1D mesh from xdmf
Issue #892
new
When reading in a 1D mesh that has been saved to an xdmf file, the geometry dimension changes from 1 to 2. I think this is a result of XDMF not being able to represent a 1D geometry so assigns zeros to the y-coordinate.
Attached is code that reproduces the bug.
from dolfin import *
mesh = UnitIntervalMesh(10);
print "Before reading in: " + str(mesh.geometry().dim())
f = XDMFFile("mesh.xdmf")
f.write(mesh)
new_mesh = Mesh()
f.read(new_mesh)
print "After reading in: " + str(new_mesh.geometry().dim())
I propose editing mesh.geometry().dim()
to check if each y coordinate (or z coordinate) is smaller than DOLFIN_EPS
and then assign the dimension accordingly.
Comments (6)
-
-
Yes, that is a bad solution, because
mesh.geometry().dim()
should not care about some XDMF defect. It could be easily fixed inXDMFFile::read(Mesh)
. -
reporter Ok - that sounds like a better solution.
-
reporter - removed responsible
-
-
assigned issue to
Ettie, can you provide a MWE?
-
assigned issue to
-
Sorry, i didn't notice of it above.
- Log in to comment
That sounds like a horrible hack to me.