I have a XDMF file that contains three 3 different sets of data: the coordinates of the vertices of a mesh, the vertices of the elements of the mesh, and the labels of the elements (either 1 or 2). When I load the mesh using the following code:
mesh = Mesh()
with XDMFFile(“test.xdmf”) as infile:
infile.read(mesh)
I can view/use the vertices using mesh.coordinates( ) and the elements using mesh.cells( ) but I cannot find where the third set of data is contained. Is it possible to view/use the labels of the elements in the mesh?
These lines are in addition to what you are currently running, i.e.
mesh = Mesh()
with XDMFFile(“test.xdmf”) as infile:
infile.read(mesh)
mf_in = MeshFunction("size_t", mesh, mesh.topology().dim())
with XDMFFile(mesh.mpi_comm(), "test.xdmf") as xdmf:
xdmf.read(mf_in, "cells")
As they are read into a mesh function, they can be used in all the same ways as a mesh function defined using subdomains in python.
*** -------------------------------------------------------------------------
*** Error: Unable to open MeshFunction for reading.
*** Reason: Mesh Grid with data Attribute not found in XDMF.
*** Where: This error was encountered inside XDMFFile.cpp.
*** Process: 0
***
*** DOLFIN version: 2019.1.0
*** Git changeset:
*** -------------------------------------------------------------------------
You need to post your XDMFFile such that one can inspect the data structure of it for anyone to be able to help you.
Following: Bitbucket
you can see that the XDMF reader expects the cell data to be attached to XDMF/domain/grid/attribute