Dimension changes when reading in a 1D mesh from xdmf

Issue #892 new
Ettie Unwin created an issue

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)

  1. Miklós Homolya

    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.

    That sounds like a horrible hack to me.

  2. Michal Habera

    Yes, that is a bad solution, because mesh.geometry().dim() should not care about some XDMF defect. It could be easily fixed in XDMFFile::read(Mesh).

  3. Log in to comment