DOpE
Public Member Functions | Static Public Member Functions | Protected Member Functions
DOpE::DOpEOutputHandler< VECTOR > Class Template Reference

#include <optproblemcontainer.h>

Public Member Functions

 DOpEOutputHandler (ReducedProblemInterface_Base< VECTOR > *SI, ParameterReader &param_reader)
 
 ~DOpEOutputHandler ()
 
void WriteAux (std::string msg, std::string file, bool append=true)
 
void Write (std::string msg, int priority=20, unsigned int pre_newlines=0, unsigned int post_newlines=0)
 
void Write (std::stringstream &msg, int priority=20, unsigned int pre_newlines=0, unsigned int post_newlines=0)
 
void Write (const VECTOR &q, std::string name, std::string dof_type)
 
void WriteElementwise (const Vector< double > &q, std::string name, std::string dof_type)
 
void Write (const ControlVector< VECTOR > &q, std::string name, std::string dof_type)
 
void Write (const std::vector< double > &q, std::string name, std::string dof_type)
 
void WriteError (std::string msg)
 
void SetIterationNumber (unsigned int iteration, std::string type)
 
void ReInit ()
 
std::string ZeroTolerance (double value, double reference_value)
 
void InitNewtonOut (std::stringstream &msg)
 
void InitOut (std::stringstream &msg)
 
void DisallowAllOutput ()
 
void ResumeOutput ()
 
std::string ConstructOutputName (std::string name, std::string dof_type)
 
void StartSaveCTypeOutputToLog ()
 
void StopSaveCTypeOutputToLog ()
 
std::string GetResultsDir () const
 

Static Public Member Functions

static void declare_params (ParameterReader &param_reader)
 

Protected Member Functions

std::map< std::string,
unsigned int >::const_iterator 
ReorderAndInsert (std::string type)
 
std::string GetPostIndex ()
 
ReducedProblemInterface_Base
< VECTOR > * 
GetReducedProblem ()
 
bool AllowWrite (std::string name)
 
bool AllowIteration (std::string name)
 
void ParseString (const std::string tmp, std::vector< std::string > &list)
 

Detailed Description

template<typename VECTOR>
class DOpE::DOpEOutputHandler< VECTOR >

This class takes care of all output from the programm. It includes special filter routines on what information is to be displayed, and what vectors should be stored. The filters and output opptions can be configured using a parameter file.

Constructor & Destructor Documentation

template<typename VECTOR >
DOpE::DOpEOutputHandler< VECTOR >::DOpEOutputHandler ( ReducedProblemInterface_Base< VECTOR > *  SI,
ParameterReader param_reader 
)
template<typename VECTOR >
DOpE::DOpEOutputHandler< VECTOR >::~DOpEOutputHandler ( )

Member Function Documentation

template<typename VECTOR >
bool DOpE::DOpEOutputHandler< VECTOR >::AllowIteration ( std::string  name)
protected

This function decides whether or not to store an iteration counter for automatic filename extension. It returns false if the name contains any substring that is given by the parameter file option 'ignore_iterations', otherwise it returns true. If the debug mode is activated via the paramfile, a declined name is noted in the log.

Parameters
nameThe name to be checked
Returns
A boolean that is true if this counter should be stored, and false otherwise.
template<typename VECTOR >
bool DOpE::DOpEOutputHandler< VECTOR >::AllowWrite ( std::string  name)
protected

This function decides whether or not a Vector with the given name should be written. It returns false if the name contains any substring that is given by the parameter file option 'never_write_list', otherwise it returns true. If the debug mode is activated via the paramfile, a declined name is noted in the log.

Parameters
nameThe name to be checked
Returns
A boolean that is true if writing this vector is ok, and false otherwise.
template<typename VECTOR >
std::string DOpE::DOpEOutputHandler< VECTOR >::ConstructOutputName ( std::string  name,
std::string  dof_type 
)

This function constructs the correct output name given by name and dof_type.

template<typename VECTOR >
void DOpE::DOpEOutputHandler< VECTOR >::declare_params ( ParameterReader param_reader)
static

This method must be called prior to instanciation of the object to be able to read the required parameters from the paramfile. Between the call of this function and the instanciation of the OutputHandler param_reader.read_parameters must be called.

template<typename VECTOR>
void DOpE::DOpEOutputHandler< VECTOR >::DisallowAllOutput ( )
inline

This function can be called to disable all output.

template<typename VECTOR >
std::string DOpE::DOpEOutputHandler< VECTOR >::GetPostIndex ( )
protected

This function computes the extension to the file name given by the stored iteration variables.

Returns
The postfix to the filename.
template<typename VECTOR>
ReducedProblemInterface_Base<VECTOR>* DOpE::DOpEOutputHandler< VECTOR >::GetReducedProblem ( )
inlineprotected
template<typename VECTOR >
std::string DOpE::DOpEOutputHandler< VECTOR >::GetResultsDir ( ) const

This function gives the current output directory

template<typename VECTOR >
void DOpE::DOpEOutputHandler< VECTOR >::InitNewtonOut ( std::stringstream &  msg)

This function sets the precision of the newton output values.

template<typename VECTOR >
void DOpE::DOpEOutputHandler< VECTOR >::InitOut ( std::stringstream &  msg)

This function sets the precision of the functional output values.

template<typename VECTOR >
void DOpE::DOpEOutputHandler< VECTOR >::ParseString ( const std::string  tmp,
std::vector< std::string > &  list 
)
protected

This function parses a string into words that are separated by a ';'

Parameters
tmpThe string to be parsed.
listA reference to a vector of strings. All words in the string tmp are beeing stored as a separate string in this list.
template<typename VECTOR >
void DOpE::DOpEOutputHandler< VECTOR >::ReInit ( )

If called this Method initializes a new subdirectory into which the solutions are written. Usually this should be called once on each mesh.

template<typename VECTOR >
std::map< std::string, unsigned int >::const_iterator DOpE::DOpEOutputHandler< VECTOR >::ReorderAndInsert ( std::string  type)
protected

For internal use. This function is used to insert a new iteration counter whose values should be stored. If necessary the counters are reordered.

Parameters
typeThe name of the counter to be stored.
Returns
An iterator pointing onto the position of the newly inserted type.
template<typename VECTOR>
void DOpE::DOpEOutputHandler< VECTOR >::ResumeOutput ( )
inline

This function is used to restore normal output behavior after a call of DisallowAllOutput

template<typename VECTOR >
void DOpE::DOpEOutputHandler< VECTOR >::SetIterationNumber ( unsigned int  iteration,
std::string  type 
)

Sets the iteration number for the automatic file name extension. Whether it is actually used is decided by the AllowIteration method.

Parameters
iterationThe number of the current iteration.
typeA name indicating which iteration the number corresponds to.
template<typename VECTOR >
void DOpE::DOpEOutputHandler< VECTOR >::StartSaveCTypeOutputToLog ( )

Redirects all output to std::cout to the logfile. This is usefull if third party software directly prints output onto the screen.

template<typename VECTOR >
void DOpE::DOpEOutputHandler< VECTOR >::StopSaveCTypeOutputToLog ( )

Disables the redirect of std::cout

template<typename VECTOR >
void DOpE::DOpEOutputHandler< VECTOR >::Write ( std::string  msg,
int  priority = 20,
unsigned int  pre_newlines = 0,
unsigned int  post_newlines = 0 
)

Call this function to write a string both to std::out and into the logfile. If the debug mode is activated via the paramfile, the message is always printed into the log.

Parameters
msgThe message that should be printed.
priorityThe priority of the message. This is used to decide whether the string is actually be printed. By comparing this number with the printlevel given in the paramfile. A message is printed only if priority < printlevel, or if printlevel < 0 As a general rule: priority 0 : Things that must be printed always and can't be turned of. priority 1 : Tell what Major Algorithms are running priority 2 : Things like number of Total Iterations priority 3 : Major subiterations priority 4 : Minor subiteration (e.g ComputeState) priority 5 : Subiteration infos priority 20: Debug Infos
pre_newlinesNumber of empty lines in front of the message.
post_newlinesNumber of empty lines after the message.
template<typename VECTOR >
void DOpE::DOpEOutputHandler< VECTOR >::Write ( std::stringstream &  msg,
int  priority = 20,
unsigned int  pre_newlines = 0,
unsigned int  post_newlines = 0 
)

Call this function to write a stringstream both to std::out and into the logfile. If the debug mode is activated via the paramfile, the message is always printed into the log.

Parameters
msgThe message that should be printed.
priorityThe priority of the message. This is used to decide whether the string is actually be printed. By comparing this number with the printlevel given in the paramfile. A message is printed only if priority < printlevel, or if printlevel < 0 As a general rule: priority 0 : Things that must be printed always and can't be turned of. priority 1 : Tell what Major Algorithms are running priority 2 : Things like number of Total Iterations priority 3 : Major subiterations priority 4 : Minor subiteration (e.g ComputeState) priority 5 : Subiteration infos priority 20: Debug Infos
pre_newlinesNumber of empty lines in front of the message.
post_newlinesNumber of empty lines after the message.
template<typename VECTOR >
void DOpE::DOpEOutputHandler< VECTOR >::Write ( const VECTOR &  q,
std::string  name,
std::string  dof_type 
)

Call this Function to write a BlockVector into a file. The method AllowWrite is called to check if this actually happens. If successfull the filename of the output file will be written with priority 3.

Parameters
qA Reference to the BlockVector to be written.
nameThe Name of the output file (this is what is checked by AllowWrite). The directory, iteration counters and ending are added automatically.
dof_typeA string indicating which dof_handler is associated to the BlockVector. Valid options are 'control' and 'state'
template<typename VECTOR >
void DOpE::DOpEOutputHandler< VECTOR >::Write ( const ControlVector< VECTOR > &  q,
std::string  name,
std::string  dof_type 
)

Call this Function to write a ControlVector into a file. The method AllowWrite is called to check if this actually happens. If successfull the filename of the output file will be written with priority 3.

Parameters
qA Reference to the ControlVector to be written.
nameThe Name of the output file (this is what is checked by AllowWrite). The directory, iteration counters and ending are added automatically.
dof_typeA string indicating which dof_handler is associated to the BlockVector. Valid options are 'control' and 'state'
template<typename VECTOR >
void DOpE::DOpEOutputHandler< VECTOR >::Write ( const std::vector< double > &  q,
std::string  name,
std::string  dof_type 
)

same as above for ControlVector<dealii::Vector<double> > Call this Function to write a std::vector into a file. The method AllowWrite is called to check if this actually happens. If successfull the filename of the output file will be written with priority 3. The output is a gnuplot file.

Parameters
qA Reference to the ControlVector to be written.
nameThe Name of the output file (this is what is checked by AllowWrite). The directory, iteration counters and ending are added automatically.
dof_typeA string indicating which dof_handler is associated to the BlockVector. Valid options are 'time'.
template<typename VECTOR >
void DOpE::DOpEOutputHandler< VECTOR >::WriteAux ( std::string  msg,
std::string  file,
bool  append = true 
)

Call this function to write a string to an auxilliary file

Parameters
msgThe message that should be printed.
fileFilename
appendString appendend to file ?
template<typename VECTOR >
void DOpE::DOpEOutputHandler< VECTOR >::WriteElementwise ( const Vector< double > &  q,
std::string  name,
std::string  dof_type 
)

Call this Function to write a Vector containing element-related data into a file. The method AllowWrite is called to check if this actually happens. If successfull the filename of the output file will be written with priority 3.

Parameters
qA Reference to the Vector to be written.
nameThe Name of the output file (this is what is checked by AllowWrite). The directory, iteration counters and ending are added automatically.
dof_typeA string indicating which dof_handler is associated to the BlockVector. Valid options are 'control' and 'state'.
template<typename VECTOR >
void DOpE::DOpEOutputHandler< VECTOR >::WriteError ( std::string  msg)

Writes an error message to std::cerr and into the Log. This message is printed always regardless of priorities.

Parameters
msgThe message to be printed.
template<typename VECTOR >
std::string DOpE::DOpEOutputHandler< VECTOR >::ZeroTolerance ( double  value,
double  reference_value 
)

Decides if the exact output value is written out or zero (in case if the exact output value is below a certain tolerance.


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