Hi everyone,
I’m trying to read in a slightly complex geometry from the following GMSH file, in which i declared only small parts of it as boundary, the rest is my interior:
$MeshFormat
2.2 0 8
$EndMeshFormat
$PhysicalNames
3
2 2 "Neumann"
2 3 "Robin"
3 1 "Volume"
$EndPhysicalNames
$Nodes
2191
1 1.45935 0.948814 -0.69911
2 1.44345 0.948814 -0.69911
3 1.29746 0.23 -0.63
4 1.34746 0.23 -0.68
...
2190 3.34704 0.23 0.712405
2191 3.36103 0.23 0.742412
$EndNodes
$Elements
7503
1 2 2 3 3 55 60 62
2 2 2 3 3 55 63 60
3 2 2 3 3 63 53 59
4 2 2 3 3 63 59 60
5 2 2 3 3 3 5 55
6 2 2 3 3 5 63 55
7 2 2 3 3 5 6 53
8 2 2 3 3 5 53 63
9 2 2 3 3 75 78 169
10 2 2 3 3 78 234 469
11 2 2 3 3 78 74 77
12 2 2 3 3 77 234 78
13 2 2 3 3 234 77 170
14 2 2 3 3 77 73 170
15 2 2 3 3 169 234 170
16 2 2 3 3 169 170 172
17 2 2 2 2 1620 1621 1622
18 2 2 2 2 1621 1876 1622
19 2 2 2 2 1725 1876 1621
20 4 2 1 1 10 23 1 11
21 4 2 1 1 23 1 11 35
22 4 2 1 1 35 23 1 2
23 4 2 1 1 35 37 23 2
...
7501 4 2 1 1 2185 2188 2190 2189
7502 4 2 1 1 2187 2185 2190 2186
7503 4 2 1 1 2188 2191 2190 2189
$EndElements
with the following python code
import dolfin as df
pathname = './CarInteriorMesh/'
filename = 'Mesh' # file to be opened
msh = meshio.read(pathname + filename + '.msh')
meshio.write(pathname + filename + '_xdmf.xdmf',
meshio.Mesh(points=msh.points,
cells={'tetra': msh.cells['tetra']},
cell_data={
'tetra': {'name_to_read': msh.cell_data['tetra']['gmsh:physical']}}))
meshio.write(pathname + filename + '_Boundary_xdmf.xdmf',
meshio.Mesh(points=msh.points,
cells={'triangle': msh.cells['triangle']},
cell_data={
'triangle': {'name_to_read': msh.cell_data['triangle']['gmsh:physical']}}))
mesh = df.Mesh()
with df.XDMFFile(pathname + filename + '_xdmf.xdmf') as infile:
infile.read(mesh)
mvc = df.MeshValueCollection('size_t', mesh, 3)
with df.XDMFFile(pathname + filename + '_Boundary_xdmf.xdmf') as infile:
infile.read(mvc, 'name_to_read')
mf = df.cpp.mesh.MeshFunctionSizet(mesh, mvc)
with df.XDMFFile(pathname + filename + '_xdmf.xdmf') as infile:
infile.read(mvc, 'name_to_read')
cf = df.cpp.mesh.MeshFunctionSizet(mesh, mvc)
ds_excited = df.Measure('ds', domain=mesh, subdomain_data=mf, subdomain_id=2)
ds_admittance = df.Measure('ds', domain=mesh, subdomain_data=mf, subdomain_id=3)
dx_volume = df.Measure('dx', domain=mesh, subdomain_data=cf, subdomain_id=1)
Edit: The error occurs in
infile.read(mvc, 'name_to_read')
and i get the following error:
*** Error: Unable to find entity in map.
*** Reason: Error reading MeshValueCollection.
*** Where: This error was encountered inside HDF5File.cpp.
*** Process: 0
***
*** DOLFIN version: 2019.1.0
I just don’t understand why FEniCS/Dolfin is not able to find an entity, i have declared everything i need in my gmsh-file.
I am able to read other GMSH-generated meshes without problems but this one won’t work.
Thanks in advance, any help is highly appreciated!