Which is the preferred way to import into a FEniCS (python) program a mesh which was generated in an external generator which provides sub-domain and boundary markers? I was using MeshData->MeshFunctions for that purpose, but switching to parallel mpi program I've found that those MeshFunctions are not transferred to partial meshes used by mpi processes. MeshFunctions seem to be no longer supported - what is the alternative?

Using geometry information to recover sub-domains is extremely inconvenient for me.

I'm using my own (diffpack)grid to xml converter which is currently creating two MeshFunctions with subdomain and boundary information. Reading such xml Mesh file from a single-process code I'am able to get and use those MeshFunctions. However, when reading the same mesh from mpi code it is divided into sub-meshes and MeshFunctions are lost at this stage. My question is if may I create an xml mesh file with data which will not get lost during mesh sub-division.


2 Answers 2


The questions depends on what program you have used to generate the external meshes. Dolfin provides the script dolfin-convert, which convert external meshes to dolfin meshes. Depending on what format you convert from you get different representations of the boundary condition within the mesh, because not all formats have been updated to the latest storage formats. As you point out MeshFunctions stored in Mesh.data is no longer the preferred storage format.

If you are able to save your mesh in diffpack (.grid) format, I know that pipeline should be pretty updated. You should then be able to access the domains through:


however this syntax has changed in the development version, where you need to explicitly create the MeshFunction:

dim = mesh.topology().dim()
facet_domains = MeshFunction("size_t", mesh, dim-1, mesh.domains())
cell_domains = MeshFunction("size_t", mesh, dim, mesh.domains())

Note that mesh entities which has no marker will get the maximal number of the data type.


I've found that the MeshFunctions need to be stored in separate files, but now I'm getting "Reading old-style XML MeshFunctions is not supported in parallel. Consider using the new format" - will search for the specification of this new format. Programming FEniCS is definitively exciting, but some stability of the code would probably be nice ;-)

  • $\begingroup$ You should not be surprised that code changes when using development version. To your problem, there are two solutions: 1. load old-style XML serially and output it - you get new-style XML which can be used in parallel now; 2. tweak meshconvert.py to comply with new-style XML - it is pretty straightforward code. $\endgroup$ Commented Jun 6, 2013 at 13:56
  • $\begingroup$ My FEniCS was installed from an Ubuntu package. I was expecting more stability. $\endgroup$
    – Jacek
    Commented Jun 6, 2013 at 14:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.