This is a read only copy of the old FEniCS QA forum. Please visit the new QA forum to ask questions

Cannot read old-style MeshFunction XML files as a MeshValueCollection: Multiple Materials

+3 votes

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?

related to an answer for: Importing Marked Mesh for parallel use
asked Aug 11, 2016 by Nikita FEniCS Novice (410 points)
edited Aug 11, 2016 by Nikita

I am facing the same problem. I wish someone could shed some light on this.

I ran them separately. First output.py and then square.py

This works in serial and now when I run it in parallel, it does not give the xml error any more but a PETSc error code 76 which has some thing to do with KSPSolver. The error shows in solver.solve() statement.

I think it may have something to do with the fact that I am saving my output in pvd.

I am facing the same exact problem, except that in my case the program doesn't end up with an error; it simply stops at

Expression('some function', V)

any idea ?
regards

1 Answer

0 votes
 
Best answer

Run it in FEniCS latest version and run them separately. Check if the .h5 file is generated after running the output.py

answered Aug 18, 2016 by Chaitanya_Raj_Goyal FEniCS User (4,150 points)
selected Aug 18, 2016 by Nikita
...