XDMFFile.h

Note

The documentation on this page was automatically extracted from the DOLFIN C++ code and may need to be edited or expanded.

class XDMFFile

Parent class(es)

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.

enum class Encoding

File encoding type

XDMFFile(const std::string filename)

Constructor

XDMFFile(MPI_Comm comm, const std::string filename)

Constructor

void 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

void write(const Mesh &mesh, Encoding encoding = Encoding::HDF5)

Save a mesh to XDMF format, either using an associated HDF5 file, or storing the data inline as XML Create function on given function space

@param mesh (Mesh)
A mesh to save.
@param encoding (_Encoding_)
Encoding to use: HDF5 or ASCII
void write(const Function &u, Encoding encoding = Encoding::HDF5)

Save a Function to XDMF file for visualisation, using an associated HDF5 file, or storing the data inline as XML.

@param u (Function)
A function to save.
@param encoding (_Encoding_)
Encoding to use: HDF5 or ASCII
void write(const Function &u, double t, Encoding encoding = Encoding::HDF5)

Save a Function with timestamp to XDMF file for visualisation, using an associated HDF5 file, or storing the data inline as XML.

You can control the output with the following boolean parameters on the XDMFFile class:

  • rewrite_function_mesh (default true): Controls whether the mesh will be rewritten every timestep. If the mesh does not change this can be turned off to create smaller files.
  • functions_share_mesh (default false): Controls whether all functions on a single time step share the same mesh. If true the files created will be smaller and also behave better in Paraview, at least in version 5.3.0
@param u (Function)
A function to save.
@param t (_double_)
Timestep
@param encoding (_Encoding_)
Encoding to use: HDF5 or ASCII
void write(const MeshFunction<bool> &meshfunction, Encoding encoding = Encoding::HDF5)

Save MeshFunction to file using an associated HDF5 file, or storing the data inline as XML.

@param meshfunction (MeshFunction)
A meshfunction to save.
@param encoding (_Encoding_)
Encoding to use: HDF5 or ASCII
void write(const MeshFunction<int> &meshfunction, Encoding encoding = Encoding::HDF5)

Save MeshFunction to file using an associated HDF5 file, or storing the data inline as XML.

@param meshfunction (MeshFunction)
A meshfunction to save.
@param encoding (_Encoding_)
Encoding to use: HDF5 or ASCII
void write(const MeshFunction<std::size_t> &meshfunction, Encoding encoding = Encoding::HDF5)

Save MeshFunction to file using an associated HDF5 file, or storing the data inline as XML.

@param meshfunction (MeshFunction)
A meshfunction to save.
@param encoding (_Encoding_)
Encoding to use: HDF5 or ASCII
void write(const MeshFunction<double> &meshfunction, Encoding encoding = Encoding::HDF5)

Save MeshFunction to file using an associated HDF5 file, or storing the data inline as XML.

@param meshfunction (MeshFunction)
A meshfunction to save.
@param encoding (_Encoding_)
Encoding to use: HDF5 or ASCII
void write(const MeshValueCollection<bool> &mvc, Encoding encoding = Encoding::HDF5)

Write out mesh value collection (subset) using an associated HDF5 file, or storing the data inline as XML.

@param mvc (_MeshValueCollection<bool>_)
MeshValueCollection to save
@param encoding (_Encoding_)
Encoding to use: HDF5 or ASCII
void write(const MeshValueCollection<int> &mvc, Encoding encoding = Encoding::HDF5)

Write out mesh value collection (subset) using an associated HDF5 file, or storing the data inline as XML.

@param mvc (_MeshValueCollection<int>_)
MeshValueCollection to save
@param encoding (_Encoding_)
Encoding to use: HDF5 or ASCII
void write(const MeshValueCollection<std::size_t> &mvc, Encoding encoding = Encoding::HDF5)

Write out mesh value collection (subset) using an associated HDF5 file, or storing the data inline as XML.

@param mvc (_MeshValueCollection<int>_)
MeshValueCollection to save
@param encoding (_Encoding_)
Encoding to use: HDF5 or ASCII
void write(const MeshValueCollection<double> &mvc, Encoding encoding = Encoding::HDF5)

Write out mesh value collection (subset) using an associated HDF5 file, or storing the data inline as XML.

@param mvc (_MeshValueCollection<double>_)
MeshValueCollection to save
@param encoding (_Encoding_)
Encoding to use: HDF5 or ASCII
void write(const std::vector<Point> &points, Encoding encoding = Encoding::HDF5)

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

@param points (_std::vector<Point>_)
A list of points to save.
@param encoding (_Encoding_)
Encoding to use: HDF5 or ASCII
void write(const std::vector<Point> &points, const std::vector<double> &values, Encoding encoding = Encoding::HDF5)

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

@param points (_std::vector<Point>_)
A list of points to save.
@param values (_std::vector<double>_)
A list of values at each point.
@param encoding (_Encoding_)
Encoding to use: HDF5 or ASCII
void read(Mesh &mesh) const

Read in the first Mesh in XDMF file

@param mesh (Mesh)
Mesh to fill from XDMF file
void read(MeshFunction<bool> &meshfunction, std::string name = "")

Read first MeshFunction from file @param meshfunction (_MeshFunction<bool>_)

MeshFunction to restore
@param name (std::string)
Name of data attribute in XDMF file
void read(MeshFunction<int> &meshfunction, std::string name = "")

Read first MeshFunction from file @param meshfunction (_MeshFunction<int>_)

MeshFunction to restore
@param name (std::string)
Name of data attribute in XDMF file
void read(MeshFunction<std::size_t> &meshfunction, std::string name = "")

Read MeshFunction from file, optionally specifying dataset name @param meshfunction (_MeshFunction<std::size_t>_)

MeshFunction to restore
@param name (std::string)
Name of data attribute in XDMF file
void read(MeshFunction<double> &meshfunction, std::string name = "")

Read MeshFunction from file, optionally specifying dataset name @param meshfunction (_MeshFunction<double>_)

MeshFunction to restore
@param name (std::string)
Name of data attribute in XDMF file
void read(MeshValueCollection<bool> &mvc, std::string name = "")

Read MeshValueCollection from file, optionally specifying dataset name @param mvc (_MeshValueCollection<bool>_)

MeshValueCollection to restore
@param name (std::string)
Name of data attribute in XDMF file
void read(MeshValueCollection<int> &mvc, std::string name = "")

Read MeshValueCollection from file, optionally specifying dataset name @param mvc (_MeshValueCollection<int>_)

MeshValueCollection to restore
@param name (std::string)
Name of data attribute in XDMF file
void read(MeshValueCollection<std::size_t> &mvc, std::string name = "")

Read MeshValueCollection from file, optionally specifying dataset name @param mvc (_MeshValueCollection<std::size_t>_)

MeshValueCollection to restore
@param name (std::string)
Name of data attribute in XDMF file
void read(MeshValueCollection<double> &mvc, std::string name = "")

Read MeshValueCollection from file, optionally specifying dataset name @param mvc (_MeshValueCollection<double>_)

MeshValueCollection to restore
@param name (std::string)
Name of data attribute in XDMF file