Note
The documentation on this page was automatically extracted from the DOLFIN C++ code and may need to be edited or expanded.
A File represents a data file for reading and writing objects. Unless specified explicitly, the format is determined by the file name suffix. A list of objects that can be read/written to file can be found in GenericFile.h. Compatible file formats include:
- Binary (.bin)
- RAW (.raw)
- SVG (.svg)
- XD3 (.xd3)
- XDMF (.xdmf)
- XML (.xml)
- XYZ (.xyz)
- VTK (.pvd)
File formats
Create a file with given name
// Save solution to file
File file("solution.pvd");
file << u;
// Read mesh data from file
File mesh_file("mesh.xml");
mesh_file >> mesh;
// Using compressed binary format
File comp_file("solution.pvd", "compressed");
Create a file with given name with MPI communicator
// Save solution to file
File file(u.mesh()->mpi_comm(), "solution.pvd");
file << u;
// Read mesh data from file
File mesh_file(MPI_COMM_WORLD, "mesh.xml");
mesh_file >> mesh;
// Using compressed binary format
File comp_file(u.mesh()->mpi_comm(), "solution.pvd",
"compressed");
Create a file with given name and type (format)
File file("solution", vtk);
Create a file with given name and type (format) with MPI communicator
File file(MPI_COMM_WORLD, "solution", vtk);
Create an outfile object writing to stream
Read from file
Write Mesh to file with time
File file("mesh.pvd", "compressed");
file << std::make_pair<const Mesh*, double>(&mesh, t);
Write MeshFunction to file with time
File file("markers.pvd", "compressed");
file << std::make_pair<const MeshFunction<int>*, double>(&f, t);
Write MeshFunction to file with time
File file("markers.pvd", "compressed");
file << std::make_pair<const MeshFunction<std::size_t>*, double>(&f, t);
Write MeshFunction to file with time
File file("markers.pvd", "compressed");
file << std::make_pair<const MeshFunction<double>*, double>(&f, t);
Write MeshFunction to file with time
File file("markers.pvd", "compressed");
file << std::make_pair<const MeshFunction<bool>*, double>(&f, t);
Write Function to file with time
File file("solution.pvd", "compressed");
file << std::make_pair<const Function*, double>(&u, t);
Write object to file
Check if file exists