sfepy/sfepy — Issue #97: Troubles loading vtk mesh file
Author: rc
Created: 2012-01-30 10:26:05+00:00
State: open

I am trying to load a mesh written by gmesh (see attached) but it fails
because the first cell in the cells list is type 1, causing
vtk_dims[cell_types[0,0]]
raise a KeyError in meshio.py as
vtk_dims = {3 : 2, 9 : 2, 5 : 2, 3 : 3, 10 : 3, 12 : 3}
does not handle single point cells.
I don't know is these single point cells are a bug in gmesh or a feature
that sfepy does not care about.

Migrated from http://code.google.com/p/sfepy/issues/detail?id=95

earlier comments

robert.cimrman said, at 2009-08-13T14:53:37.000Z:

SfePy currently supports only triangles, quads, tetrahedrons and hexahedrons. What
are those single point cells used for? Would it be enough to modify the mesh reader
so that it ignores the unknown cell types?

robert.cimrman said, at 2009-08-13T15:07:23.000Z:

One more thing - your mesh is a 3D surface (nice!), but in 3D, sfepy needs a volume
mesh (e.g. of tetrahedrons).

Fabrice.Silva said, at 2009-08-13T15:08:42.000Z:

I don't know why Gmesh adds those singular cells in vtk file and not in the other
formats it supports (msh and medit for example).
Would it be difficult not to load them ?
Just an idea : in VTKMeshIO.read, when the 'while 1' loop ends, pop the lines of the
array that has undesirable value in the first column, count the dropped cells and
adjust n_el and n_val

Fabrice.Silva said, at 2009-08-13T15:12:08.000Z:

You are right about the 3D surface, but I have the same problem with a 3D volume mesh
(see cylindre.vtk). I attached in the original bugreport a lightweight vtk file
showing singular cells that the sfepy does not handle.

robert.cimrman said, at 2009-08-13T15:25:05.000Z:

I can now read the mesh, but there are also some line segment cells - the computation
will not work with that (no bar elements in sfepy), so we should probably ignore any
cells besides those with the highest dimension.

robert.cimrman said, at 2009-08-13T15:30:29.000Z:

Try the attached patch, please.

Fabrice.Silva said, at 2009-08-13T15:40:25.000Z:

With the patch, calling Mesh.from_file (in problemDef) does not raise the KeyError
anymore. Thanks!

robert.cimrman said, at 2009-08-13T15:59:43.000Z:

Good, here is a better patch. If all works, you can close the issue :)

Fabrice.Silva said, at 2009-08-13T16:48:07.000Z:

It seems to work too. At least it loads the mesh file without raising any error.

robert.cimrman said, at 2009-08-14T08:29:30.000Z:

Good, let's close this.