ug4
ug::MGStats< TDomain, TAlgebra > Class Template Reference

Records statistics on how individual parts of a multigrid method worked. More...

#include <mg_stats.h>

Classes

struct  FuncEntry
 

Public Types

typedef GridFunction< TDomain, TAlgebra > grid_func_t
 
typedef SmartPtr< grid_func_tsp_grid_func_t
 
enum  Stage {
  BEFORE_PRE_SMOOTH , AFTER_PRE_SMOOTH , BEFORE_POST_SMOOTH , AFTER_POST_SMOOTH ,
  INVALID
}
 Defines at which stage data is recorded in a given multigrid cycle. More...
 

Public Member Functions

void clear ()
 clears the current stats More...
 
 MGStats ()
 
void print ()
 prints the current stats More...
 
void save_stats_to_file ()
 saves current stats to filenamePrefix.log More...
 
void save_stats_to_file (const char *filename)
 saves current stats to the specified file More...
 
void set_active_stages (const std::vector< int > &activeStages)
 sets the active stages. All other stages will be ignored. More...
 
void set_defect (grid_func_t &gf, int lvl, Stage stage)
 set the defect on a certain level for a given stage More...
 
void set_exit_on_error (bool exitOnError)
 If enabled, a deterioration of the norm of the defect leads to an error. More...
 
void set_filename_prefix (const char *filename)
 sets the prefix with which files are written More...
 
void set_write_err_diffs (bool writeErrDiffs)
 If enabled, a diff bettween defects involved is written to file if the defect deteriorates. More...
 
void set_write_err_vecs (bool writeErrVecs)
 If enabled, involved defects are written to file if the defect deteriorates. More...
 
const char * stage_name (Stage stage)
 returns the name of a given stage as a string More...
 
const char * stage_norm_name (Stage stage)
 returns the name of the norm of a given stage as a string More...
 

Static Public Attributes

static const int NUM_STAGES = INVALID + 1
 

Private Member Functions

void level_required (int lvl)
 
void write_header (int maxLvl)
 

Private Attributes

bool m_exitOnError
 
std::string m_filenamePrefix
 
std::vector< FuncEntrym_funcs
 
int m_lastLvlWritten
 
int m_maxLvl
 
bool m_stageIsActive [NUM_STAGES]
 
StringTable m_stats
 
int m_statsRow
 
bool m_writeErrDiffs
 
bool m_writeErrVecs
 

Detailed Description

template<typename TDomain, typename TAlgebra>
class ug::MGStats< TDomain, TAlgebra >

Records statistics on how individual parts of a multigrid method worked.

Member Typedef Documentation

◆ grid_func_t

template<typename TDomain , typename TAlgebra >
typedef GridFunction<TDomain, TAlgebra> ug::MGStats< TDomain, TAlgebra >::grid_func_t

◆ sp_grid_func_t

template<typename TDomain , typename TAlgebra >
typedef SmartPtr<grid_func_t> ug::MGStats< TDomain, TAlgebra >::sp_grid_func_t

Member Enumeration Documentation

◆ Stage

template<typename TDomain , typename TAlgebra >
enum ug::MGStats::Stage

Defines at which stage data is recorded in a given multigrid cycle.

Enumerator
BEFORE_PRE_SMOOTH 
AFTER_PRE_SMOOTH 
BEFORE_POST_SMOOTH 
AFTER_POST_SMOOTH 
INVALID 

Constructor & Destructor Documentation

◆ MGStats()

Member Function Documentation

◆ clear()

template<typename TDomain , typename TAlgebra >
void ug::MGStats< TDomain, TAlgebra >::clear

clears the current stats

◆ level_required()

template<typename TDomain , typename TAlgebra >
void ug::MGStats< TDomain, TAlgebra >::level_required ( int  lvl)
private

◆ print()

template<typename TDomain , typename TAlgebra >
void ug::MGStats< TDomain, TAlgebra >::print

prints the current stats

References UG_LOG.

◆ save_stats_to_file() [1/2]

template<typename TDomain , typename TAlgebra >
void ug::MGStats< TDomain, TAlgebra >::save_stats_to_file

saves current stats to filenamePrefix.log

References mkstr.

◆ save_stats_to_file() [2/2]

template<typename TDomain , typename TAlgebra >
void ug::MGStats< TDomain, TAlgebra >::save_stats_to_file ( const char *  filename)

saves current stats to the specified file

References pcl::ProcRank(), and UG_COND_THROW.

◆ set_active_stages()

template<typename TDomain , typename TAlgebra >
void ug::MGStats< TDomain, TAlgebra >::set_active_stages ( const std::vector< int > &  activeStages)

sets the active stages. All other stages will be ignored.

Parameters
activeStagesvector containing constants from MGStats::Stage. Each listed stage will be considered active, all non-listed stages will be ignored.

◆ set_defect()

template<typename TDomain , typename TAlgebra >
void ug::MGStats< TDomain, TAlgebra >::set_defect ( grid_func_t gf,
int  lvl,
Stage  stage 
)

set the defect on a certain level for a given stage

If the defect for the previous stage was set for the same level, norms are compared and a diff can be computed.

If 'exitOnError' is enabled, the method will print the current stats and throw an instance of UGError of the norm of the defect deteriorated.

Note
In parallel environments this method is a synchronization point. Make sure to call it from all processes which hold 'gf'.

References ug::GridFunction< TDomain, TAlgebra >::clone_without_values(), ug::MGStats< TDomain, TAlgebra >::FuncEntry::func, SmartPtr< T, FreePolicy >::invalid(), mkstr, ug::MGStats< TDomain, TAlgebra >::FuncEntry::norm, ug::GridFunction< TDomain, TAlgebra >::num_indices(), print(), ug::SaveVectorDiffForConnectionViewer(), ug::SaveVectorForConnectionViewer(), ug::MGStats< TDomain, TAlgebra >::FuncEntry::stage, ug::MGStats< TDomain, TAlgebra >::FuncEntry::tmpFunc, UG_LOG, and UG_THROW.

◆ set_exit_on_error()

template<typename TDomain , typename TAlgebra >
void ug::MGStats< TDomain, TAlgebra >::set_exit_on_error ( bool  exitOnError)

If enabled, a deterioration of the norm of the defect leads to an error.

disabled by default.

◆ set_filename_prefix()

template<typename TDomain , typename TAlgebra >
void ug::MGStats< TDomain, TAlgebra >::set_filename_prefix ( const char *  filename)

sets the prefix with which files are written

This concerns the log-file and grid-function files. Default is 'mgstats'.

◆ set_write_err_diffs()

template<typename TDomain , typename TAlgebra >
void ug::MGStats< TDomain, TAlgebra >::set_write_err_diffs ( bool  writeErrDiffs)

If enabled, a diff bettween defects involved is written to file if the defect deteriorates.

disabled by default.

◆ set_write_err_vecs()

template<typename TDomain , typename TAlgebra >
void ug::MGStats< TDomain, TAlgebra >::set_write_err_vecs ( bool  writeErrVecs)

If enabled, involved defects are written to file if the defect deteriorates.

disabled by default.

◆ stage_name()

template<typename TDomain , typename TAlgebra >
const char* ug::MGStats< TDomain, TAlgebra >::stage_name ( Stage  stage)
inline

returns the name of a given stage as a string

◆ stage_norm_name()

template<typename TDomain , typename TAlgebra >
const char* ug::MGStats< TDomain, TAlgebra >::stage_norm_name ( Stage  stage)
inline

returns the name of the norm of a given stage as a string

◆ write_header()

template<typename TDomain , typename TAlgebra >
void ug::MGStats< TDomain, TAlgebra >::write_header ( int  maxLvl)
private

References mkstr.

Member Data Documentation

◆ m_exitOnError

template<typename TDomain , typename TAlgebra >
bool ug::MGStats< TDomain, TAlgebra >::m_exitOnError
private

◆ m_filenamePrefix

template<typename TDomain , typename TAlgebra >
std::string ug::MGStats< TDomain, TAlgebra >::m_filenamePrefix
private

◆ m_funcs

template<typename TDomain , typename TAlgebra >
std::vector<FuncEntry> ug::MGStats< TDomain, TAlgebra >::m_funcs
private

◆ m_lastLvlWritten

template<typename TDomain , typename TAlgebra >
int ug::MGStats< TDomain, TAlgebra >::m_lastLvlWritten
private

◆ m_maxLvl

template<typename TDomain , typename TAlgebra >
int ug::MGStats< TDomain, TAlgebra >::m_maxLvl
private

◆ m_stageIsActive

template<typename TDomain , typename TAlgebra >
bool ug::MGStats< TDomain, TAlgebra >::m_stageIsActive[NUM_STAGES]
private

◆ m_stats

template<typename TDomain , typename TAlgebra >
StringTable ug::MGStats< TDomain, TAlgebra >::m_stats
private

◆ m_statsRow

template<typename TDomain , typename TAlgebra >
int ug::MGStats< TDomain, TAlgebra >::m_statsRow
private

◆ m_writeErrDiffs

template<typename TDomain , typename TAlgebra >
bool ug::MGStats< TDomain, TAlgebra >::m_writeErrDiffs
private

◆ m_writeErrVecs

template<typename TDomain , typename TAlgebra >
bool ug::MGStats< TDomain, TAlgebra >::m_writeErrVecs
private

◆ NUM_STAGES

template<typename TDomain , typename TAlgebra >
const int ug::MGStats< TDomain, TAlgebra >::NUM_STAGES = INVALID + 1
static

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