Hi,
It’s been several days that i am stuck on this problem : “Reason: Error reading MeshValueCollection.”
Please do you know how to fix it ?
Context: i have just imported my .geo file on fenics (google colabs), then i used this program :
!add-apt-repository -y ppa:fenics-packages/fenics
!apt-get update -qq
!apt-get install -y -qq software-properties-common python3-software-properties module-init-tools
!apt install -y -qq --no-install-recommends fenics
!pip3 install --upgrade pip
!pip3 install -U --no-binary=h5py h5py meshio
from dolfin import *
!apt-get install gmsh
!gmsh --version
!gmsh -2 wear.geo -o wear.msh
!pip install -U meshio
!apt-get install python-lxml
import meshio
in_mesh = meshio.read("wear.msh")
import numpy
def create_mesh(mesh, cell_type, prune_z=False):
cells = numpy.vstack([cell.data for cell in mesh.cells if cell.type==cell_type])
cell_data = numpy.hstack([mesh.cell_data_dict["gmsh:physical"][key]
for key in mesh.cell_data_dict["gmsh:physical"].keys() if key==cell_type])
# Remove z-coordinates from mesh if we have a 2D cell and all points have the same third coordinate
points= mesh.points
if prune_z:
points = points[:,:2]
mesh_new = meshio.Mesh(points=points, cells={cell_type: cells}, cell_data={"name_to_read":[cell_data]})
return mesh_new
line_mesh = create_mesh(in_mesh, "line", prune_z=True)
meshio.write("facet_mesh.xdmf", line_mesh)
triangle_mesh = create_mesh(in_mesh, "triangle", prune_z=True)
meshio.write("mesh.xdmf", triangle_mesh)
mesh = Mesh()
with XDMFFile("mesh.xdmf") as infile:
infile.read(mesh)
mvc = MeshValueCollection("size_t", mesh, 1)
with XDMFFile("facet_mesh.xdmf") as infile:
infile.read(mvc, "name_to_read")
mf = cpp.mesh.MeshFunctionSizet(mesh, mvc)
and this is the error message :
---------------------------------------------------------------------------
RuntimeError Traceback (most recent call last)
[<ipython-input-10-1c9f148725b4>](https://localhost:8080/#) in <module>() 4 mvc = MeshValueCollection("size_t", mesh, 35) 5 with XDMFFile("facet_mesh.xdmf") as infile: ----> 6 infile.read(mvc, "name_to_read") 7 mf = cpp.mesh.MeshFunctionSizet(mesh, mvc)
RuntimeError: *** ------------------------------------------------------------------------- *** DOLFIN encountered an error. If you are not able to resolve this issue *** using the information listed below, you can ask for help at *** *** [fenics-support@googlegroups.com](mailto:fenics-support@googlegroups.com) *** *** Remember to include the error message listed below and, if possible, *** include a *minimal* running example to reproduce the 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.2.0.dev0 *** Git changeset: unknown *** -------------------------------------------------------------------------
SEARCH STACK OVERFLOW