Importing Materials/Domains/Subdomains

Asked by Niklas

I would like to import a geometry with different volumes of different materials. I created the CAD-Modell in Autodesk Inventor Fusion and exported as STEP (STL alternatively). I then meshed the STEP in NETGEN under Ubuntu and exported as Diffpack mesh. This I converted with dolfin-convert to dolfin-XML.

With this combination I get a main XML of the structure:

<dolfin xmlns:dolfin="">
   <mesh celltype="tetrahedron" dim="3">
      <vertices size="978">
      <cells size="2938">
        <mesh_value_collection name="m" type="uint" dim="2" size="503">
        <mesh_value_collection name="m" type="uint" dim="3" size="2938">

Also I get 9 files of naming ..._marker_1 which seem to host boundaries. Their structure is:

  <mesh_function type="uint" dim="0" size="978">
    <entity index="0" value="1"/>

I would like to import the mesh and access the two subdomains. I understand that mesh_value_collection is a class similar to mesh_function. I tried to create an instance of a mesh_value_collection from file by

mesh = Mesh('test11.xml')
ValueCollection1 = MeshValueCollection('int',mesh,'test11.xml',3)

But it cannot read the MeshValueCollection tag that way.

What is the most intelligent way to import subdomains from a mesh? Is there a better way of pre-processing? If MeshValueCollection is the way to go: Is it appropriate for differentiating subdomains and saving material properties? Or should it be used to create a Mesh_Function later on?

Grateful for all kinds of help...

Question information

English Edit question
FEniCS Project Edit question
No assignee Edit question
Solved by:
Last query:
Last reply:
Revision history for this message
Niklas (ntschech) said :

I fixed it:

The problem actually lied in the pre-processing or in the dolfin-convert script. The second ValueCollection

<mesh_value_collection name="m" type="uint" dim="3" size="2938">

will contain the cells-subdomain mapping. If you copy it in a <MeshFunction> node directly below the <dolfin> node, it can be read in by a MeshFunction Constructor.

Maybe the dolfin-convert script can take account for this, but with the data manipulation as a in-between-step it seems to work.

Better solutions are, of course, always welcome, as well...

Revision history for this message
Johan Hake (johan-hake) said :

Not sure what you are doing but are you copying stuff between generated xml files? That is not necessary to get the MeshFunction of the cell domains. For that you just:

  mesh = Mesh('test11.xml')
  domains =


Revision history for this message
Niklas (ntschech) said :

Thanks Johan,

Thats much better...^^