Problem with mesh

I created a brain mesh with Tetgen and I have obtained a file .mesh.
In order to use it with Fenics I used dolfin-converter but it creates me problems since the previous mesh was high quality but using dolfin_converter it gets worse.
The error that Fenics gave me is the following:

*** Error: Unable to compute tetrahedron point collision.
*** Reason: Not implemented for degenerate tetrahedron.
*** Where: This error was encountered inside CollisionPredicates.cpp.
*** Process: 0


*** DOLFIN version: 2019.1.0
*** Git changeset: 68992f956799dc3f153b3d59b8f60cf1a72b9b9e

Any suggestion?

When you say dolfin converter, what do you mean? The dolfin-convert script? This script has not been maintained, and it is suggested to use meshio, as described here: Transitioning from mesh.xml to mesh.xdmf, from dolfin-convert to meshio - #174 by dokken

Yes I mean the dolfin-convert script. Thank you for the suggestion, I will try to use meshio.

I managed to convert it using meshio from a file .mesh to a file .xml.
I have only one question: is it possible to keep the labels (an integer) that every tetheadron has in the file .mesh also in the output file?
In order to convert it I use the command: meshio-convert input.mesh output.xml
Could I set an option in order to include those label?

I do not know how to do it using the meshio-convert script, as I use the meshio Python API. In the script I’ve linked to, it saves the cell data (loaded as a dictionary with key "gmsh:physical")

1 Like

Perfect, I used your script and I saw the dictionary. But if I load the output.xml in another script fenics as mesh, how can I access to that dictionary?
I mean, if I load it as:
mesh= Mesh(“output.xml”)
and then I want to create a MeshFunction using the information in that dictionary, how can I do?

See: Bitbucket

1 Like

I cannot understand. In my script I want to create a MeshFunction with the integer values that I have for each tetraedra and they are saved in this way:
{‘name_to_read’: {‘tetra’: array([2, 2, 2, …, 2, 2, 2])}}
(using the command print(tetra_mesh.cell_data_dict) in the conversion file)

So I think to proceed in this way:

mf = MeshFunction(“int”, mesh, mesh.topology().dim())
mf.array()[:] = some_array

and some_array should be the previous array, but I definitely do not know how to do.

As you have still not supplied me with a mesh, I cannot do much to help you.
What I am linking you to in the previous post is that the xml file most likely contains the domain markers, and you can extract them from it.

If you want to make something that works in parallel, you need to do the following:

  1. Use the meshio python interface to convert your mesh from your .mesh format to XDMF, as described in: Transitioning from mesh.xml to mesh.xdmf, from dolfin-convert to meshio - #174 by dokken, where the cell_data variable is replaced with the array you are describing (one integer per cell).
  2. Read in meshvalue collections and place then in a MeshFunction, as described in: Need help converting GMSH to FEniCS - #17 by dokken

Thank you so much! Exactly what I needed!