deal2lkit: A ToolKit library for Deal.II
ErrorHandler< ntables > Class Template Reference

#include <error_handler.h>

Inheritance diagram for ErrorHandler< ntables >:
ParameterAcceptor Subscriptor

Public Member Functions

 ErrorHandler (const std::string name="", const std::string solution_names="u", const std::string list_of_error_norms="Linfty, L2, H1")
 The constructor takes an optional name, specifying the parameter entry. More...
 
virtual void declare_parameters (ParameterHandler &prm)
 Initialize the given values for the paramter file. More...
 
virtual void parse_parameters (ParameterHandler &prm)
 Parse the given parameter handler. More...
 
template<typename DH , typename VEC >
void error_from_exact (const DH &vspace, const VEC &solution, const Function< DH::space_dimension > &exact, unsigned int table_no=0, double dt=0.)
 Calculate the error of the numeric solution in variuous norms. More...
 
template<typename DH , typename VEC >
void error_from_exact (const Mapping< DH::dimension, DH::space_dimension > &mapping, const DH &vspace, const VEC &solution, const Function< DH::space_dimension > &exact, unsigned int table_no=0, double dt=0.)
 Same as above, with different mapping. More...
 
template<typename DH >
void custom_error (const std::function< double(const unsigned int component)> &custom_error_function, const DH &dh, const std::string &error_name="custom", const bool add_table_extras=false, const unsigned int table_no=0, const double dt=0.)
 Call the given custom function to compute the custom error for the given component and store the result in the given table. More...
 
template<typename DH , typename VEC >
void difference (const DH &, const VEC &, const DH &, const VEC &, unsigned int table_no=0, double dt=0.)
 Difference between two solutions in two different vector spaces. More...
 
template<typename DH , typename VEC >
void difference (const DH &, const VEC &, const VEC &, unsigned int table_no=0, double dt=0.)
 Difference between two solutions in the same vector space. More...
 
void output_table (std::ostream &out=std::cout, const unsigned int table_no=0)
 By default output first table. More...
 
void output_table (ConditionalOStream &pcout, const unsigned int table_no=0)
 By default output first table. More...
 
template<typename DH , typename VECTOR >
void difference (const DH &dh, const VECTOR &solution1, const VECTOR &solution2, unsigned int table_no, double dt)
 
template<typename DH , typename VECTOR >
void error_from_exact (const DH &dh, const VECTOR &solution, const Function< DH::space_dimension > &exact, unsigned int table_no, double dt)
 
template<typename DH , typename VECTOR >
void error_from_exact (const Mapping< DH::dimension, DH::space_dimension > &mapping, const DH &dh, const VECTOR &solution, const Function< DH::space_dimension > &exact, unsigned int table_no, double dt)
 
- Public Member Functions inherited from ParameterAcceptor
 ParameterAcceptor (const std::string section_name="")
 The constructor adds derived classes to the list of acceptors. More...
 
virtual ~ParameterAcceptor ()
 The destructor sets to zero the pointer relative to this index, so that it is safe to destroy the mother class. More...
 
virtual void parse_parameters_call_back ()
 Parse parameter call back. More...
 
std::string get_section_name () const
 Return the section name of this class. More...
 
std::vector< std::string > get_section_path () const
 Travers all registered classes, and figure out what subsections we need to enter. More...
 
template<class T >
void add_parameter (ParameterHandler &prm, T *parameter, const std::string &entry, const std::string &default_value, const Patterns::PatternBase &pattern=Patterns::Anything(), const std::string &documentation=std::string())
 Add a parameter the given parameter list. More...
 
template<class T >
void add_parameter (T &parameter, const std::string &entry, const std::string &documentation=std::string(), ParameterHandler &prm=ParameterAcceptor::prm)
 Add a parameter to the global parameter handler ParameterAcceptor::prm. More...
 
void enter_my_subsection (ParameterHandler &prm)
 Make sure we enter the right subsection of the global parameter file. More...
 
void leave_my_subsection (ParameterHandler &prm)
 This function undoes what the enter_my_subsection() function did. More...
 
template<>
std_cxx11::shared_ptr< Patterns::PatternBaseto_pattern (const double &)
 double More...
 
template<>
std::string to_string (const double &entry)
 
template<>
double to_type (const std::string &parameter)
 
template<>
std_cxx11::shared_ptr< Patterns::PatternBaseto_pattern (const int &)
 int More...
 
template<>
std::string to_string (const int &entry)
 
template<>
int to_type (const std::string &parameter)
 
template<>
std_cxx11::shared_ptr< Patterns::PatternBaseto_pattern (const unsigned int &)
 unsigned int More...
 
template<>
std::string to_string (const unsigned int &entry)
 
template<>
unsigned int to_type (const std::string &parameter)
 
template<>
std_cxx11::shared_ptr< Patterns::PatternBaseto_pattern (const bool &)
 bool More...
 
template<>
std::string to_string (const bool &entry)
 
template<>
bool to_type (const std::string &parameter)
 
- Public Member Functions inherited from Subscriptor
 Subscriptor ()
 
 Subscriptor (const Subscriptor &)
 
 Subscriptor (Subscriptor &&)
 
virtual ~Subscriptor ()
 
Subscriptoroperator= (const Subscriptor &)
 
Subscriptoroperator= (Subscriptor &&)
 
void subscribe (const char *identifier=0) const
 
void unsubscribe (const char *identifier=0) const
 
unsigned int n_subscriptions () const
 
void list_subscribers () const
 
void serialize (Archive &ar, const unsigned int version)
 

Private Attributes

const std::string solution_names
 Value of solution names. More...
 
const std::string list_of_error_norms
 List of error norms to compute. More...
 
std::vector< ConvergenceTabletables
 Error results. More...
 
std::vector< std::string > headers
 Headers for tables and output. More...
 
std::vector< std::string > latex_headers
 Headers for latex tables. More...
 
std::vector< std::string > latex_captions
 Captions for latex. More...
 
std::vector< std::string > names
 Names of the tables. More...
 
std::vector< std::vector< NormFlags > > types
 Type of error to compute per components. More...
 
bool initialized
 The parameters have been read. More...
 
bool compute_error
 Compute the error. More...
 
std::vector< bool > add_rates
 Add convergence rates. More...
 
bool write_error
 Write the error files. More...
 
bool output_error
 Output the error file also on screen. More...
 
std::string error_file_format
 The error file format. More...
 
std::vector< std::map< std::string, bool > > extras
 The extra column to add to the tables. More...
 
std::vector< std::string > rate_keys
 Wether or not to calculate the rates according to the given keys. More...
 
unsigned int precision
 The precision with which the table is written. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from ParameterAcceptor
static void initialize (const std::string filename="", const std::string outfilename="")
 Call declare_all_parameters(), read filename (if it is present as input parameter) and parse_all_parameters() on the static member prm. More...
 
static void clear ()
 Clear class list and global parameter file. More...
 
static void parse_all_parameters (ParameterHandler &prm=ParameterAcceptor::prm)
 Parse the given ParameterHandler. More...
 
static void log_info ()
 Print information about all stored classes. More...
 
static void declare_all_parameters (ParameterHandler &prm=ParameterAcceptor::prm)
 Initialize the ParameterHandler with all derived classes parameters.This function enters the subsection returned by get_section_name() for each derived class, and declares all parameters that were added using add_parameter(). More...
 
template<class T >
static std_cxx11::shared_ptr< Patterns::PatternBaseto_pattern (const T &)
 Given a class T, construct its default pattern to be used when declaring parameters. More...
 
template<class T >
static T to_type (const std::string &)
 Given a string, fill the value of the given parameter. More...
 
template<class T >
static std::string to_string (const T &)
 Given a parameter, return a string containing the given parameter. More...
 
- Static Public Member Functions inherited from Subscriptor
static::ExceptionBase & ExcInUse (int arg1, char *arg2, std::string &arg3)
 
static::ExceptionBase & ExcNoSubscriber (char *arg1, char *arg2)
 
- Static Public Attributes inherited from ParameterAcceptor
static ParameterHandler prm
 Static parameter. More...
 
- Protected Attributes inherited from ParameterAcceptor
const std::string section_name
 The subsection name for this class. More...
 

Detailed Description

template<int ntables = 1>
class ErrorHandler< ntables >

Definition at line 82 of file error_handler.h.

Constructor & Destructor Documentation

§ ErrorHandler()

template<int ntables>
ErrorHandler< ntables >::ErrorHandler ( const std::string  name = "",
const std::string  solution_names = "u",
const std::string  list_of_error_norms = "Linfty, L2H1" 
)

The constructor takes an optional name, specifying the parameter entry.

Definition at line 40 of file error_handler.cc.

Member Function Documentation

§ custom_error()

template<int ntables>
template<typename DH >
void ErrorHandler< ntables >::custom_error ( const std::function< double(const unsigned int component)> &  custom_error_function,
const DH &  dh,
const std::string &  error_name = "custom",
const bool  add_table_extras = false,
const unsigned int  table_no = 0,
const double  dt = 0. 
)

Call the given custom function to compute the custom error for the given component and store the result in the given table.

If a name is specified, then this function can be called several times on the same table to add different columns with different names, provided you use an appropriate function every time.

Should you wish to do so, then make sure the parameter add_table_extras is set to false for each call, except one, so that you only add dofs and cells informations once.

Definition at line 527 of file error_handler.h.

§ declare_parameters()

template<int ntables>
void ErrorHandler< ntables >::declare_parameters ( ParameterHandler prm)
virtual

Initialize the given values for the paramter file.

Reimplemented from ParameterAcceptor.

Definition at line 52 of file error_handler.cc.

§ difference() [1/3]

template<int ntables = 1>
template<typename DH , typename VEC >
void ErrorHandler< ntables >::difference ( const DH &  ,
const VEC &  ,
const DH &  ,
const VEC &  ,
unsigned int  table_no = 0,
double  dt = 0. 
)

Difference between two solutions in two different vector spaces.

§ difference() [2/3]

template<int ntables = 1>
template<typename DH , typename VEC >
void ErrorHandler< ntables >::difference ( const DH &  ,
const VEC &  ,
const VEC &  ,
unsigned int  table_no = 0,
double  dt = 0. 
)

Difference between two solutions in the same vector space.

§ difference() [3/3]

template<int ntables = 1>
template<typename DH , typename VECTOR >
void ErrorHandler< ntables >::difference ( const DH &  dh,
const VECTOR &  solution1,
const VECTOR &  solution2,
unsigned int  table_no,
double  dt 
)

Definition at line 276 of file error_handler.h.

§ error_from_exact() [1/4]

template<int ntables = 1>
template<typename DH , typename VEC >
void ErrorHandler< ntables >::error_from_exact ( const DH &  vspace,
const VEC &  solution,
const Function< DH::space_dimension > &  exact,
unsigned int  table_no = 0,
double  dt = 0. 
)

Calculate the error of the numeric solution in variuous norms.

Store the result in the given table.

§ error_from_exact() [2/4]

template<int ntables = 1>
template<typename DH , typename VEC >
void ErrorHandler< ntables >::error_from_exact ( const Mapping< DH::dimension, DH::space_dimension > &  mapping,
const DH &  vspace,
const VEC &  solution,
const Function< DH::space_dimension > &  exact,
unsigned int  table_no = 0,
double  dt = 0. 
)

Same as above, with different mapping.

§ error_from_exact() [3/4]

template<int ntables = 1>
template<typename DH , typename VECTOR >
void ErrorHandler< ntables >::error_from_exact ( const DH &  dh,
const VECTOR &  solution,
const Function< DH::space_dimension > &  exact,
unsigned int  table_no,
double  dt 
)

Definition at line 294 of file error_handler.h.

§ error_from_exact() [4/4]

template<int ntables = 1>
template<typename DH , typename VECTOR >
void ErrorHandler< ntables >::error_from_exact ( const Mapping< DH::dimension, DH::space_dimension > &  mapping,
const DH &  dh,
const VECTOR &  solution,
const Function< DH::space_dimension > &  exact,
unsigned int  table_no,
double  dt 
)

Definition at line 306 of file error_handler.h.

§ output_table() [1/2]

template<int ntables>
void ErrorHandler< ntables >::output_table ( std::ostream &  out = std::cout,
const unsigned int  table_no = 0 
)

By default output first table.

Definition at line 214 of file error_handler.cc.

§ output_table() [2/2]

template<int ntables>
void ErrorHandler< ntables >::output_table ( ConditionalOStream pcout,
const unsigned int  table_no = 0 
)

By default output first table.

The output is according to to the condition of ConditionalOStream &pcout

Definition at line 261 of file error_handler.cc.

§ parse_parameters()

template<int ntables>
void ErrorHandler< ntables >::parse_parameters ( ParameterHandler prm)
virtual

Parse the given parameter handler.

Reimplemented from ParameterAcceptor.

Definition at line 114 of file error_handler.cc.

Member Data Documentation

§ add_rates

template<int ntables = 1>
std::vector<bool> ErrorHandler< ntables >::add_rates
private

Add convergence rates.

Definition at line 188 of file error_handler.h.

§ compute_error

template<int ntables = 1>
bool ErrorHandler< ntables >::compute_error
private

Compute the error.

If this is false, all functions regarding errors are disabled and don't do anything.

Definition at line 185 of file error_handler.h.

§ error_file_format

template<int ntables = 1>
std::string ErrorHandler< ntables >::error_file_format
private

The error file format.

Definition at line 197 of file error_handler.h.

§ extras

template<int ntables = 1>
std::vector<std::map<std::string, bool> > ErrorHandler< ntables >::extras
private

The extra column to add to the tables.

Definition at line 200 of file error_handler.h.

§ headers

template<int ntables = 1>
std::vector<std::string> ErrorHandler< ntables >::headers
private

Headers for tables and output.

Contains the name of the solution components.

Definition at line 165 of file error_handler.h.

§ initialized

template<int ntables = 1>
bool ErrorHandler< ntables >::initialized
private

The parameters have been read.

Definition at line 181 of file error_handler.h.

§ latex_captions

template<int ntables = 1>
std::vector<std::string> ErrorHandler< ntables >::latex_captions
private

Captions for latex.

Definition at line 172 of file error_handler.h.

§ latex_headers

template<int ntables = 1>
std::vector<std::string> ErrorHandler< ntables >::latex_headers
private

Headers for latex tables.

Contains the name of the solution components.

Definition at line 169 of file error_handler.h.

§ list_of_error_norms

template<int ntables = 1>
const std::string ErrorHandler< ntables >::list_of_error_norms
private

List of error norms to compute.

Definition at line 158 of file error_handler.h.

§ names

template<int ntables = 1>
std::vector<std::string> ErrorHandler< ntables >::names
private

Names of the tables.

Definition at line 175 of file error_handler.h.

§ output_error

template<int ntables = 1>
bool ErrorHandler< ntables >::output_error
private

Output the error file also on screen.

Definition at line 194 of file error_handler.h.

§ precision

template<int ntables = 1>
unsigned int ErrorHandler< ntables >::precision
private

The precision with which the table is written.

Definition at line 206 of file error_handler.h.

§ rate_keys

template<int ntables = 1>
std::vector<std::string> ErrorHandler< ntables >::rate_keys
private

Wether or not to calculate the rates according to the given keys.

Definition at line 203 of file error_handler.h.

§ solution_names

template<int ntables = 1>
const std::string ErrorHandler< ntables >::solution_names
private

Value of solution names.

Definition at line 155 of file error_handler.h.

§ tables

template<int ntables = 1>
std::vector<ConvergenceTable> ErrorHandler< ntables >::tables
private

Error results.

Definition at line 161 of file error_handler.h.

§ types

template<int ntables = 1>
std::vector<std::vector<NormFlags> > ErrorHandler< ntables >::types
private

Type of error to compute per components.

Definition at line 178 of file error_handler.h.

§ write_error

template<int ntables = 1>
bool ErrorHandler< ntables >::write_error
private

Write the error files.

Definition at line 191 of file error_handler.h.


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