I learnt how to convert a gmsh mesh to xml using dolfin-convert and how to run in parallel using mpirun. Thereafter, following an error, I came across this question. I am trying to run a simple problem in python in parallel and facing the same issue. From what I understand in the answer, I have to create 2 python files and run them together:
First file will convert the .xml to HDF5. So, I created the file output.py
from dolfin import *
mesh = Mesh("square.xml");
cd=MeshFunction('size_t',mesh,"square_physical_region.xml");
fd=MeshFunction('size_t',mesh,"square_facet_region.xml");
hdf = HDF5File(mesh.mpi_comm(), "file.h5", "w")
hdf.write(mesh, "/mesh")
hdf.write(cd, "/cd")
hdf.write(fd, "/fd")
Then I created my main file: Square.py, i.e., my full code
from dolfin import *
# Defining function space, functions, material parameters
# Importing the Mesh
mesh = Mesh()
hdf = HDF5File(mesh.mpi_comm(), "file.h5", "r")
hdf.read(mesh, "/mesh", False)
cd = CellFunction("size_t", mesh)
hdf.read(cd, "/cd")
fd = FacetFunction("size_t", mesh)
hdf.read(fd, "/fd")
# Writing the rest of algorithm and saving pvd file and plotting the result
RUN: mpirun -np 4 python output.py && mpirun -np 4 python square.py
However, I still get the same error "Cannot read old-style MeshFunction XML files as a MeshValueCollection." Can someone please send me some sample code or tell me what I am doing wrong?