XDMFFile

class dolfin.cpp.io.XDMFFile(*args)

Bases: dolfin.cpp.common.Variable

Read and write Mesh , Function , MeshFunction and other objects in XDMF. This class supports the output of meshes and functions in XDMF (http://www.xdmf.org ) format. It creates an XML file that describes the data and points to a HDF5 file that stores the actual problem data. Output of data in parallel is supported. XDMF is not suitable for checkpointing as it may decimate some data.

Constructor.

Parameters:
  • comm (MPI_Comm) –
  • std::string filename (const) –
Encoding_ASCII = 1
Encoding_HDF5 = 0
close()

Close the file This closes any open HDF5 files. In ASCII mode the XML file is closed each time it is written to or read from, so close has no effect. From Python you can also use XDMFFile as a context manager:

with XDMFFile(mpi_comm_world(), 'name.xdmf') as xdmf:
    xdmf.write(mesh)

The file is automatically closed at the end of the with block

Return type:void
read()

Read MeshValueCollection from file, optionally specifying dataset name

Parameters:
  • double > & mvc (MeshValueCollection<) – (MeshValueCollection<double>) MeshValueCollection to restore
  • name (std::string) – (std::string) Name of data attribute in XDMF file
Return type:

void

thisown

The membership flag

write()

Save a cloud of points, with scalar values using an associated HDF5 file, or storing the data inline as XML.

Parameters:
  • std::vector< Point > & points (const) – (std::vector<Point>) A list of points to save.
  • std::vector< double > & values (const) – (std::vector<double>) A list of values at each point.
  • encoding (Encoding) – (Encoding) Encoding to use: HDF5 or ASCII
Return type:

void