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:584
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:551
ReducedProblemInterface_Base< VECTOR > * GetReducedProblem()
Definition: outputhandler.h:257
bool AllowWrite(std::string name)
Definition: outputhandler.cc:178
Definition: controlvector.h:49
DOpEOutputHandler(ReducedProblemInterface_Base< VECTOR > *SI, ParameterReader &param_reader)
Definition: outputhandler.cc:59
void StartSaveCTypeOutputToLog()
Definition: outputhandler.cc:564
void WriteElementwise(const Vector< double > &q, std::string name, std::string dof_type)
Definition: outputhandler.cc:492
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:447
void InitOut(std::stringstream &msg)
Definition: outputhandler.cc:482
bool AllowIteration(std::string name)
Definition: outputhandler.cc:204
std::string GetResultsDir() const
Definition: outputhandler.cc:599
void InitNewtonOut(std::stringstream &msg)
Definition: outputhandler.cc:475
std::string ConstructOutputName(std::string name, std::string dof_type)
Definition: outputhandler.cc:525
~DOpEOutputHandler()
Definition: outputhandler.cc:115