deal.II version GIT relicensing-6842-g793a97d2aa 2026-10-02 14:00:01+00:00
\(\newcommand{\dealvcentcolon}{\mathrel{\mathop{:}}}\) \(\newcommand{\dealcoloneq}{\dealvcentcolon\mathrel{\mkern-1.2mu}=}\) \(\newcommand{\jump}[1]{\left[\!\left[ #1 \right]\!\right]}\) \(\newcommand{\average}[1]{\left\{\!\left\{ #1 \right\}\!\right\}}\)
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
DataOutBase::CFFlags Struct Reference

#include <deal.II/base/data_out_base.h>

Detailed Description

Flags controlling the details of output in CF Conventions format.

Definition at line 1094 of file data_out_base.h.

Inheritance diagram for DataOutBase::CFFlags:
[legend]

Public Types

using AttributeValue = std::variant< int, double, std::string >
 

Public Member Functions

 CFFlags (const double time=-std::numeric_limits< double >::infinity(), const bool keep_existing_file=false, const std::map< std::string, std::vector< std::pair< std::string, AttributeValue > > > &attributes={})
 
void parse_parameters (const ParameterHandler &prm)
 
std::size_t memory_consumption () const
 

Static Public Member Functions

static void declare_parameters (ParameterHandler &prm)
 

Public Attributes

double time
 
bool keep_existing_file
 
std::map< std::string, std::vector< std::pair< std::string, AttributeValue > > > attributes
 

Member Typedef Documentation

◆ AttributeValue

using DataOutBase::CFFlags::AttributeValue = std::variant<int, double, std::string>

Definition at line 1096 of file data_out_base.h.

Constructor & Destructor Documentation

◆ CFFlags()

DataOutBase::CFFlags::CFFlags ( const double  time = -std::numeric_limits<double>::infinity(),
const bool  keep_existing_file = false,
const std::map< std::string, std::vector< std::pair< std::string, AttributeValue > > > &  attributes = {} 
)
explicit

Constructor. Initializes the member variables with names corresponding to the argument names of this function.

Definition at line 2462 of file data_out_base.cc.

Member Function Documentation

◆ declare_parameters()

void DataOutBase::OutputFlagsBase< CFFlags >::declare_parameters ( ParameterHandler &  prm)
staticinherited

Declare all flags with name and type as offered by this class, for use in input files.

This method does nothing, but child classes may override this method to add fields to prm.

Definition at line 575 of file data_out_base.h.

◆ parse_parameters()

void DataOutBase::OutputFlagsBase< CFFlags >::parse_parameters ( const ParameterHandler &  prm)
inherited

Read the parameters declared in declare_parameters() and set the flags for this output format accordingly.

This method does nothing, but child classes may override this method to add fields to prm.

Definition at line 585 of file data_out_base.h.

◆ memory_consumption()

std::size_t DataOutBase::OutputFlagsBase< CFFlags >::memory_consumption ( ) const
inherited

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 594 of file data_out_base.h.

Member Data Documentation

◆ time

double DataOutBase::CFFlags::time

The time of the time step if this file is part of a time dependent simulation.

If this field is set to a value other than the default value of negative infinity, the output file will contain an unlimited time dimension which is used as a dimension for all data vectors. With keep_existing_file = true, consecutive time points are written to the same file. It is assumed that time is increasing.

Definition at line 1109 of file data_out_base.h.

◆ keep_existing_file

bool DataOutBase::CFFlags::keep_existing_file

If this field is set to true, instead of creating a new file with a mesh definition, data vectors are added to an existing file. This is mostly used to write multiple time points to the same file by setting CFFlags::time. For example:

DataOut<dim> data_out;
data_out.attach_dof_handler(dof);
// output mesh and initial value
data_out.add_vector("solution", solution);
data_out.build_patches();
data_out.cf_flags.time = t_0;
data_out.write_filtered_data(data_filter);
data_out.write_cf_parallel(data_filter, "solution.nc", MPI_COMM_WORLD);
double t = t_0;
while (t < t_end) {
// update solution, e.g. ODE step
// output current time step by adding
// a time step to the same file.
data_out.clear_data_vectors();
data_out.add_vector("solution", solution);
data_out.build_patches();
data_out.cf_flags.keep_existing_file = true;
data_out.cf_flags.time = t;
DataOutBase::DataOutFilter data_filter({false, false});
data_out.write_filtered_data(data_filter);
data_out.write_cf_parallel(data_filter, "solution.nc", MPI_COMM_WORLD);
}
void write_filtered_data(DataOutBase::DataOutFilter &filtered_data) const
void write_cf_parallel(const DataOutBase::DataOutFilter &data_filter, const std::string &filename, const MPI_Comm comm) const
DataOutBase::CFFlags cf_flags
void clear_data_vectors()
void attach_dof_handler(const DoFHandler< dim, spacedim > &)
virtual void build_patches(const unsigned int n_subdivisions=0)
Definition data_out.cc:1060

The current mesh must be the same as the one that was written to the existing file. When the mesh changes, e.g., when refining or coarsening, a new file must be created with the updated mesh.

Definition at line 1150 of file data_out_base.h.

◆ attributes

std::map<std::string, std::vector<std::pair<std::string, AttributeValue> > > DataOutBase::CFFlags::attributes

Additional attributes written for each data vector. Can be used to set attributes that are defined or required by CF Conventions but cannot be set by deal.II due to lack of information, e.g., units. deal.II does not use these attributes in any way except adding them to the output file, but they may be required by post processing tools. For example:

attributes["solution"].push_back({"units", "m/s"});
std::map< std::string, std::vector< std::pair< std::string, AttributeValue > > > attributes

The map may include the special keys that do not correspond to data vectors (and should not be used as names for data vectors):

  • "global": define global attributes that describe the file content
  • "time", "x", "y": attributes for dimension variables, e.g., "units". Attributes are only written when the file is first created, not on subsequent calls with keep_existing_file = true; Common attributes in the CF Conventions include (see the CF documentation for full details):
  • units: required for all data that is not dimensionless.
  • long_name, standard_name: recommended for all data.
  • comment: e.g. methods, global or per variable
  • title, references, history, etc: global, description of file.

Definition at line 1176 of file data_out_base.h.


The documentation for this struct was generated from the following files: