DOpE
outputhandler.h
Go to the documentation of this file.
1 
24 #ifndef _DOPE_OUTPUT_HANDLER_H_
25 #define _DOPE_OUTPUT_HANDLER_H_
26 
27 #include <iostream>
28 #include <fstream>
29 #include <string>
30 #include <map>
31 #include <vector>
32 #include <sstream>
33 #include <lac/vector.h>
34 
35 #include "optproblemcontainer.h"
36 #include "controlvector.h"
37 #include "parameterreader.h"
38 
39 namespace DOpE
40 {
41 //Predeclaration necessary
42 template<typename VECTOR> class ReducedProblemInterface_Base;
44 
52 template<typename VECTOR>
54 {
55  public:
56 
59 
65  static void declare_params(ParameterReader &param_reader);
66 
74  void WriteAux(std::string msg, std::string file, bool append=true);
75 
96  void Write(std::string msg, int priority = 20, unsigned int pre_newlines = 0,
97  unsigned int post_newlines = 0);
118  void Write(std::stringstream& msg, int priority = 20, unsigned int pre_newlines = 0,
119  unsigned int post_newlines = 0);
130  void Write(const VECTOR&q, std::string name, std::string dof_type);
131 
143  void
144  WriteElementwise(const Vector<double>&q, std::string name,
145  std::string dof_type);
146 
157  void Write(const ControlVector<VECTOR>& q, std::string name, std::string dof_type);
158  // /**
159  // * same as above for ControlVector<dealii::Vector<double> >
160  // *
161  // */
162  // void Write(const ControlVector<dealii::Vector<double> >& q, std::string name, std::string dof_type);
174  void Write(const std::vector<double>& q, std::string name, std::string dof_type);
181  void WriteError(std::string msg);
189  void SetIterationNumber(unsigned int iteration, std::string type);
194  void ReInit();
200  std::string ZeroTolerance(double value, double reference_value);
204  void InitNewtonOut(std::stringstream& msg);
208  void InitOut(std::stringstream& msg);
209 
213  void DisallowAllOutput() { _disallow_all = true; };
218  void ResumeOutput() { _disallow_all = false; }
219 
223  std::string
224  ConstructOutputName(std::string name, std::string dof_type);
225 
236 
240  std::string GetResultsDir() const;
241 
242  protected:
250  std::map<std::string, unsigned int>::const_iterator ReorderAndInsert(std::string type);
256  std::string GetPostIndex();
258  {
259  return _Solver;
260  }
261 
271  bool AllowWrite(std::string name);
281  bool AllowIteration(std::string name);
289  void ParseString(const std::string tmp, std::vector<std::string>& list);
290 
291  private:
292  std::map<std::string, unsigned int> _iteration_type_pos;
293  std::vector<unsigned int> _iteration_number;
294  int _printlevel;
295  std::string _results_basedir, _results_outdir, _ending, _control_ending, _logfile;
297  unsigned int _n_reinits;
298  bool _debug;
299  unsigned int _number_precision;
300  unsigned int _functional_number_precision;
301  double _user_eps_machine;
302  bool _disallow_all;
303 
304  std::vector<std::string> never_write_list;
305  std::vector<std::string> ignore_iterations;
306 
307  std::ofstream _log;
308 
309  fpos_t _std_out_pos;
310  int _stdout_backup;
311 
315  void PrintCopyrightNotice();
316 
317 };
318 
319 }
320 #endif
void ResumeOutput()
Definition: outputhandler.h:218
void ReInit()
Definition: outputhandler.cc:125
void Write(std::string msg, int priority=20, unsigned int pre_newlines=0, unsigned int post_newlines=0)
Definition: outputhandler.cc:268
void WriteAux(std::string msg, std::string file, bool append=true)
Definition: outputhandler.cc:250
void WriteError(std::string msg)
Definition: outputhandler.cc:233
void SetIterationNumber(unsigned int iteration, std::string type)
Definition: outputhandler.cc:141
void StopSaveCTypeOutputToLog()
Definition: outputhandler.cc:601
static void declare_params(ParameterReader &param_reader)
Definition: outputhandler.cc:40
Definition: parameterreader.h:36
std::map< std::string, unsigned int >::const_iterator ReorderAndInsert(std::string type)
Definition: outputhandler.cc:222
Definition: optproblemcontainer.h:70
void DisallowAllOutput()
Definition: outputhandler.h:213
std::string GetPostIndex()
Definition: outputhandler.cc:568
ReducedProblemInterface_Base< VECTOR > * GetReducedProblem()
Definition: outputhandler.h:257
bool AllowWrite(std::string name)
Definition: outputhandler.cc:178
Definition: controlvector.h:48
DOpEOutputHandler(ReducedProblemInterface_Base< VECTOR > *SI, ParameterReader &param_reader)
Definition: outputhandler.cc:59
void StartSaveCTypeOutputToLog()
Definition: outputhandler.cc:581
void WriteElementwise(const Vector< double > &q, std::string name, std::string dof_type)
Definition: outputhandler.cc:509
void ParseString(const std::string tmp, std::vector< std::string > &list)
Definition: outputhandler.cc:157
Definition: outputhandler.h:42
std::string ZeroTolerance(double value, double reference_value)
Definition: outputhandler.cc:464
void InitOut(std::stringstream &msg)
Definition: outputhandler.cc:499
bool AllowIteration(std::string name)
Definition: outputhandler.cc:204
std::string GetResultsDir() const
Definition: outputhandler.cc:616
void InitNewtonOut(std::stringstream &msg)
Definition: outputhandler.cc:492
std::string ConstructOutputName(std::string name, std::string dof_type)
Definition: outputhandler.cc:542
~DOpEOutputHandler()
Definition: outputhandler.cc:115