Reference documentation for deal.II version 9.4.1
\(\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 | Protected Member Functions | Protected Attributes | List of all members
ConvergenceTable Class Reference

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

Inheritance diagram for ConvergenceTable:
[legend]

Public Types

enum  RateMode { none , reduction_rate , reduction_rate_log2 }
 
enum  TextOutputFormat { table_with_headers , table_with_separate_column_description , simple_table_with_separate_column_description , org_mode_table }
 

Public Member Functions

 ConvergenceTable ()=default
 
void evaluate_convergence_rates (const std::string &data_column_key, const std::string &reference_column_key, const RateMode rate_mode, const unsigned int dim=2)
 
void evaluate_convergence_rates (const std::string &data_column_key, const RateMode rate_mode)
 
void omit_column_from_convergence_rate_evaluation (const std::string &key)
 
void evaluate_all_convergence_rates (const std::string &reference_column_key, const RateMode rate_mode)
 
void evaluate_all_convergence_rates (const RateMode rate_mode)
 
void declare_column (const std::string &key)
 
template<typename T >
void add_value (const std::string &key, const T value)
 
void start_new_row ()
 
void set_auto_fill_mode (const bool state)
 
void add_column_to_supercolumn (const std::string &key, const std::string &superkey)
 
void set_column_order (const std::vector< std::string > &new_order)
 
void set_precision (const std::string &key, const unsigned int precision)
 
void set_scientific (const std::string &key, const bool scientific)
 
void set_tex_caption (const std::string &key, const std::string &tex_caption)
 
void set_tex_table_caption (const std::string &table_caption)
 
void set_tex_table_label (const std::string &table_label)
 
void set_tex_supercaption (const std::string &superkey, const std::string &tex_supercaption)
 
void set_tex_format (const std::string &key, const std::string &format="c")
 
void write_text (std::ostream &out, const TextOutputFormat format=table_with_headers) const
 
void write_tex (std::ostream &file, const bool with_header=true) const
 
void clear ()
 
void clear_current_row ()
 
template<class Archive >
void serialize (Archive &ar, const unsigned int version)
 

Static Public Member Functions

static ::ExceptionBaseExcRateColumnAlreadyExists (std::string arg1)
 
static ::ExceptionBaseExcColumnNotExistent (std::string arg1)
 
static ::ExceptionBaseExcSuperColumnNotExistent (std::string arg1)
 
static ::ExceptionBaseExcColumnOrSuperColumnNotExistent (std::string arg1)
 
static ::ExceptionBaseExcWrongNumberOfDataEntries (std::string arg1, int arg2, std::string arg3, int arg4)
 
static ::ExceptionBaseExcUndefinedTexFormat (std::string arg1)
 

Protected Member Functions

void get_selected_columns (std::vector< std::string > &sel_columns) const
 
unsigned int n_rows () const
 

Protected Attributes

std::vector< std::string > column_order
 
std::map< std::string, Columncolumns
 
std::map< std::string, std::vector< std::string > > supercolumns
 
std::map< std::string, std::string > tex_supercaptions
 
std::string tex_table_caption
 
std::string tex_table_label
 
bool auto_fill_mode
 

Detailed Description

The ConvergenceTable class is an application to the TableHandler class and stores some convergence data, such as residuals of the cg-method, or some evaluated L2-errors of discrete solutions, etc, and evaluates convergence rates or orders.

The already implemented RateMode's are reduction_rate, where the convergence rate is the quotient of two following rows, and reduction_rate_log2, that evaluates the order of convergence. These standard evaluations are useful for global refinement, for local refinement this may not be an appropriate method, as the convergence rates should be set in relation to the number of cells or the number of DoFs. The implementations of these non-standard methods is left to a user.

For example, the number of cells may be added to the table by calling add_value("n cells", n_cells). The number of DoFs may be added to the table by calling add_value("n dofs", n_dofs). Of course, one can also add more kinds of information by calling add_value() with other arguments. In any case, before the output of the table the functions evaluate_convergence_rates() and evaluate_all_convergence_rates() may be called.

There are two possibilities of how to evaluate the convergence rates of multiple columns in the same RateMode.

  1. call evaluate_convergence_rates() for all wanted columns
  2. call omit_column_from_convergence_rate_evaluation() for all columns for which this evaluation is not desired and then evaluate_all_convergence_rates() to evaluate the convergence rates of all columns that have not been flagged for omission.

A detailed discussion of this class can also be found in the step-7 and step-13 example programs. It is also used in step-74.

Definition at line 64 of file convergence_table.h.

Member Enumeration Documentation

◆ RateMode

Rate in relation to the rows.

Enumerator
none 

Do not do anything.

reduction_rate 

Quotient of values in the previous row and in this row.

reduction_rate_log2 

Logarithm of reduction_rate to the base 2 representing the order of convergence when halving the grid size, e.g. from h to h/2.

Definition at line 75 of file convergence_table.h.

◆ TextOutputFormat

Set of options how a table should be formatted when output with the write_text() function. The following possibilities exist:

  • table_with_headers: The table is formatted in such a way that the contents are aligned under the key of each column, i.e. the key sits atop each column. This is suitable for tables with few columns where the entire table can be displayed on the screen. Output looks like this:
    key1 key2 key3
    0 0 ""
    1 0 ""
    2 13 a
    1 0 ""
  • table_with_separate_column_description: This is a better format when there are many columns and the table as a whole can not be displayed on the screen. Here, the column keys are first listed one-by- one on lines of their own, and are numbered for better readability. In addition, each of these description lines are prefixed by '#' to mark these lines as comments for programs that want to read the following table as data and should ignore these descriptive lines. GNUPLOT is one such program that will automatically ignore lines so prefixed. Output with this option looks like this:
    # 1: key1
    # 2: key2
    # 3: key3
    0 0 ""
    1 0 ""
    2 13 a
    1 0 ""
  • simple_table_with_separate_column_description: This format is very similar to table_with_separate_column_description, but it skips aligning the columns with additional white space. This increases the performance of write_text() for large tables. Example output:
    # 1: key1
    # 2: key2
    # 3: key3
    0 0 ""
    1 0 ""
    2 13 a
    1 0 ""
  • org_mode_table: Outputs to org-mode (http://orgmode.org/) table format. It is easy to convert org-mode tables to HTML/LaTeX/csv. Example output:
    | key1 | key2 | key3 |
    | 0 | 0 | "" |
    | 1 | 0 | "" |
    | 2 | 13 | a |
    | 1 | 0 | "" |
Enumerator
table_with_headers 

Print the table with headers.

table_with_separate_column_description 

Print the table with separate lines for each column label.

simple_table_with_separate_column_description 

Like table_with_separate_column_description, but without aligning the column containing the column labels.

org_mode_table 

Print the table in org mode format.

Definition at line 356 of file table_handler.h.

Constructor & Destructor Documentation

◆ ConvergenceTable()

ConvergenceTable::ConvergenceTable ( )
default

Constructor.

Member Function Documentation

◆ evaluate_convergence_rates() [1/2]

void ConvergenceTable::evaluate_convergence_rates ( const std::string &  data_column_key,
const std::string &  reference_column_key,
const RateMode  rate_mode,
const unsigned int  dim = 2 
)

Evaluate the convergence rates of the data column data_column_key due to the RateMode in relation to the reference column reference_column_key. Be sure that the value types of the table entries of the data column and the reference data column is a number, i.e. double, float, (unsigned) int, and so on.

As this class has no information on the space dimension upon which the reference column vs. the value column is based upon, it needs to be passed as last argument to this method. The default dimension for the reference column is 2, which is appropriate for the number of cells in 2D. If you work in 3D, set the number to 3. If the reference column is \(1/h\), remember to set the dimension to 1 also when working in 3D to get correct rates.

The new rate column and the data column will be merged to a supercolumn. The tex caption of the supercolumn will be (by default) the same as the one of the data column. This may be changed by using the set_tex_supercaption (...) function of the base class TableHandler.

This method behaves in the following way:

If RateMode is reduction_rate, then the computed output is \( \frac{e_{n-1}/k_{n-1}}{e_n/k_n}, \) where \(k\) is the reference column (no dimension dependence!).

If RateMode is reduction_rate_log2, then the computed output is \( dim \frac{\log |e_{n-1}/e_{n}|}{\log |k_n/k_{n-1}|} \).

This is useful, for example, if we use as reference key the number of degrees of freedom or better, the number of cells. Assuming that the error is proportional to \( C (1/\sqrt{k})^r \) in 2D, then this method will produce the rate \(r\) as a result. For general dimension, as described by the last parameter of this function, the formula needs to be \( C (1/\sqrt[dim]{k})^r \).

Note
Since this function adds columns to the table after several rows have already been filled, it switches off the auto fill mode of the TableHandler base class. If you intend to add further data with auto fill, you will have to re-enable it after calling this function.

Definition at line 23 of file convergence_table.cc.

◆ evaluate_convergence_rates() [2/2]

void ConvergenceTable::evaluate_convergence_rates ( const std::string &  data_column_key,
const RateMode  rate_mode 
)

Evaluate the convergence rates of the data column data_column_key due to the RateMode. Be sure that the value types of the table entries of the data column is a number, i.e. double, float, (unsigned) int, and so on.

The new rate column and the data column will be merged to a supercolumn. The tex caption of the supercolumn will be (by default) the same as the one of the data column. This may be changed by using the set_tex_supercaption() function of the base class TableHandler.

Note
Since this function adds columns to the table after several rows have already been filled, it switches off the auto fill mode of the TableHandler base class. If you intend to add further data with auto fill, you will have to re-enable it after calling this function.

Definition at line 127 of file convergence_table.cc.

◆ omit_column_from_convergence_rate_evaluation()

void ConvergenceTable::omit_column_from_convergence_rate_evaluation ( const std::string &  key)

Omit this column key (not supercolumn!) from the evaluation of the convergence rates of ‘all’ columns (see the following two functions).

The Column::flag==1 is reserved for omitting the column from convergence rate evaluation.

Definition at line 218 of file convergence_table.cc.

◆ evaluate_all_convergence_rates() [1/2]

void ConvergenceTable::evaluate_all_convergence_rates ( const std::string &  reference_column_key,
const RateMode  rate_mode 
)

Evaluate convergence rates due to the rate_mode in relation to the reference column reference_column_key. This function evaluates the rates of ALL columns except of the columns that are to be omitted (see previous function) and except of the columns that are previously evaluated rate columns. This function allows to evaluate the convergence rate for almost all columns of a table without calling evaluate_convergence_rates() for each column separately.

Example: Columns like n cells or n dofs columns may be wanted to be omitted in the evaluation of the convergence rates. Hence they should omitted by calling the omit_column_from_convergence_rate_evaluation().

Definition at line 230 of file convergence_table.cc.

◆ evaluate_all_convergence_rates() [2/2]

void ConvergenceTable::evaluate_all_convergence_rates ( const RateMode  rate_mode)

Evaluate convergence rates due to the rate_mode. This function evaluates the rates of ALL columns except of the columns that are to be omitted (see previous function) and except of the columns that are previously evaluated rate columns. This function allows to evaluate the convergence rate for almost all columns of a table without calling evaluate_convergence_rates() for each column separately.

Example: Columns like n cells or n dofs columns may be wanted to be omitted in the evaluation of the convergence rates. Hence they should omitted by calling the omit_column_from_convergence_rate_evaluation().

Definition at line 246 of file convergence_table.cc.

◆ declare_column()

void TableHandler::declare_column ( const std::string &  key)
inherited

Declare the existence of a column in the table by giving it a name. As discussed in the documentation of the class, this is not usually necessary – just adding a value for a given column key via the add_value() function also declares the column. This function is therefore only necessary in cases where you want a column to also show up even if you never add an entry to any row in this column; or, more likely, if you want to prescribe the order in which columns are later printed by declaring columns in a particular order before entries are ever put into them.

(The latter objective can also be achieved by adding entries to the table in whatever order they are produced by a program, and later calling set_column_order(). However, this approach requires knowing – in one central place of your software – all of the columns keys that other parts of the software have written into, and how they should be sorted. This is easily possible for small programs, but may not be feasible for large code bases in which parts of the code base are only executed based on run-time parameters.)

Definition at line 219 of file table_handler.cc.

◆ add_value()

template<typename T >
void TableHandler::add_value ( const std::string &  key,
const T  value 
)
inherited

Adds a column (if not yet existent) with the key key and adds the value of type T to the column. Values of type T must be convertible to one of int, unsigned int, double, std::uint64_t, std::string or a compiler error will result.

Definition at line 948 of file table_handler.h.

◆ start_new_row()

void TableHandler::start_new_row ( )
inherited

If a row is only partially filled, then set all elements of that row for which no elements exist in a particular column to the empty string. This is akin to the 'auto_fill_mode' described in the introduction, but more general because it allows you to start writing into a column for a new row without having to know that that column had been written to in the previous row.

If all columns have been written into in the current row, then this function doesn't do anything at all. In other words, conceptually the function "completes" the current row, though its use case is to "start" a new row.

Definition at line 233 of file table_handler.cc.

◆ set_auto_fill_mode()

void TableHandler::set_auto_fill_mode ( const bool  state)
inherited

Switch auto-fill mode on or off. See the general documentation of this class for a description of what auto-fill mode does.

Definition at line 259 of file table_handler.cc.

◆ add_column_to_supercolumn()

void TableHandler::add_column_to_supercolumn ( const std::string &  key,
const std::string &  superkey 
)
inherited

Creates a supercolumn (if not yet existent) and includes column to it. The keys of the column and the supercolumn are key and superkey, respectively. To merge two columns c1 and c2 to a supercolumn sc hence call add_column_to_supercolumn(c1,sc) and add_column_to_supercolumn(c2,sc).

Concerning the order of the columns, the supercolumn replaces the first column that is added to the supercolumn. Within the supercolumn the order of output follows the order the columns are added to the supercolumn.

Definition at line 266 of file table_handler.cc.

◆ set_column_order()

void TableHandler::set_column_order ( const std::vector< std::string > &  new_order)
inherited

Change the order of columns and supercolumns in the table.

new_order includes the keys and superkeys of the columns and supercolumns in the order the user would like them to be output. If a superkey is included the keys of the subcolumns need not be explicitly mentioned in this vector. The order of subcolumns within a supercolumn is not changeable and remains in the order in which the columns are added to the supercolumn.

This function may also be used to break big tables with too many columns into smaller ones. For example, you can call this function with the first five columns and then call one of the write_* functions, then call this function with the next five columns and again write_*, and so on.

Definition at line 310 of file table_handler.cc.

◆ set_precision()

void TableHandler::set_precision ( const std::string &  key,
const unsigned int  precision 
)
inherited

Set the precision e.g. double or float variables are written with. precision is the same as in calling out<<setprecision(precision).

Definition at line 373 of file table_handler.cc.

◆ set_scientific()

void TableHandler::set_scientific ( const std::string &  key,
const bool  scientific 
)
inherited

Set the scientific_flag. True means scientific, false means fixed point notation.

Definition at line 386 of file table_handler.cc.

◆ set_tex_caption()

void TableHandler::set_tex_caption ( const std::string &  key,
const std::string &  tex_caption 
)
inherited

Set the caption of the column key for tex output. You may want to chose this different from key, if it contains formulas or similar constructs.

Definition at line 324 of file table_handler.cc.

◆ set_tex_table_caption()

void TableHandler::set_tex_table_caption ( const std::string &  table_caption)
inherited

Set the tex caption of the entire table for tex output.

Definition at line 334 of file table_handler.cc.

◆ set_tex_table_label()

void TableHandler::set_tex_table_label ( const std::string &  table_label)
inherited

Set the label of this table for tex output.

Definition at line 342 of file table_handler.cc.

◆ set_tex_supercaption()

void TableHandler::set_tex_supercaption ( const std::string &  superkey,
const std::string &  tex_supercaption 
)
inherited

Set the caption the supercolumn superkey for tex output. You may want to chose this different from superkey, if it contains formulas or similar constructs.

Definition at line 350 of file table_handler.cc.

◆ set_tex_format()

void TableHandler::set_tex_format ( const std::string &  key,
const std::string &  format = "c" 
)
inherited

Set the tex output format of a column, e.g. c, r, l, or p{3cm}. The default is c. Also if this function is not called for a column, the default is preset to be c.

Definition at line 361 of file table_handler.cc.

◆ write_text()

void TableHandler::write_text ( std::ostream &  out,
const TextOutputFormat  format = table_with_headers 
) const
inherited

Write table as formatted text to the given stream. The text is formatted in such as way that it represents data as formatted columns of text. To avoid problems when reading these tables automatically, for example for postprocessing, if an entry in a cell of this table is empty (i.e. it has been created by calling the add_value() function with an empty string), then the entry of the table is printed as "".

The second argument indicates how column keys are to be displayed. See the description of TextOutputFormat for more information.

Definition at line 398 of file table_handler.cc.

◆ write_tex()

void TableHandler::write_tex ( std::ostream &  file,
const bool  with_header = true 
) const
inherited

Write table as a tex file. If with_header is set to false, then no \documentclass{...}, \begin{document} and \end{document} are used. In this way the file can be included into an existing tex file using a command like \input{table_file}.

Definition at line 614 of file table_handler.cc.

◆ clear()

void TableHandler::clear ( )
inherited

Clear the rows of the table, i.e. calls clear() on all the underlying storage data structures.

Definition at line 760 of file table_handler.cc.

◆ clear_current_row()

void TableHandler::clear_current_row ( )
inherited

Remove all values added at the current row. This is useful when, for example, a time-step is rejected and all data recorded about it needs to be discarded.

Definition at line 825 of file table_handler.cc.

◆ serialize()

template<class Archive >
void TableHandler::serialize ( Archive &  ar,
const unsigned int  version 
)
inherited

Read or write the data of this object to or from a stream for the purpose of serialization using the BOOST serialization library.

Definition at line 1007 of file table_handler.h.


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