DataOut_DoFData< DH, patch_dim, patch_space_dim > Class Template Reference
[Graphical output]

Inheritance diagram for DataOut_DoFData< DH, patch_dim, patch_space_dim >:
Inheritance graph
[legend]

List of all members.

Classes

class  DataEntry
class  DataEntryBase
class  ExcDataPostprocessingIsNotPossibleForCellData
class  ExcIncompatibleDatasetNames
class  ExcIncompatiblePatchLists
class  ExcInvalidCharacter
class  ExcInvalidNumberOfNames
class  ExcInvalidVectorDeclaration
class  ExcInvalidVectorSize
class  ExcNoDoFHandlerSelected
class  ExcNoPatches
class  ExcOldDataStillPresent

Public Types

enum  DataVectorType { type_dof_data, type_cell_data, type_automatic }
typedef DH::cell_iterator cell_iterator
typedef DH::active_cell_iterator active_cell_iterator

Public Member Functions

 DataOut_DoFData ()
virtual ~DataOut_DoFData ()
void attach_dof_handler (const DH &)
template<class VECTOR >
void add_data_vector (const VECTOR &data, const std::vector< std::string > &names, const DataVectorType type=type_automatic, const std::vector< DataComponentInterpretation::DataComponentInterpretation > &data_component_interpretation=std::vector< DataComponentInterpretation::DataComponentInterpretation >())
template<class VECTOR >
void add_data_vector (const VECTOR &data, const std::string &name, const DataVectorType type=type_automatic, const std::vector< DataComponentInterpretation::DataComponentInterpretation > &data_component_interpretation=std::vector< DataComponentInterpretation::DataComponentInterpretation >())
template<class VECTOR >
void add_data_vector (const VECTOR &data, const DataPostprocessor< DH::space_dimension > &data_postprocessor)
void clear_data_vectors ()
void clear_input_data_references ()
template<class DH2 >
void merge_patches (const DataOut_DoFData< DH2, patch_dim, patch_space_dim > &source, const Point< patch_space_dim > &shift=Point< patch_space_dim >())
virtual void clear ()
unsigned int memory_consumption () const

Protected Types

typedef ::DataOutBase::Patch
< patch_dim, patch_space_dim > 
Patch

Protected Member Functions

virtual const std::vector
< Patch > & 
get_patches () const
virtual std::vector< std::string > get_dataset_names () const
virtual std::vector
< std_cxx1x::tuple< unsigned
int, unsigned int, std::string > > 
get_vector_data_ranges () const

Protected Attributes

SmartPointer< const DH > dofs
std::vector
< std_cxx1x::shared_ptr
< DataEntryBase > > 
dof_data
std::vector
< std_cxx1x::shared_ptr
< DataEntryBase > > 
cell_data
std::vector< Patchpatches

Friends

class DataOut_DoFData

Detailed Description

template<class DH, int patch_dim, int patch_space_dim = patch_dim>
class DataOut_DoFData< DH, patch_dim, patch_space_dim >

This is an abstract class which provides the functionality to generate patches for output by base classes from data vectors on a grid. It allows to store a pointer to a DoFHandler object and one or more pointers to node and cell data denoting functions on the grid which shall later be written in any of the implemented data formats.

User visible interface

The user visible interface of this class consists of functions which allow a user to make a DoFHandler object known to this class and to add data vectors which will later be written to a file in some format. Instead of pondering about the different functions, an example is probably the best way:

   ...
   ...   // compute solution, which contains nodal values
   ...
   ...   // compute error_estimator, which contains one value per cell

   std::vector<std::string> solution_names;
   solution_names.push_back ("x-displacement");
   solution_names.push_back ("y-displacement");

   DataOut<dim> data_out;
   data_out.attach_dof_handler (dof_handler);
   data_out.add_data_vector (solution, solution_names);
   data_out.add_data_vector (error_estimator, "estimated_error");

   data_out.build_patches ();

   ofstream output_file ("output");
   data_out.write_xxx (output_file);

   data_out.clear();

attach_dof_handler() tells this class that all future operations are to take place with the DoFHandler object and the triangulation it lives on. We then add the solution vector and the error estimator; note that they have different dimensions, because the solution is a nodal vector, here consisting of two components ("x-displacement" and "y-displacement") while the error estimator probably is a vector holding cell data. When attaching a data vector, you have to give a name to each component of the vector, which is done through an object of type vector<string> as second argument; if only one component is in the vector, for example if we are adding cell data as in the second case, or if the finite element used by the DoFHandler has only one component, then you can use the second add_data_vector() function which takes a string instead of the vector<string>.

The add_data_vector() functions have additional arguments (with default values) that can be used to specify certain transformations. In particular, it allows to attach DataPostprocessor arguments to compute derived information from a data vector at each quadrature point (for example, the Mach number in hypersonic flow can be computed from density and velocities; step-29 also shows an example); another piece of information specified through arguments with default values is how certain output components should be interpreted, i.e. whether each component of the data is logically an independent scalar field, or whether some of them together form logically a vector-field (see the DataComponentInterpretation::DataComponentInterpretation enum, and the step-22 tutorial program).

It should be noted that this class does not copy the vector given to it through the add_data_vector() functions, for memory consumption reasons. It only stores a reference to it, so it is in your responsibility to make sure that the data vectors exist long enough.

After adding all data vectors, you need to call a function which generates the patches for output from the stored data. Derived classes name this function build_patches(). Finally, you write() the data in one format or other, to a file.

Please note, that in the example above, an object of type DataOut was used, i.e. an object of a derived class. This is necessary since this class does not provide means to actually generate the patches, only aids to store and access data.

Note that the base class of this class, DataOutInterface offers several functions to ease programming with run-time determinable output formats (i.e. you need not use a fixed format by calling DataOutInterface::write_xxx in the above example, but you can select it by a run-time parameter without having to write the if () ... else ... clauses yourself), and also functions and classes offering ways to control the appearance of the output by setting flags for each output format.

Information for derived classes

What is actually missing this class is a way to produce the patches for output itself, from the stored data and degree of freedom information. Since this task is often application dependent it is left to derived classes. For example, in many applications, it might be wanted to limit the depth of output to a certain number of refinement levels and write data from finer cells only in a way interpolated to coarser cells, to reduce the amount of output. Also, it might be wanted to use different numbers of subdivisions on different cells when forming a patch, for example to accomplish for different polynomial degrees of the trial space on different cells. Also, the output need not necessarily consist of a patch for each cell, but might be made up of patches for faces, of other things. Take a look at derived classes to what is possible in this respect.

For this reason, it is left to a derived class to provide a function, named usually build_patches() or the like, which fills the patches array of this class.

Regarding the templates of this class, it needs three values: first the space dimension in which the triangulation and the DoF handler operate, second the dimension of the objects which the patches represent. Although in most cases they are equal, there are also classes for which this does not hold, for example if one outputs the result of a computation exploiting rotational symmetry in the original domain (in which the space dimension of the output would be one higher than that of the DoF handler, see the DataOut_Rotation() class), or one might conceive that one could write a class that only outputs the solution on a cut through the domain, in which case the space dimension of the output is less than that of the DoF handler. The last template argument denotes the dimension of the space into which the patches are embedded; usually, this dimension is the same as the dimensio of the patches themselves (which is also the default value of the template parameter), but there might be cases where this is not so. For example, in the DataOut_Faces() class, patches are generated from faces of the triangulation. Thus, the dimension of the patch is one less than the dimension of the embedding space, which is, in this case, equal to the dimension of the triangulation and DoF handler. However, for the cut through the domain mentioned above, if the cut is a straight one, then the cut can be embedded into a space of one dimension lower than the dimension of the triangulation, so that the last template parameter has the same value as the second one.

Author:
Wolfgang Bangerth, 1999

Member Typedef Documentation

template<class DH, int patch_dim, int patch_space_dim = patch_dim>
typedef DH::cell_iterator DataOut_DoFData< DH, patch_dim, patch_space_dim >::cell_iterator

Typedef to the iterator type of the dof handler class under consideration.

Reimplemented in DataOut< dim, DH >, DataOutFaces< dim, DH >, DataOutRotation< dim, DH >, and DataOut< dim >.

template<class DH, int patch_dim, int patch_space_dim = patch_dim>
typedef DH::active_cell_iterator DataOut_DoFData< DH, patch_dim, patch_space_dim >::active_cell_iterator

Reimplemented in DataOut< dim, DH >, and DataOut< dim >.

template<class DH, int patch_dim, int patch_space_dim = patch_dim>
typedef ::DataOutBase::Patch<patch_dim,patch_space_dim> DataOut_DoFData< DH, patch_dim, patch_space_dim >::Patch [protected]

Abbreviate the somewhat lengthy name for the Patch class.


Member Enumeration Documentation

template<class DH, int patch_dim, int patch_space_dim = patch_dim>
enum DataOut_DoFData::DataVectorType

Type describing what the vector given to add_data_vector() is: a vector that has one entry per degree of freedom in a DoFHandler object (such as solution vectors), or one entry per cell in the triangulation underlying the DoFHandler object (such as error per cell data). The value type_automatic tells add_data_vector() to find out itself (see the documentation of add_data_vector() for the method used).

Enumerator:
type_dof_data 

Data vector entries are associated to degrees of freedom

type_cell_data 

Data vector entries are one per grid cell

type_automatic 

Find out automatically


Constructor & Destructor Documentation

template<class DH, int patch_dim, int patch_space_dim = patch_dim>
DataOut_DoFData< DH, patch_dim, patch_space_dim >::DataOut_DoFData (  ) 

Constructor

template<class DH, int patch_dim, int patch_space_dim = patch_dim>
virtual DataOut_DoFData< DH, patch_dim, patch_space_dim >::~DataOut_DoFData (  )  [virtual]

Destructor.


Member Function Documentation

template<class DH, int patch_dim, int patch_space_dim = patch_dim>
void DataOut_DoFData< DH, patch_dim, patch_space_dim >::attach_dof_handler ( const DH &   ) 

Designate a dof handler to be used to extract geometry data and the mapping between nodes and node values.

template<class DH, int patch_dim, int patch_space_dim = patch_dim>
template<class VECTOR >
void DataOut_DoFData< DH, patch_dim, patch_space_dim >::add_data_vector ( const VECTOR &  data,
const std::vector< std::string > &  names,
const DataVectorType  type = type_automatic,
const std::vector< DataComponentInterpretation::DataComponentInterpretation > &  data_component_interpretation = std::vector< DataComponentInterpretation::DataComponentInterpretation >() 
) [inline]

Add a data vector together with its name and the physical unit (for example meter, kelvin, etc). By default, "<dimensionless>" is assumed for the units.

A pointer to the vector is stored, so you have to make sure the vector exists at that address at least as long as you call the write_* functions.

It is assumed that the vector has the same number of components as there are degrees of freedom in the dof handler, in which case it is assumed to be a vector storing nodal data; or the size may be the number of active cells on the present grid, in which case it is assumed to be a cell data vector. As the number of degrees of freedom and of cells is usually not equal, the function can determine itself which type of vector it is given; however, there is one corner case, namely if you compute with piecewise constant elements and have one scalar quantity, then there are as many cells as there are degrees of freedom, but they may be ordered differently. In that case, you can change the last argument of the function from its default value type_automatic to either type_dof_data or type_cell_data, depending on what the vector represents. Apart from this corner case, you can leave the argument at its default value and let the function determine the type of the vector itself.

If it is a vector holding DoF data, the names given shall be one for each component, if the finite element in use is composed of several subelements. If it is a finite element composed of only one subelement, then there is another function following which takes a single name instead of a vector of names.

The data_component_interpretation argument contains information about how the individual components of output files that consist of more than one data set are to be interpreted.

For example, if one has a finite element for the Stokes equations in 2d, representing components (u,v,p), one would like to indicate that the first two, u and v, represent a logical vector so that later on when we generate graphical output we can hand them off to a visualization program that will automatically know to render them as a vector field, rather than as two separate and independent scalar fields.

The default value of this argument (i.e. an empty vector) corresponds is equivalent to a vector of values DataComponentInterpretation::component_is_scalar, indicating that all output components are independent scalar fields. However, if the given data vector represents logical vectors, you may pass a vector that contains values DataComponentInterpretation::component_is_part_of_vector. In the example above, one would pass in a vector with components (DataComponentInterpretation::component_is_part_of_vector, DataComponentInterpretation::component_is_part_of_vector, DataComponentInterpretation::component_is_scalar) for (u,v,p).

The names of a data vector shall only contain characters which are letters, underscore and a few other ones. Refer to the ExcInvalidCharacter exception declared in this class to see which characters are valid and which are not.

The actual type for the template argument may be any vector type from which FEValues can extract values on a cell using the FEValuesBase::get_function_values() function.

Referenced by DoFPrintSolverStep< dim, SOLVER, VECTOR >::print_vectors().

template<class DH, int patch_dim, int patch_space_dim = patch_dim>
template<class VECTOR >
void DataOut_DoFData< DH, patch_dim, patch_space_dim >::add_data_vector ( const VECTOR &  data,
const std::string &  name,
const DataVectorType  type = type_automatic,
const std::vector< DataComponentInterpretation::DataComponentInterpretation > &  data_component_interpretation = std::vector< DataComponentInterpretation::DataComponentInterpretation >() 
) [inline]

This function is an abbreviation to the above one (see there for a discussion of the various arguments), intended for use with finite elements that are not composed of subelements. In this case, only one name per data vector needs to be given, which is what this function takes. It simply relays its arguments after a conversion of the name to a vector of strings, to the other add_data_vector() function above.

If data 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 actual type for the template argument may be any vector type from which FEValues can extract values on a cell using the FEValuesBase::get_function_values() function.

template<class DH, int patch_dim, int patch_space_dim = patch_dim>
template<class VECTOR >
void DataOut_DoFData< DH, patch_dim, patch_space_dim >::add_data_vector ( const VECTOR &  data,
const DataPostprocessor< DH::space_dimension > &  data_postprocessor 
) [inline]

This function is an alternative to the above ones, allowing the output of derived quantities instead of the given data. This converison has to be done in a class derived from DataPostprocessor.

The names for these derived quantities are provided by the data_postprocessor argument. Likewise, the data_component_interpretation argument of the other add_data_vector() functions is provided by the data_postprocessor argument. As only data of type type_dof_data can be transformed, this type is also known implicitly and does not have to be given.

The actual type for the template argument may be any vector type from which FEValues can extract values on a cell using the FEValuesBase::get_function_values() function.

template<class DH, int patch_dim, int patch_space_dim = patch_dim>
void DataOut_DoFData< DH, patch_dim, patch_space_dim >::clear_data_vectors (  ) 

Release the pointers to the data vectors. This allows output of a new set of vectors without supplying the DoF handler again. Therefore, the DataOut object can be used in an algebraic context. Note that besides the data vectors also the patches already computed are deleted.

Referenced by DoFPrintSolverStep< dim, SOLVER, VECTOR >::print_vectors().

template<class DH, int patch_dim, int patch_space_dim = patch_dim>
void DataOut_DoFData< DH, patch_dim, patch_space_dim >::clear_input_data_references (  ) 

Release pointers to all input data elements, i.e. pointers to data vectors and to the DoF handler object. This function may be useful when you have called the build_patches function of derived class, since then the patches are built and the input data is no more needed, nor is there a need to reference it. You can then output the patches detached from the main thread and need not make sure anymore that the DoF handler object and vectors must not be deleted before the output thread is finished.

template<class DH , int patch_dim, int patch_space_dim>
template<class DH2 >
void DataOut_DoFData< DH, patch_dim, patch_space_dim >::merge_patches ( const DataOut_DoFData< DH2, patch_dim, patch_space_dim > &  source,
const Point< patch_space_dim > &  shift = Point<patch_space_dim>() 
) [inline]

This function can be used to merge the patches that were created using the build_patches function of the object given as argument into the list of patches created by this object. This is sometimes handy if one has, for example, a domain decomposition algorithm where each block is represented by a DoFHandler of its own, but one wants to output the solution on all the blocks at the same time.

For this to work, the given argument and this object need to have the same number of output vectors, and they need to use the same number of subdivisions per patch. The output will probably look rather funny if patches in both objects overlap in space.

If you call build_patches() for this object after merging in patches, the previous state is overwritten, and the merged-in patches are lost.

The second parameter allows to shift each node of the patches in the object passed in in the first parameter by a certain amount. This is sometimes useful to generate "exploded" views of a collection of blocks.

This function will fail if either this or the other object did not yet set up any patches.

References Assert, DataOut_DoFData< DH, patch_dim, patch_space_dim >::get_dataset_names(), DataOut_DoFData< DH, patch_dim, patch_space_dim >::get_patches(), DataOut_DoFData< DH, patch_dim, patch_space_dim >::get_vector_data_ranges(), DataOutBase::Patch< dim, spacedim >::no_neighbor, and DataOut_DoFData< DH, patch_dim, patch_space_dim >::patches.

template<class DH, int patch_dim, int patch_space_dim = patch_dim>
virtual void DataOut_DoFData< DH, patch_dim, patch_space_dim >::clear (  )  [virtual]

Release the pointers to the data vectors and the DoF handler. You have to set all data entries again using the add_data_vector() function. The pointer to the dof handler is cleared as well, along with all other data. In effect, this function resets everything to a virgin state.

template<class DH, int patch_dim, int patch_space_dim = patch_dim>
unsigned int DataOut_DoFData< DH, patch_dim, patch_space_dim >::memory_consumption (  )  const

Determine an estimate for the memory consumption (in bytes) of this object.

Reimplemented from DataOutInterface< patch_dim, patch_space_dim >.

template<class DH, int patch_dim, int patch_space_dim = patch_dim>
virtual const std::vector<Patch>& DataOut_DoFData< DH, patch_dim, patch_space_dim >::get_patches (  )  const [protected, virtual]

Function by which the base class's functions get to know what patches they shall write to a file.

Implements DataOutInterface< patch_dim, patch_space_dim >.

Referenced by DataOut_DoFData< DH, patch_dim, patch_space_dim >::merge_patches().

template<class DH, int patch_dim, int patch_space_dim = patch_dim>
virtual std::vector<std::string> DataOut_DoFData< DH, patch_dim, patch_space_dim >::get_dataset_names (  )  const [protected, virtual]

Virtual function through which the names of data sets are obtained by the output functions of the base class.

Implements DataOutInterface< patch_dim, patch_space_dim >.

Referenced by DataOut_DoFData< DH, patch_dim, patch_space_dim >::merge_patches().

template<class DH, int patch_dim, int patch_space_dim = patch_dim>
virtual std::vector<std_cxx1x::tuple<unsigned int, unsigned int, std::string> > DataOut_DoFData< DH, patch_dim, patch_space_dim >::get_vector_data_ranges (  )  const [protected, virtual]

Overload of the respective DataOutInterface::get_vector_data_ranges() function. See there for a more extensive documentation.

Reimplemented from DataOutInterface< patch_dim, patch_space_dim >.

Referenced by DataOut_DoFData< DH, patch_dim, patch_space_dim >::merge_patches().


Friends And Related Function Documentation

template<class DH, int patch_dim, int patch_space_dim = patch_dim>
friend class DataOut_DoFData [friend]

Make all template siblings friends. Needed for the merge_patches() function.


Member Data Documentation

template<class DH, int patch_dim, int patch_space_dim = patch_dim>
SmartPointer<const DH> DataOut_DoFData< DH, patch_dim, patch_space_dim >::dofs [protected]

Pointer to the dof handler object.

template<class DH, int patch_dim, int patch_space_dim = patch_dim>
std::vector<std_cxx1x::shared_ptr<DataEntryBase> > DataOut_DoFData< DH, patch_dim, patch_space_dim >::dof_data [protected]

List of data elements with vectors of values for each degree of freedom.

template<class DH, int patch_dim, int patch_space_dim = patch_dim>
std::vector<std_cxx1x::shared_ptr<DataEntryBase> > DataOut_DoFData< DH, patch_dim, patch_space_dim >::cell_data [protected]

List of data elements with vectors of values for each cell.

template<class DH, int patch_dim, int patch_space_dim = patch_dim>
std::vector<Patch> DataOut_DoFData< DH, patch_dim, patch_space_dim >::patches [protected]

This is a list of patches that is created each time build_patches() is called. These patches are used in the output routines of the base classes.

Referenced by DataOut_DoFData< DH, patch_dim, patch_space_dim >::merge_patches().


The documentation for this class was generated from the following file:

deal.II documentation generated on Mon Nov 23 22:57:34 2009 by doxygen 1.6.1