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 2605 2014-08-15 03:36:44Z secanell $
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 #include <boost/program_options.hpp>
31 
32 #include <base/timer.h>
33 #include <base/utilities.h>
35 
36 // FCST
38 #include "utils/parametric_study.h"
40 #include "geometries.h"
41 #include "geometry.h"
42 #include "simulation_selector.h"
43 #include "adaptive_refinement.h"
44 #include "agglomerate_ionomer_1D.h"
45 #include "agglomerate_water_1D.h"
46 #include "tafel_kinetics.h"
47 #include "FCST_TEST_SUITE.h"
48 #include <utils/fcst_utilities.h>
49 
50 #include "dakota_interface.h"
51 // These files can only be used if DAKOTA is linked to our package:
52 #ifdef _WITH_DAKOTA
54 #include "dakota_application.h"
55 #endif
56 
57 //---------------------------------------------------------
58 
72 template <int dim>
74 {
75 public:
76 
78 
79 
83 
88 
92  void parse_inputs(int argc, char *argv[]);
93 
98  void scan();
100 
102 
103 
108  virtual void run();
110 
111 protected:
113 
114 
129  void declare_parameters(ParameterHandler& param) const;
130 
134  void initialize(ParameterHandler& param);
135 
140  void open_logfile (const std::string&);
142 
144 
158  void run_optimization();
159 
165  void run_test();
166 
168 
169 
172  void output_default_main();
173 
179  void output_default_other(std::string main_file);
180 
187  void convert_parameters(std::string main_file);
189 
191 
192 
196  void print_logo() const;
197 
201  void print_timer_info() const;
203 
205 
206 
207  const std::string program_name;
208 
210  const std::string program_version;
212 
214 
215 
219  ParameterHandler param;
220 
222  boost::shared_ptr <FuelCell::ApplicationCore::OptimizationBlockMatrixApplication<dim> >app_lin;
223 
225  boost::shared_ptr <FuelCell::ApplicationCore::ApplicationWrapper> newton;
226 
230  boost::shared_ptr <FuelCell::ApplicationCore::AdaptiveRefinement<dim> > solver;
231 
236  boost::shared_ptr< SimulationSelector<dim> > sim_selector;
238 
240 
245  std::string input_file;
246 
257  boost::shared_ptr<std::ofstream> log_file;
258 
264 
288  std::string analysis_type;
294 
296 
297 
300  Timer timer;
302 
304 
305 
310 
315 
319 
324  std::string dakota_results;
325 
330  std::string dakota_parameters;
332 
334 
337 
339 
342 };
343 
344 #endif
boost::shared_ptr< FuelCell::ApplicationCore::ApplicationWrapper > newton
Pointer to the non-linear solver.
Definition: simulator_builder.h:225
void run_optimization()
Set up the required optimization objects (i.e.
std::string dakota_parameters
Variable set in parse_inputs which stores the name of the parameter file if the simulation is being c...
Definition: simulator_builder.h:330
boost::shared_ptr< std::ofstream > log_file
Stores a pointer to the log file object.
Definition: simulator_builder.h:257
void output_default_other(std::string main_file)
Outputs the AdaptiveRefinement and DakotaApplication parameters options to files &quot;data.xml&quot; and &quot;opt.xml&quot; in current working directory.
const std::string program_version
Local variable for the program version.
Definition: simulator_builder.h:210
void print_timer_info() const
Print timer info.
std::string simulator_parameter_file_name
Stores the name of the parameter file containing the physical data for the simulation.
Definition: simulator_builder.h:263
void open_logfile(const std::string &)
Member function used to attach the deal.II logfile to the application and provide the name of the fil...
void initialize(ParameterHandler &param)
Initialize the local variables declared by the parameter handler.
Timer timer
Object used to calculate the CPU and Run time for the simulation.
Definition: simulator_builder.h:300
std::string analysis_type
Decision varible for selecting the type of analysis.
Definition: simulator_builder.h:288
void convert_parameters(std::string main_file)
Opens project specified by /prm file.
This class is used to output data or to initialize and launch simulations.
Definition: simulator_builder.h:73
void print_logo() const
Member function that is used to print information about the program.
boost::shared_ptr< FuelCell::ApplicationCore::OptimizationBlockMatrixApplication< dim > > app_lin
Pointer where linear application is stored.
Definition: simulator_builder.h:222
This application is used to perform a parametric study for a given fuel cell model.
Definition: parametric_study.h:78
std::string input_file
Stores the name of the input file with the application selector data.
Definition: simulator_builder.h:245
const std::string program_name
Local varible for the program name.
Definition: simulator_builder.h:207
bool dakota_use
Variable set in parse_inputs which determines whether the program is being called from DAKOTA...
Definition: simulator_builder.h:309
This application is used to compute the polarization curve for a given fuel cell model.
Definition: polarization_curve.h:101
void scan()
Member function used to call the declaration of the parameters, initialize data and set the applicati...
FuelCell::PolarizationCurve< dim > curve
Polarization curve object.
Definition: simulator_builder.h:335
void run_test()
This routine is mainly used for testing single member functions in classes.
boost::shared_ptr< SimulationSelector< dim > > sim_selector
Object which stores the name of the application and solver Allows the user to select the application ...
Definition: simulator_builder.h:236
bool save_transfer_files
Set to true if you want to keep the mesh and solution from the simulation.
Definition: simulator_builder.h:292
boost::shared_ptr< FuelCell::ApplicationCore::AdaptiveRefinement< dim > > solver
Pointer to a solver application which applies adaptive refinement to the grid.
Definition: simulator_builder.h:230
virtual void run()
Run the simulation.
bool dakota_direct
Decision varible for using the direct dakota interface.
Definition: simulator_builder.h:314
std::string optimization_parameter_file_name
Stores the name of the parameter file containing the optimization data.
Definition: simulator_builder.h:318
~SimulatorBuilder()
Destructor.
ParameterHandler param
Parameter handler object that will be used to store all input data for the application.
Definition: simulator_builder.h:219
void declare_parameters(ParameterHandler &param) const
Declare all necessary parameters to read the input files.
SimulatorBuilder()
Constructor.
void parse_inputs(int argc, char *argv[])
Member function used to read in the command line and initialize the necessary data.
void output_default_main()
Outputs the SimulatorBuilder parameter options to file &quot;main.xml&quot; in current working directory...
FuelCell::ParametricStudy< dim > param_study
Polarization curve object.
Definition: simulator_builder.h:340
std::string dakota_results
Variable set in parse_inputs which stores the name of the results (responses) file if the simulation ...
Definition: simulator_builder.h:324