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 <deal.II/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  if(NULL != Solver_)
260  return Solver_;
261  else
262  {
263  abort();
264  }
265  }
266 
276  bool AllowWrite(std::string name);
286  bool AllowIteration(std::string name);
294  void ParseString(const std::string tmp, std::vector<std::string>& list);
295 
296  private:
297  std::map<std::string, unsigned int> iteration_type_pos_;
298  std::vector<unsigned int> iteration_number_;
299  int printlevel_;
300  std::string results_basedir_, results_outdir_, ending_, control_ending_, logfile_;
302  unsigned int n_reinits_;
303  bool debug_;
304  unsigned int number_precision_;
305  unsigned int functional_number_precision_;
306  double user_eps_machine_;
307  bool disallow_all_;
308 
309  std::vector<std::string> never_write_list;
310  std::vector<std::string> ignore_iterations;
311 
312  std::ofstream log_;
313 
314  fpos_t std_out_pos_;
315  int stdout_backup_;
316 
320  void PrintCopyrightNotice();
321 
322 };
323 
324 }
325 #endif
void ResumeOutput()
Definition: outputhandler.h:218
void ReInit()
Definition: outputhandler.cc:133
void Write(std::string msg, int priority=20, unsigned int pre_newlines=0, unsigned int post_newlines=0)
Definition: outputhandler.cc:276
void WriteAux(std::string msg, std::string file, bool append=true)
Definition: outputhandler.cc:258
void WriteError(std::string msg)
Definition: outputhandler.cc:241
void SetIterationNumber(unsigned int iteration, std::string type)
Definition: outputhandler.cc:149
void StopSaveCTypeOutputToLog()
Definition: outputhandler.cc:592
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:230
Definition: optproblemcontainer.h:70
void DisallowAllOutput()
Definition: outputhandler.h:213
std::string GetPostIndex()
Definition: outputhandler.cc:559
ReducedProblemInterface_Base< VECTOR > * GetReducedProblem()
Definition: outputhandler.h:257
bool AllowWrite(std::string name)
Definition: outputhandler.cc:186
Definition: controlvector.h:49
DOpEOutputHandler(ReducedProblemInterface_Base< VECTOR > *SI, ParameterReader &param_reader)
Definition: outputhandler.cc:59
void StartSaveCTypeOutputToLog()
Definition: outputhandler.cc:572
void WriteElementwise(const Vector< double > &q, std::string name, std::string dof_type)
Definition: outputhandler.cc:500
void ParseString(const std::string tmp, std::vector< std::string > &list)
Definition: outputhandler.cc:165
Definition: outputhandler.h:42
std::string ZeroTolerance(double value, double reference_value)
Definition: outputhandler.cc:455
void InitOut(std::stringstream &msg)
Definition: outputhandler.cc:490
bool AllowIteration(std::string name)
Definition: outputhandler.cc:212
std::string GetResultsDir() const
Definition: outputhandler.cc:607
void InitNewtonOut(std::stringstream &msg)
Definition: outputhandler.cc:483
std::string ConstructOutputName(std::string name, std::string dof_type)
Definition: outputhandler.cc:533
~DOpEOutputHandler()
Definition: outputhandler.cc:123