Hi everyone,
Currently I have a Fenics script that imports a mesh, determines the appropriate cells and facets then uses the .xml file of the facets region to determine the surface indices of the facets that lie on a given surface. Currently, it looks like this:
from __future__ import print_function
from dolfin import *
import ufl
from mpi4py import MPI
#---------------------------------------
data = 'crucible'
mesh = Mesh()
hdf = HDF5File(mesh.mpi_comm(), data+'.h5', 'r')
hdf.read(mesh, '/mesh', False)
cells_f = MeshFunction('size_t', mesh, 3)
hdf.read(cells_f, '/cells')
facets_f = MeshFunction('size_t', mesh, 2)
hdf.read(facets_f, '/facets')
boundaries = MeshFunction('size_t', mesh, 'crucible_facet_region.xml')
#-----------------------------------------------
# Mark the tags for 'top' and 'surface' groups
#-----------------------------------------------
tag_s = 2 #Tags for 'surface' group in .msh file
tag_t = 3
surfacefacetindices = np.where(boundaries.array() == tag_s)[0]
surfacefacetindices_2 = np.where(boundaries.array() == tag_t)[0]
surfacefacetindices_total = np.append(surfacefacetindices,surfacefacetindices_2)
surfacefacets = np.array(list(facets(mesh)))[surfacefacetindices_total]
print(surfacefacets)
However if I try running this code using mpirun
, like so:
mpirun -n 20 python3 test_boundaries.py
I get the following error:
File "test_boundaries.py", line 14, in <module>
boundaries = MeshFunction('size_t', mesh, 'crucible_facet_region.xml')
File "/usr/local/fkf/Fenics_openmpi2/Python3/lib64/python3.6/site-packages/dolfin/mesh/meshfunction.py", line 18, in __new__
return fn(mesh, dim)
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
***
*** Remember to include the error message listed below and, if possible,
*** include a *minimal* running example to reproduce the error.
***
*** -------------------------------------------------------------------------
*** Error: Unable to read mesh function from XML file.
*** Reason: Cannot read old-style MeshFunction XML files as a MeshValueCollection.
*** Where: This error was encountered inside XMLMeshFunction.h.
*** Process: 0
***
*** DOLFIN version: 2019.2.0.dev0
*** Git changeset: b55804ecca7d010ff976967af869571b56364975
*** -------------------------------------------------------------------------
Does anyone know how I can fix this. This code runs fine without the mpirun
The required files can be found here: Crucible - Google Drive