OpenFCST: The open-source Fuel Cell Simulation Toolbox
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
simulator_builder.h
Go to the documentation of this file.
1 //---------------------------------------------------------------------------
2 //
3 // FCST: Fuel Cell Simulation Toolbox
4 //
5 // Copyright (C) 2011-13 by Energy Systems Design Laboratory, University of Alberta
6 //
7 // This software is distributed under the MIT License.
8 // For more information, see the README file in /doc/LICENSE
9 //
10 // - Class: simulation_builder.cc
11 // - Description:
12 // - Developers: M. Secanell, P. Dobson, Valentin N. Zingan
13 // - $Id: simulator_builder.h 1444 2013-08-30 21:03:06Z wardlawp $
14 //
15 //---------------------------------------------------------------------------
16 
17 #ifndef SIMULATOR_BUILDER_H
18 #define SIMULATOR_BUILDER_H
19 
20 // STL
21 #include <string>
22 #include <fstream>
23 #include <iostream>
24 #include <vector>
25 #include <ctime>
26 #include <stdlib.h>
27 
28 // Boost
29 #include <boost/smart_ptr.hpp>
30 
31 #include <base/timer.h>
32 #include <base/utilities.h>
33 #include <appframe/base.h>
35 
36 // FCST
38 #include "geometries.h"
39 #include "geometry.h"
40 #include "simulation_selector.h"
41 #include "adaptive_refinement.h"
42 #include "tafel_kinetics.h"
43 #include "FCST_TEST_SUITE.h"
44 
45 #include "dakota_interface.h"
46 // These files can only be used if DAKOTA is linked to our package:
47 #ifdef _WITH_DAKOTA
49 #include "dakota_application.h"
50 #endif
51 
52 //---------------------------------------------------------
53 
72 template <int dim>
74 {
75 public:
76 
81 
86 
91  void usage(int exit_value);
92 
97  void print_logo() const;
98 
102  void print_timer_info() const;
103 
107  void parse_inputs(int argc, char *argv[]);
108 
113  void scan();
114 
120  virtual void run();
121 
122 protected:
123 
134  void declare_parameters(ParameterHandler& param) const;
135 
139  void initialize(ParameterHandler& param);
140 
144  void open_logfile (const std::string&);
145 
159  void run_optimization();
160 
166  void run_test();
167 
171  inline void random_number(double &val, double min, double max)
172  {
173  double rand_num = drand48();
174  val = min + rand_num*(max - min);
175  }
176 
182 
187 
191  bool run_tests;
192 
194  std::string input_file;
195 
197  boost::shared_ptr<std::ofstream> log_file;
198 
203 
242  std::vector<std::string> simulator_parameter_file_names;
243 
247 
252  std::string dakota_results;
253 
258  std::string dakota_parameters;
259 
261  std::string program_name;
262 
264  std::string program_version;
265 
268 
273  ParameterHandler param;
274 
276  boost::shared_ptr <AppFrame::OptimizationBlockMatrixApplication<dim> >app_lin;
277 
279  //boost::shared_ptr <AppFrame::newtonBase> newton;
280  boost::shared_ptr <AppFrame::ApplicationCopy> newton;
281 
285  boost::shared_ptr <AppFrame::AdaptiveRefinement<dim> > solver;
286 
291  boost::shared_ptr< SimulationSelector<dim> > sim_selector;
292 
294  Timer timer;
295 };
296 
297 #endif