This is a read only copy of the old FEniCS QA forum. Please visit the new QA forum to ask questions

Gmsh to HDF5

+4 votes

Hello, I wrote a small python script in order to convert meshes from Gmsh to HDF5 (I modified a script pushed recently by Garth Wells on BitBucket). Is it still a missing feature? Is there any interest for it? And is there a preferred platform where one can post such files? (here, Launchpad, BitBucket, the mailing list .... I got lost).
Cheers,
Paolo

asked Jan 23, 2014 by nick.not.used FEniCS Novice (200 points)

2 Answers

+1 vote

By HDF5, you probably mean XDMF. (HDF5 is a general purpose data format, XDMF builds on top of it to provide info about functions, meshes and so forth.)

Part of the mesh I/O is a dark place in Dolfin's code, notably dolfin-convert which can handle the situation. I'd say use dolfin-convert to convert your mesh into Dolfin's native XML format, read that with a small script and write it out as XDMF. It should be something along the lines of

from dolfin import *
mesh = Mesh('my_mesh.xml')
mesh_file = XDMFFile(mesh.mpi_comm(), 'output.xdmf')
mesh_file << mesh

Ideally, of course, dolfin-convert should take care of all your needs; feel free to file a bug report about this.

answered Jan 23, 2014 by nschloe FEniCS User (7,120 points)

Thanks for the answer. I already used the method you mention for small meshes. The problem is that when dealing with large meshes I couldn't work with the xml data format any more. Garth Wells posted on BitBucket a fast and memory efficient script to convert xml meshes to hdf5/xdmf format https://www.mail-archive.com/fenics@fenicsproject.org/msg00791.html , and I extended it to the gmsh *msh data format. I tested it for large meshes as well. My question was: is it of any use for others, and if yes, how should I contribute?

Ah okay! Well, I guess I can say it'd be useful for me in that I wouldn't have to deal with the custom XML format anymore.
+1

0 votes

I pushed it to BitBucket on a separate repo
https://bitbucket.org/pcrosetto/dolfin-gmshtohdf5

answered Jan 24, 2014 by nick.not.used FEniCS Novice (200 points)

Thanks for making it available on Bitbucket. I'll take a look later and try to integrate it into the XML-to-XDMF converter.

...