Hi I was able to use meshio to read in my files from Gmsh thanks to your instructions here. Currently, my code works fine using the following:
#!/usr/bin/env python3
from fenics import *
import numpy as np
import os
import time
import meshio
#Folder and Directory Names
output_folder_name = "./Kolachalama/"
os.system("rm "+output_folder_name+"*.xdmf")
os.system("rm "+output_folder_name+"*.h5")
output_vtk_folder = "Solution/"
output_vtk_filename = "Kola.pvd"
os.system("rm "+output_folder_name+output_vtk_folder+"*.vtu")
os.system("rm "+output_folder_name+output_vtk_folder+"*.pvd")
os.system("rm "+output_folder_name+output_vtk_folder+"*.pvtu")
vtkfile = File(output_folder_name+output_vtk_folder+output_vtk_filename)
#Define Mesh and Function Space
msh = meshio.read(output_folder_name+"Vessel.msh")
meshio.write(output_folder_name+"Kola.xdmf", meshio.Mesh(points=msh.points, cells{"tetra":msh.cells["tetra"]}))
meshio.write(output_folder_name+"mfKola.xdmf", meshio.Mesh(points=msh.points, cells={"triangle":msh.cells["triangle"]}, \
cell_data={"triangle":{"name_to_read":msh.cell_data["triangle"]["gmsh:physical"]}}))
meshio.write(output_folder_name+"cfKola.xdmf",meshio.Mesh(points=msh.points, cells={"tetra":msh.cells["tetra"]},\
cell_data={"tetra":{"name_to_read":msh.cell_data["tetra"]["gmsh:physical"]}}))
mesh = Mesh()
with XDMFFile(output_folder_name+"Kola.xdmf") as infile:
infile.read(mesh)
mvc = MeshValueCollection("size_t", mesh, 2) # Creates a container for mesh data - ie facet data
with XDMFFile(output_folder_name+"mfKola.xdmf") as infile:
infile.read(mvc, "name_to_read")
mf = cpp.mesh.MeshFunctionSizet(mesh,mvc)
boundaries = MeshFunction("size_t", mesh, mvc)
V = FunctionSpace(mesh, 'P', 1)
However, I run into problems when I try to run the code on parallel using:
mpirun -np 6 python3 Kolachalama.py
I get the following error:
Traceback (most recent call last):
File "Kolachalama.py", line 25, in <module>
meshio.write(output_folder_name+"Kola.xdmf", meshio.Mesh(points=msh.points, cells={"tetra":msh.cells["tetra"]}))
File "/home/karthic/.local/lib/python3.6/site-packages/meshio/_helpers.py", line 245, in write
return interface.write(filename, mesh, *args, **_kwargs)
File "/home/karthic/.local/lib/python3.6/site-packages/meshio/_xdmf/main.py", line 501, in write
XdmfWriter(*args, **kwargs)
File "/home/karthic/.local/lib/python3.6/site-packages/meshio/_xdmf/main.py", line 297, in __init__
self.h5_file = h5py.File(self.h5_filename, "w")
File "/home/karthic/.local/lib/python3.6/site-packages/h5py/_hl/files.py", line 394, in __init__
swmr=swmr)
File "/home/karthic/.local/lib/python3.6/site-packages/h5py/_hl/files.py", line 176, in make_fid
fid = h5f.create(name, h5f.ACC_TRUNC, fapl=fapl, fcpl=fcpl)
File "h5py/_objects.pyx", line 54, in h5py._objects.with_phil.wrapper
File "h5py/_objects.pyx", line 55, in h5py._objects.with_phil.wrapper
File "h5py/h5f.pyx", line 105, in h5py.h5f.create
OSError: Unable to create file (unable to flock file, errno = 11, error message = 'Resource temporarily unavailable')
Traceback (most recent call last):
File "Kolachalama.py", line 25, in <module>
meshio.write(output_folder_name+"Kola.xdmf", meshio.Mesh(points=msh.points, cells={"tetra":msh.cells["tetra"]}))
File "/home/karthic/.local/lib/python3.6/site-packages/meshio/_helpers.py", line 245, in write
return interface.write(filename, mesh, *args, **_kwargs)
File "/home/karthic/.local/lib/python3.6/site-packages/meshio/_xdmf/main.py", line 501, in write
XdmfWriter(*args, **kwargs)
File "/home/karthic/.local/lib/python3.6/site-packages/meshio/_xdmf/main.py", line 297, in __init__
self.h5_file = h5py.File(self.h5_filename, "w")
File "/home/karthic/.local/lib/python3.6/site-packages/h5py/_hl/files.py", line 394, in __init__
swmr=swmr)
File "/home/karthic/.local/lib/python3.6/site-packages/h5py/_hl/files.py", line 176, in make_fid
fid = h5f.create(name, h5f.ACC_TRUNC, fapl=fapl, fcpl=fcpl)
File "h5py/_objects.pyx", line 54, in h5py._objects.with_phil.wrapper
File "h5py/_objects.pyx", line 55, in h5py._objects.with_phil.wrapper
File "h5py/h5f.pyx", line 105, in h5py.h5f.create
OSError: Unable to create file (unable to flock file, errno = 11, error message = 'Resource temporarily unavailable')
I’m assuming the error has to do with each process attempting to write the same xdmf file? I’m not too sure how to resolve this. Any assistance would be greatly appreciated.