evalf/nutils

Issues faced while importing msh file

Opened this issue · 7 comments

Hello,

we are using Nutils to simulate a phase field fracture problem. The code has been working so far as expected on a simple geometry generated using the mesh.rectilinear() function. But now we want to test the code on a multi grain geometry generated using the Neper library. We generated the geometry file in .msh format, but we are running into some errors while importing it. When using the mesh.gmsh() function, we get the error KeyError: 'gmsh:bounding_entities' and error statement looks like:

$ python3 fracture.py 
opened log at file:///home/aravinth/public_html/fracture.py/log-40.html
nutils v6.2 "garak-guksu"
start Mon May 31 08:58:39 2021
KeyError: 'gmsh:bounding_entities'
log written to file:///home/aravinth/public_html/fracture.py/log-40.html

We could not find any documentation on this error. Any guidance on this issue would be helpful. I have attached the mesh file and the block of the source code to recreate the issue. We are running Nutils 6.2.

We also want to evaluate integrals on grain boundaries, which can be considered as curves/lines inside the domain. These grain boundaries are denoted as edges in the .msh file. How would one do this in Nutils? Would a command like topology.boundary['edge1'].integral() work, if the name of the edge is 'edge1' in the .msh file?

Nutils code
Mesh

Attaching the msh file here because the links went stale; calling mesh.gmsh('n2-id1.msh') produces the error. Before failing in mesh.parsegmsh we get a warning from meshio ("The file contains tag data that couldn't be processed") which might indicate that the msh file is non-compliant, but from looking at it it's not immediately clear why.

I saw a comment on the Element forum from you saying that you do not provide any examples with Gmsh meshes. But that comment is from 3 years ago. Do you maybe have Gmsh msh file that is working with some Nutils code? If you have one, I can compare my msh file against it and maybe find a solution.

There are msh files of various dimensions, polynomial degrees, and format versions in tests/test_mesh, along with the geo files they are generated from. The v2 ones look very similar to yours so whatever is going on must be subtle.

If you or anybody would like to dig into this: the format is formally described here.

Thank you very much. I will have a look and update any progress.

So I solved the issue yesterday. Here are my conclusions:

  1. When importing a msh file, every Entity needs to be assigned to a Physical Group. The library with which I generated the mesh did not assign every Entity to a Physical Group, which lead to an error.
  2. When importing a msh file with gmsh version 4.1, a physical group named gmsh:bounding_entities is automatically generated. I added a line in the nutils.mesh.py file to delete the element in the msh.cell_sets dict object. The line msh.cell_sets.pop('gmsh:bounding_entities') was added before line 399. I am using Nutils version 6.2. But looking at a comment on the Element forum, it seems like you already fixed this problem.

Thanks for investigating this!
Regarding your first conclusion, did you manage to establish whether entities that are not assigned to a physical group are indeed violating the spec (and can you point that out) or is the problem with meshio for not loading this correctly?
The second point I don't fully understand - gmsh:bounding_entities does not ring a bell and I'm not sure what forum comment you are referring to. Could you elaborate a bit?

  1. I got an error message from meshio saying the number of entities do not match with the number of physical groups. But I have not been able to replicate this error. So I am not sure about it, I will post here if I find anything new regarding this.
  2. I am referring to this comment . I can show you the fixed code, if you need it. But it is basically what I said in my previous comment.