Classes | |
struct | DataVector |
class | ExcDataAlreadyAdded |
class | ExcDataNotCleared |
class | ExcInvalidCharacter |
class | ExcInvalidNumberOfNames |
class | ExcInvalidNumberOfSubdivisions |
class | ExcInvalidVectorSize |
class | ExcNameAlreadyUsed |
class | ExcNoDoFHandlerSelected |
class | ExcVectorNotDeclared |
Public Types | |
enum | VectorType { cell_vector, dof_vector } |
Public Member Functions | |
virtual | ~DataOutStack () |
void | new_parameter_value (const double parameter_value, const double parameter_step) |
void | attach_dof_handler (const DH &dof_handler) |
void | declare_data_vector (const std::string &name, const VectorType vector_type) |
void | declare_data_vector (const std::vector< std::string > &name, const VectorType vector_type) |
template<typename number > | |
void | add_data_vector (const Vector< number > &vec, const std::string &name) |
template<typename number > | |
void | add_data_vector (const Vector< number > &vec, const std::vector< std::string > &names) |
void | build_patches (const unsigned int n_subdivisions=0) |
void | finish_parameter_value () |
void | clear () |
unsigned int | memory_consumption () const |
Private Member Functions | |
virtual const std::vector < ::DataOutBase::Patch< dim+1, dim+1 > > & | get_patches () const |
virtual std::vector< std::string > | get_dataset_names () const |
Private Attributes | |
double | parameter |
double | parameter_step |
SmartPointer< const DH > | dof_handler |
std::vector < ::DataOutBase::Patch< dim+1, dim+1 > > | patches |
std::vector< DataVector > | dof_data |
std::vector< DataVector > | cell_data |
We will explain the concept for a time dependent problem, but instead of the time any parameter can be substituted. In our example, a solution of an equation is computed for each discrete time level. This is then added to an object of the present class and after all time levels are added, a space-time plot will be written in any of the output formats supported by the base class. Upon output, the (spatial) solution on each time level is extended into the time direction by writing it twice, once for the time level itself and once for a time equal to the time level minus a given time step. These two copies are connected, to form a space-time slab, with constant values in time.
Due to the piecewise constant output in time, the written solution will in general be discontinuous at discrete time levels, but the output is still sufficient in most cases. More sophisticated interpolations in time may be added in the future.
The following little example shall illustrate the different steps of use of this class. It is assumed that the finite element used is composed of two components, u
and v
, that the solution vector is named solution
and that a vector error
is computed which contains an error indicator for each spatial cell.
Note that unlike for the DataOut class it is necessary to first declare data vectors and the names of the components before first use. This is because on all time levels the same data should be present to produce reasonable time-space output. The output is generated with two subdivisions in each space and time direction, which is suitable for quadratic finite elements in space, for example.
* DataOutStack<dim> data_out_stack; * * // first declare the vectors * // to be used later * vector<string> solution_names; * solution_names.push_back ("u"); * solution_names.push_back ("v"); * data_out_stack.declare_data_vector (solution_names, * DataOutStack<dim>::dof_vector); * data_out_stack.declare_data_vector ("error", * DataOutStack<dim>::cell_vector); * * // now do computations * for (double parameter=0; ...) * { * DoFHandler<dim,spacedim> dof_handler; * ... // compute something * * // now for output * data_out_stack.new_parameter_value (parameter, * delta_parameter); * data_out_stack.attach_dof_handler (dof_handler); * data_out_stack.add_data_vector (solution, solution_names); * data_out_stack.add_data_vector (error, "error"); * data_out_stack.build_patches (2); * data_out_stack.finish_parameter_value (); * }; *
enum DataOutStack::VectorType |
virtual DataOutStack< dim, spacedim, DH >::~DataOutStack | ( | ) | [virtual] |
Destructor. Only declared to make it virtual
.
void DataOutStack< dim, spacedim, DH >::new_parameter_value | ( | const double | parameter_value, | |
const double | parameter_step | |||
) |
Start the next set of data for a specific parameter value. The argument parameter_step
denotes the interval (in backward direction, counted from parameter_value
) with which the output will be extended in parameter direction, i.e. orthogonal to the space directions.
void DataOutStack< dim, spacedim, DH >::attach_dof_handler | ( | const DH & | dof_handler | ) |
Attach the DoF handler for the grid and data associated with the parameter previously set by new_parameter_value
.
This has to happen before adding data vectors for the present parameter value.
void DataOutStack< dim, spacedim, DH >::declare_data_vector | ( | const std::string & | name, | |
const VectorType | vector_type | |||
) |
Declare a data vector. The vector_type
argument determines whether the data vector will be considered as DoF or cell data.
This version may be called if the finite element presently used by the DoFHandler (and previously attached to this object) has only one component and therefore only one name needs to be given.
void DataOutStack< dim, spacedim, DH >::declare_data_vector | ( | const std::vector< std::string > & | name, | |
const VectorType | vector_type | |||
) |
Declare a data vector. The vector_type
argument determines whether the data vector will be considered as DoF or cell data.
This version must be called if the finite element presently used by the DoFHandler (and previously attached to this object) has more than one component and therefore more than one name needs to be given. However, you can also call this function with a vector<string>
containing only one element if the finite element has only one component.
void DataOutStack< dim, spacedim, DH >::add_data_vector | ( | const Vector< number > & | vec, | |
const std::string & | name | |||
) | [inline] |
Add a data vector for the presently set value of the parameter.
This version may be called if the finite element presently used by the DoFHandler (and previously attached to this object) has only one component and therefore only one name needs to be given.
If vec
is a vector with multiple components this function will generate distinct names for all components by appending an underscore and the number of each component to name
The data vector must have been registered using the declare_data_vector
function before actually using it the first time.
Note that a copy of this vector is stored until finish_parameter_value
is called the next time, so if you are short of memory you may want to call this function only after all computations involving large matrices are already done.
void DataOutStack< dim, spacedim, DH >::add_data_vector | ( | const Vector< number > & | vec, | |
const std::vector< std::string > & | names | |||
) | [inline] |
Add a data vector for the presently set value of the parameter.
This version must be called if the finite element presently used by the DoFHandler (and previously attached to this object) has more than one component and therefore more than one name needs to be given. However, you can also call this function with a vector<string>
containing only one element if the finite element has only one component.
The data vector must have been registered using the declare_data_vector
function before actually using it the first time.
Note that a copy of this vector is stored until finish_parameter_value
is called the next time, so if you are short of memory you may want to call this function only after all computations involving large matrices are already done.
void DataOutStack< dim, spacedim, DH >::build_patches | ( | const unsigned int | n_subdivisions = 0 |
) |
Actually build the patches for output by the base classes from the data stored in the data vectors and using the previously attached DoFHandler object.
By n_subdivisions
you can decide into how many subdivisions (in each space and parameter direction) each patch is divided. This is useful if higher order elements are used. Note however, that the number of subdivisions in parameter direction is always the same as the one is space direction for technical reasons.
void DataOutStack< dim, spacedim, DH >::finish_parameter_value | ( | ) |
Release all data that is no more needed once build_patches
was called and all other transactions for a given parameter value are done.
Couterpart of new_parameter_value
.
void DataOutStack< dim, spacedim, DH >::clear | ( | ) |
Clear all data presently stored in this object.
unsigned int DataOutStack< dim, spacedim, DH >::memory_consumption | ( | ) | const |
Determine an estimate for the memory consumption (in bytes) of this object.
Reimplemented from DataOutInterface< dim+1 >.
virtual const std::vector< ::DataOutBase::Patch<dim+1,dim+1> >& DataOutStack< dim, spacedim, DH >::get_patches | ( | ) | const [private, virtual] |
This is the 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.
Implements DataOutInterface< dim+1 >.
virtual std::vector<std::string> DataOutStack< dim, spacedim, DH >::get_dataset_names | ( | ) | const [private, virtual] |
Virtual function through which the names of data sets are obtained by the output functions of the base class.
Implements DataOutInterface< dim+1 >.
double DataOutStack< dim, spacedim, DH >::parameter [private] |
Present parameter value.
double DataOutStack< dim, spacedim, DH >::parameter_step [private] |
Present parameter step, i.e. length of the parameter interval to be written next.
SmartPointer<const DH> DataOutStack< dim, spacedim, DH >::dof_handler [private] |
DoF handler to be used for the data corresponding to the present parameter value.
std::vector< ::DataOutBase::Patch<dim+1,dim+1> > DataOutStack< dim, spacedim, DH >::patches [private] |
List of patches of all past and present parameter value data sets.
std::vector<DataVector> DataOutStack< dim, spacedim, DH >::dof_data [private] |
List of DoF data vectors.
std::vector<DataVector> DataOutStack< dim, spacedim, DH >::cell_data [private] |
List of cell data vectors.