![]() |
Reference documentation for deal.II version 9.6.0
|
#include <deal.II/base/data_out_base.h>
Public Member Functions | |
DataOutInterface () | |
virtual | ~DataOutInterface ()=default |
void | write_dx (std::ostream &out) const |
void | write_eps (std::ostream &out) const |
void | write_gmv (std::ostream &out) const |
void | write_gnuplot (std::ostream &out) const |
void | write_povray (std::ostream &out) const |
void | write_tecplot (std::ostream &out) const |
void | write_ucd (std::ostream &out) const |
void | write_vtk (std::ostream &out) const |
void | write_vtu (std::ostream &out) const |
void | write_vtu_in_parallel (const std::string &filename, const MPI_Comm comm) const |
void | write_pvtu_record (std::ostream &out, const std::vector< std::string > &piece_names) const |
std::string | write_vtu_with_pvtu_record (const std::string &directory, const std::string &filename_without_extension, const unsigned int counter, const MPI_Comm mpi_communicator, const unsigned int n_digits_for_counter=numbers::invalid_unsigned_int, const unsigned int n_groups=0) const |
void | write_svg (std::ostream &out) const |
void | write_deal_II_intermediate (std::ostream &out) const |
void | write_deal_II_intermediate_in_parallel (const std::string &filename, const MPI_Comm comm, const DataOutBase::CompressionLevel compression) const |
XDMFEntry | create_xdmf_entry (const DataOutBase::DataOutFilter &data_filter, const std::string &h5_filename, const double cur_time, const MPI_Comm comm) const |
XDMFEntry | create_xdmf_entry (const DataOutBase::DataOutFilter &data_filter, const std::string &h5_mesh_filename, const std::string &h5_solution_filename, const double cur_time, const MPI_Comm comm) const |
void | write_xdmf_file (const std::vector< XDMFEntry > &entries, const std::string &filename, const MPI_Comm comm) const |
void | write_hdf5_parallel (const DataOutBase::DataOutFilter &data_filter, const std::string &filename, const MPI_Comm comm) const |
void | write_hdf5_parallel (const DataOutBase::DataOutFilter &data_filter, const bool write_mesh_file, const std::string &mesh_filename, const std::string &solution_filename, const MPI_Comm comm) const |
void | write_filtered_data (DataOutBase::DataOutFilter &filtered_data) const |
void | write (std::ostream &out, const DataOutBase::OutputFormat output_format=DataOutBase::default_format) const |
void | set_default_format (const DataOutBase::OutputFormat default_format) |
template<typename FlagType > | |
void | set_flags (const FlagType &flags) |
std::string | default_suffix (const DataOutBase::OutputFormat output_format=DataOutBase::default_format) const |
void | parse_parameters (ParameterHandler &prm) |
std::size_t | memory_consumption () const |
Static Public Member Functions | |
static void | declare_parameters (ParameterHandler &prm) |
Protected Member Functions | |
virtual const std::vector< DataOutBase::Patch< dim, spacedim > > & | get_patches () const =0 |
virtual std::vector< std::string > | get_dataset_names () const =0 |
virtual std::vector< std::tuple< unsigned int, unsigned int, std::string, DataComponentInterpretation::DataComponentInterpretation > > | get_nonscalar_data_ranges () const |
void | validate_dataset_names () const |
Protected Attributes | |
unsigned int | default_subdivisions |
This class is the interface to the functions in the DataOutBase namespace, as already its name might suggest. It does not offer much functionality apart from a way to access the implemented formats and a way to dynamically dispatch what output format to chose.
This class is thought as a base class to classes actually generating data for output. It has two abstract virtual functions, get_patches() and get_dataset_names() produce the data which is actually needed. These are the only functions that need to be overloaded by a derived class. In addition to that, it has a function for each output format supported by the underlying base class which gets the output data using these two virtual functions and passes them to the raw output functions.
The purpose of this class is mainly two-fold: to support storing flags by which the output in the different output formats are controlled, and means to work with output in a way where output format, flags and other things are determined at run time. In addition to that it offers the abstract interface to derived classes briefly discussed above.
The way we treat flags in this class is very similar to that used in the GridOut
class. For detailed information on the why's and how's, as well as an example of programming, we refer to the documentation of that class.
Basically, this class stores a set of flags for each output format supported by the underlying DataOutBase
class. These are used whenever one of the write_*
functions is used. By default, the values of these flags are set to reasonable start-ups, but in case you want to change them, you can create a structure holding the flags for one of the output formats and set it using the set_flags
functions of this class to determine all future output the object might produce by that output format.
For information on what parameters are supported by different output functions, please see the documentation of the DataOutBase
class and its member classes.
In the output flags classes, described above, many flags are defined for output in the different formats. In order to make them available to the input file handler class ParameterHandler
, each of these has a function declaring these flags to the parameter handler and to read them back from an actual input file. In order to avoid that in user programs these functions have to be called for each available output format and the respective flag class, the present DataOutInterface
class offers a function declare_parameters
which calls the respective function of all known output format flags classes. The flags of each such format are packed together in a subsection in the input file. Likewise, there is a function parse_parameters
which reads these parameters and stores them in the flags associated with this object (see above).
Using these functions, you do not have to track which formats are presently implemented.
Usage is as follows:
Note that in the present example, the class DataOut
was used. However, any other class derived from DataOutInterface
would work alike.
This class, much like the GridOut
class, has a set of functions providing a list of supported output formats, an enum
denoting all these and a function to parse a string and return the respective enum
value if it is a valid output format's name (actually, these functions are inherited from the base class). Finally, there is a function write
, which takes a value of this enum
and dispatches to one of the actual write_*
functions depending on the output format selected by this value.
The functions offering the different output format names are, respectively, default_suffix
, parse_output_format
, and get_output_format_names
. They make the selection of output formats in parameter files much easier, and especially independent of the formats presently implemented. User programs need therefore not be changed whenever a new format is implemented.
Additionally, objects of this class have a default format, which can be set by the parameter "Output format" of the parameter file. Within a program, this can be changed by the member function set_default_format
. Using this default format, it is possible to leave the format selection completely to the parameter file. A suitable suffix for the output file name can be obtained by default_suffix
without arguments.
Definition at line 2642 of file data_out_base.h.
DataOutInterface< dim, spacedim >::DataOutInterface | ( | ) |
Constructor.
Definition at line 7581 of file data_out_base.cc.
|
virtualdefault |
Destructor. Does nothing, but is declared virtual since this class has virtual functions.
void DataOutInterface< dim, spacedim >::write_dx | ( | std::ostream & | out | ) | const |
Obtain data through get_patches() and write it to out
in OpenDX format. See DataOutBase::write_dx.
Definition at line 7590 of file data_out_base.cc.
void DataOutInterface< dim, spacedim >::write_eps | ( | std::ostream & | out | ) | const |
Obtain data through get_patches() and write it to out
in EPS format. See DataOutBase::write_eps.
Definition at line 7642 of file data_out_base.cc.
void DataOutInterface< dim, spacedim >::write_gmv | ( | std::ostream & | out | ) | const |
Obtain data through get_patches() and write it to out
in GMV format. See DataOutBase::write_gmv.
Definition at line 7655 of file data_out_base.cc.
void DataOutInterface< dim, spacedim >::write_gnuplot | ( | std::ostream & | out | ) | const |
Obtain data through get_patches() and write it to out
in GNUPLOT format. See DataOutBase::write_gnuplot.
Definition at line 7616 of file data_out_base.cc.
void DataOutInterface< dim, spacedim >::write_povray | ( | std::ostream & | out | ) | const |
Obtain data through get_patches() and write it to out
in POVRAY format. See DataOutBase::write_povray.
Definition at line 7629 of file data_out_base.cc.
void DataOutInterface< dim, spacedim >::write_tecplot | ( | std::ostream & | out | ) | const |
Obtain data through get_patches() and write it to out
in Tecplot format. See DataOutBase::write_tecplot.
Definition at line 7668 of file data_out_base.cc.
void DataOutInterface< dim, spacedim >::write_ucd | ( | std::ostream & | out | ) | const |
Obtain data through get_patches() and write it to out
in UCD format for AVS. See DataOutBase::write_ucd.
Definition at line 7603 of file data_out_base.cc.
void DataOutInterface< dim, spacedim >::write_vtk | ( | std::ostream & | out | ) | const |
Obtain data through get_patches() and write it to out
in Vtk format. See DataOutBase::write_vtk.
Definition at line 7681 of file data_out_base.cc.
void DataOutInterface< dim, spacedim >::write_vtu | ( | std::ostream & | out | ) | const |
Obtain data through get_patches() and write it to out
in Vtu (VTK's XML) format. See DataOutBase::write_vtu.
Some visualization programs, such as ParaView, can read several separate VTU files to parallelize visualization. In that case, you need a .pvtu
file that describes which VTU files form a group. The DataOutInterface::write_pvtu_record() function can generate such a centralized record. Likewise, DataOutInterface::write_visit_record() does the same for older versions of VisIt (although VisIt can also read pvtu
records since version 2.5.1). Finally, DataOutInterface::write_pvd_record() can be used to group together the files that jointly make up a time dependent simulation.
Definition at line 7692 of file data_out_base.cc.
void DataOutInterface< dim, spacedim >::write_vtu_in_parallel | ( | const std::string & | filename, |
const MPI_Comm | comm ) const |
Collective MPI call to write the solution from all participating nodes (those in the given communicator) to a single compressed .vtu file on a shared file system. The communicator can be a sub communicator of the one used by the computation. This routine uses MPI I/O to achieve high performance on parallel filesystems. In order to use this function, you need to be using a file system that supports parallel MPI I/O, and you will get error messages about failed MPI calls if you do not. Also see DataOutInterface::write_vtu().
Definition at line 7715 of file data_out_base.cc.
void DataOutInterface< dim, spacedim >::write_pvtu_record | ( | std::ostream & | out, |
const std::vector< std::string > & | piece_names ) const |
Some visualization programs, such as ParaView and VisIt, can read several separate VTU files that all form part of the same simulation, in order to parallelize visualization. In that case, you need a .pvtu
file that describes which VTU files (written, for example, through the DataOutInterface::write_vtu() function) form a group. The current function can generate such a centralized record.
The central record file generated by this function contains a list of (scalar or vector) fields that describes which fields can actually be found in the individual files that comprise the set of parallel VTU files along with the names of these files. This function gets the names and types of fields through the get_dataset_names() and get_nonscalar_data_ranges() functions of this class. The second argument to this function specifies the names of the files that form the parallel set.
pvtu
files that each describe one time step of a time dependent simulation, see the DataOutBase::write_pvd_record() function.pvtu
records. However, it can read visit records as written by the write_visit_record() function. Definition at line 7839 of file data_out_base.cc.
std::string DataOutInterface< dim, spacedim >::write_vtu_with_pvtu_record | ( | const std::string & | directory, |
const std::string & | filename_without_extension, | ||
const unsigned int | counter, | ||
const MPI_Comm | mpi_communicator, | ||
const unsigned int | n_digits_for_counter = numbers::invalid_unsigned_int, | ||
const unsigned int | n_groups = 0 ) const |
This function writes several .vtu files and a .pvtu record in parallel and constructs the filenames automatically. It is a combination of DataOutInterface::write_vtu() or DataOutInterface::write_vtu_in_parallel(), and DataOutInterface::write_pvtu_record().
For example, running write_vtu_with_pvtu_record("output/", "solution", 3, comm, 4, 2)
on 10 processes generates the files
where the .0.vtu
file contains the output of the first half of the processes grouped together, and the .1.vtu
the data from the remaining half.
A specified directory
and a filename_without_extension
form the first part of the filename. The filename is then extended with a counter
labeling the current timestep/iteration/etc., the processor ID, and finally the .vtu/.pvtu ending. Since the number of timesteps to be written depends on the application, the number of digits to be reserved in the filename can be specified as parameter n_digits_for_counter
, and the number is not padded with leading zeros if this parameter is left at its default value numbers::invalid_unsigned_int. If more than one file identifier is needed (e.g. time step number and iteration counter of solver), the last identifier is used as counter
, while all other identifiers have to be added to filename_without_extension
when calling this function.
In a parallel setting, several files are typically written per time step. The number of files written in parallel depends on the number of MPI processes (see parameter mpi_communicator
), and a specified number of n_groups
with default value 0. The background is that VTU file output supports grouping files from several CPUs into a given number of files using MPI I/O when writing on a parallel filesystem. The default value of n_groups
is 0, meaning that every MPI rank will write one file. A value of 1 will generate one big file containing the solution over the whole domain, while a larger value will create n_groups
files (but not more than there are MPI ranks). For all values other than n_groups==0
, this function calls write_vtu_in_parallel(); for this function to work you need to be using a file system that supports parallel MPI I/O, and you will get error messages about failed MPI calls if you do not.
Note that only one processor needs to generate the .pvtu file, where processor zero is chosen to take over this job.
The return value is the filename of the centralized file for the pvtu record.
directory
and filename_without_extension
, i.e., the user has to make sure that directory
contains a trailing character, e.g. "/", that separates the directory from the filename.Definition at line 7854 of file data_out_base.cc.
void DataOutInterface< dim, spacedim >::write_svg | ( | std::ostream & | out | ) | const |
Obtain data through get_patches() and write it to out
in SVG format. See DataOutBase::write_svg.
Definition at line 7703 of file data_out_base.cc.
void DataOutInterface< dim, spacedim >::write_deal_II_intermediate | ( | std::ostream & | out | ) | const |
Obtain data through get_patches() and write it to out
in deal.II intermediate format. See DataOutBase::write_deal_II_intermediate.
Note that the intermediate format is what its name suggests: a direct representation of internal data. It isn't standardized and will change whenever we change our internal representation. You can only expect to process files written in this format using the same version of deal.II that was used for writing.
Definition at line 7935 of file data_out_base.cc.
void DataOutInterface< dim, spacedim >::write_deal_II_intermediate_in_parallel | ( | const std::string & | filename, |
const MPI_Comm | comm, | ||
const DataOutBase::CompressionLevel | compression ) const |
Obtain data through get_patches() and write it using MPI I/O in parallel to the file filename
in the parallel deal.II intermediate format. See DataOutBase::write_deal_II_intermediate_in_parallel().
Definition at line 7949 of file data_out_base.cc.
XDMFEntry DataOutInterface< dim, spacedim >::create_xdmf_entry | ( | const DataOutBase::DataOutFilter & | data_filter, |
const std::string & | h5_filename, | ||
const double | cur_time, | ||
const MPI_Comm | comm ) const |
Create an XDMFEntry based on the data in the data_filter. This assumes the mesh and solution data were written to a single file. See write_xdmf_file() for an example of usage.
Definition at line 7968 of file data_out_base.cc.
XDMFEntry DataOutInterface< dim, spacedim >::create_xdmf_entry | ( | const DataOutBase::DataOutFilter & | data_filter, |
const std::string & | h5_mesh_filename, | ||
const std::string & | h5_solution_filename, | ||
const double | cur_time, | ||
const MPI_Comm | comm ) const |
Create an XDMFEntry based on the data in the data_filter. This assumes the mesh and solution data were written to separate files. See write_xdmf_file() for an example of usage.
Definition at line 7982 of file data_out_base.cc.
void DataOutInterface< dim, spacedim >::write_xdmf_file | ( | const std::vector< XDMFEntry > & | entries, |
const std::string & | filename, | ||
const MPI_Comm | comm ) const |
Write an XDMF file based on the provided vector of XDMFEntry objects. Below is an example of how to use this function with HDF5 and the DataOutFilter:
Definition at line 8121 of file data_out_base.cc.
void DataOutInterface< dim, spacedim >::write_hdf5_parallel | ( | const DataOutBase::DataOutFilter & | data_filter, |
const std::string & | filename, | ||
const MPI_Comm | comm ) const |
Write the data in data_filter
to a single HDF5 file containing both the mesh and solution values. Below is an example of how to use this function with the DataOutFilter:
Definition at line 8656 of file data_out_base.cc.
void DataOutInterface< dim, spacedim >::write_hdf5_parallel | ( | const DataOutBase::DataOutFilter & | data_filter, |
const bool | write_mesh_file, | ||
const std::string & | mesh_filename, | ||
const std::string & | solution_filename, | ||
const MPI_Comm | comm ) const |
Write the data in data_filter to HDF5 file(s). If write_mesh_file is false, the mesh data will not be written and the solution file will contain only the solution values. If write_mesh_file is true and the filenames are the same, the resulting file will contain both mesh data and solution values.
Definition at line 8669 of file data_out_base.cc.
void DataOutInterface< dim, spacedim >::write_filtered_data | ( | DataOutBase::DataOutFilter & | filtered_data | ) | const |
DataOutFilter is an intermediate data format that reduces the amount of data that will be written to files. The object filled by this function can then later be used again to write data in a concrete file format; see, for example, DataOutBase::write_hdf5_parallel().
Definition at line 8166 of file data_out_base.cc.
void DataOutInterface< dim, spacedim >::write | ( | std::ostream & | out, |
const DataOutBase::OutputFormat | output_format = DataOutBase::default_format ) const |
Write data and grid to out
according to the given data format. This function simply calls the appropriate write_*
function. If no output format is requested, the default_format
is written.
An error occurs if no format is provided and the default format is default_format
.
Definition at line 8787 of file data_out_base.cc.
void DataOutInterface< dim, spacedim >::set_default_format | ( | const DataOutBase::OutputFormat | default_format | ) |
Set the default format. The value set here is used anytime, output for format default_format
is requested.
Definition at line 8853 of file data_out_base.cc.
void DataOutInterface< dim, spacedim >::set_flags | ( | const FlagType & | flags | ) |
Set the flags to be used for output. This method expects flags
to be a member of one of the child classes of OutputFlagsBase
.
Definition at line 8863 of file data_out_base.cc.
std::string DataOutInterface< dim, spacedim >::default_suffix | ( | const DataOutBase::OutputFormat | output_format = DataOutBase::default_format | ) | const |
A function that returns the same string as the respective function in the base class does; the only exception being that if the parameter is omitted, then the value for the present default format is returned, i.e. the correct suffix for the format that was set through set_default_format() or parse_parameters() before calling this function.
Definition at line 8900 of file data_out_base.cc.
|
static |
Declare parameters for all output formats by declaring subsections within the parameter file for each output format and call the respective declare_parameters
functions of the flag classes for each output format.
Some of the declared subsections may not contain entries, if the respective format does not export any flags.
Note that the top-level parameters denoting the number of subdivisions per patch and the output format are not declared, since they are only passed to virtual functions and are not stored inside objects of this type. You have to declare them yourself.
Definition at line 8913 of file data_out_base.cc.
void DataOutInterface< dim, spacedim >::parse_parameters | ( | ParameterHandler & | prm | ) |
Read the parameters declared in declare_parameters() and set the flags for the output formats accordingly.
The flags thus obtained overwrite all previous contents of the flag objects as default-constructed or set by the set_flags() function.
Definition at line 8970 of file data_out_base.cc.
std::size_t DataOutInterface< dim, spacedim >::memory_consumption | ( | ) | const |
Return an estimate for the memory consumption, in bytes, of this object. This is not exact (but will usually be close) because calculating the memory usage of trees (e.g., std::map
) is difficult.
Definition at line 9021 of file data_out_base.cc.
|
protectedpure virtual |
This is the abstract function through which derived classes propagate preprocessed data in the form of Patch structures (declared in the base class DataOutBase) to the actual output function. You need to overload this function to allow the output functions to know what they shall print.
Implemented in BoundingBoxDataOut< dim >, DataOut_DoFData< dim, patch_dim, spacedim, patch_spacedim >, DataOut_DoFData< dim, dim - 1, dim, dim >, DataOut_DoFData< dim, dim+1, dim, dim+1 >, DataOut_DoFData< dim, dim, dim, dim >, DataOut_DoFData< dim, dim, spacedim, spacedim >, DataOut_DoFData< dim, patch_dim, spacedim, spacedim >, DataOutReader< dim, spacedim >, DataOutResample< dim, patch_dim, spacedim >, DataOutStack< dim, spacedim >, MatrixOut, and Particles::DataOut< dim, spacedim >.
|
protectedpure virtual |
Abstract virtual function through which the names of data sets are obtained by the output functions of the base class.
Implemented in BoundingBoxDataOut< dim >, DataOut_DoFData< dim, patch_dim, spacedim, patch_spacedim >, DataOut_DoFData< dim, dim - 1, dim, dim >, DataOut_DoFData< dim, dim+1, dim, dim+1 >, DataOut_DoFData< dim, dim, dim, dim >, DataOut_DoFData< dim, dim, spacedim, spacedim >, DataOut_DoFData< dim, patch_dim, spacedim, spacedim >, DataOutReader< dim, spacedim >, DataOutStack< dim, spacedim >, MatrixOut, and Particles::DataOut< dim, spacedim >.
|
protectedvirtual |
This functions returns information about how the individual components of output files that consist of more than one data set are to be interpreted.
It returns a list of index pairs and corresponding name and type indicating which components of the output are to be considered vector- or tensor-valued rather than just a collection of scalar data. The index pairs are inclusive; for example, if we have a Stokes problem in 2d with components (u,v,p), then the corresponding vector data range should be (0,1), and the returned list would consist of only a single element with a tuple such as (0,1,"velocity",component_is_part_of_vector).
Since some of the derived classes do not know about non-scalar data, this function has a default implementation that simply returns an empty string, meaning that all data is to be considered a collection of scalar fields.
Reimplemented in DataOut_DoFData< dim, patch_dim, spacedim, patch_spacedim >, DataOut_DoFData< dim, dim - 1, dim, dim >, DataOut_DoFData< dim, dim+1, dim, dim+1 >, DataOut_DoFData< dim, dim, dim, dim >, DataOut_DoFData< dim, dim, spacedim, spacedim >, DataOut_DoFData< dim, patch_dim, spacedim, spacedim >, DataOutReader< dim, spacedim >, and Particles::DataOut< dim, spacedim >.
Definition at line 9045 of file data_out_base.cc.
|
protected |
Validate that the names of the datasets returned by get_dataset_names() and get_nonscalar_data_ranges() are valid. This currently consists of checking that names are not used more than once. If an invalid state is encountered, an Assert() will be triggered in debug mode.
Definition at line 9057 of file data_out_base.cc.
|
protected |
The default number of subdivisions for patches. This is filled by parse_parameters() and should be obeyed by build_patches() in derived classes.
Definition at line 3117 of file data_out_base.h.
|
private |
Standard output format. Use this format, if output format default_format is requested. It can be changed by the set_format
function or in a parameter file.
Definition at line 3125 of file data_out_base.h.
|
private |
Flags to be used upon output of OpenDX data. Can be changed by using the set_flags
function.
Definition at line 3131 of file data_out_base.h.
|
private |
Flags to be used upon output of UCD data. Can be changed by using the set_flags
function.
Definition at line 3137 of file data_out_base.h.
|
private |
Flags to be used upon output of GNUPLOT data. Can be changed by using the set_flags
function.
Definition at line 3143 of file data_out_base.h.
|
private |
Flags to be used upon output of POVRAY data. Can be changed by using the set_flags
function.
Definition at line 3149 of file data_out_base.h.
|
private |
Flags to be used upon output of EPS data in one space dimension. Can be changed by using the set_flags
function.
Definition at line 3155 of file data_out_base.h.
|
private |
Flags to be used upon output of gmv data in one space dimension. Can be changed by using the set_flags
function.
Definition at line 3161 of file data_out_base.h.
|
private |
Flags to be used upon output of hdf5 data in one space dimension. Can be changed by using the set_flags
function.
Definition at line 3167 of file data_out_base.h.
|
private |
Flags to be used upon output of Tecplot data in one space dimension. Can be changed by using the set_flags
function.
Definition at line 3173 of file data_out_base.h.
|
private |
Flags to be used upon output of vtk data in one space dimension. Can be changed by using the set_flags
function.
Definition at line 3179 of file data_out_base.h.
|
private |
Flags to be used upon output of svg data in one space dimension. Can be changed by using the set_flags
function.
Definition at line 3185 of file data_out_base.h.
|
private |
Flags to be used upon output of deal.II intermediate data in one space dimension. Can be changed by using the set_flags
function.
Definition at line 3191 of file data_out_base.h.