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 //
14 //---------------------------------------------------------------------------
15 
16 #ifndef SIMULATOR_BUILDER_H
17 #define SIMULATOR_BUILDER_H
18 
19 // STL
20 #include <fstream>
21 #include <vector>
22 #include <ctime>
23 #include <stdlib.h>
24 
25 // Boost
26 #include <boost/smart_ptr.hpp>
27 #include <boost/program_options.hpp>
28 
29 // deal.II
30 #include <deal.II/base/timer.h>
31 #include <deal.II/base/utilities.h>
32 
33 // FCST
35 #include <utils/parametric_study.h>
36 #include <grid/geometries.h>
37 #include <grid/geometry.h>
42 #include "FCST_TEST_SUITE.h"
43 #include <utils/fcst_utilities.h>
44 
46 // These files can only be used if DAKOTA is linked to our package:
47 #ifdef _WITH_DAKOTA
50 #endif
51 
52 //---------------------------------------------------------
57 {
58  NONE = 0,
61 };
62 
76 template <int dim>
78 {
79 public:
80 
82 
83 
87 
92 
96  void parse_inputs(int argc, char *argv[]);
97 
102  void scan();
104 
106 
107 
112  virtual void run();
114 
115 protected:
117 
118 
133  void declare_parameters(ParameterHandler& param) const;
134 
138  void initialize(ParameterHandler& param);
139 
144  void open_logfile (const std::string&);
146 
148 
162  void run_optimization();
163 
169  void run_test();
170 
172 
173 
176  void output_default_main();
177 
183  void output_default_other(std::string main_file);
184 
193  void convert_file(std::string main_file);
195 
197 
198 
202  void print_logo() const;
203 
207  void print_timer_info() const;
209 
211 
212 
213  const std::string program_name;
214 
216  const std::string program_version;
218 
220 
221 
225  ParameterHandler param;
226 
230  boost::shared_ptr <FuelCell::ApplicationCore::ApplicationData> data;
231 
233  boost::shared_ptr <FuelCell::ApplicationCore::OptimizationBlockMatrixApplication<dim> >app_lin;
234 
236  boost::shared_ptr <FuelCell::ApplicationCore::ApplicationWrapper> newton;
237 
241  boost::shared_ptr <FuelCell::ApplicationCore::AdaptiveRefinement<dim> > solver;
242 
247  boost::shared_ptr< SimulationSelector<dim> > sim_selector;
249 
251 
256  std::string input_file;
257 
268  boost::shared_ptr<std::ofstream> log_file;
269 
275 
299  std::string analysis_type;
305 
307 
308 
311  Timer timer;
313 
315 
316 
321 
326 
330 
335  std::string dakota_results;
336 
341  std::string dakota_parameters;
343 
345 
348 
350 
353 };
354 
355 #endif
boost::shared_ptr< FuelCell::ApplicationCore::ApplicationWrapper > newton
Pointer to the non-linear solver.
Definition: simulator_builder.h:236
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:341
boost::shared_ptr< std::ofstream > log_file
Stores a pointer to the log file object.
Definition: simulator_builder.h:268
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:216
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:274
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...
boost::shared_ptr< FuelCell::ApplicationCore::ApplicationData > data
Data structure storing information to be shared between applications.
Definition: simulator_builder.h:230
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:311
Definition: simulator_builder.h:58
std::string analysis_type
Decision varible for selecting the type of analysis.
Definition: simulator_builder.h:299
This class is used to output data or to initialize and launch simulations.
Definition: simulator_builder.h:77
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:233
This application is used to perform a parametric study for a given fuel cell model.
Definition: parametric_study.h:96
std::string input_file
Stores the name of the input file with the application selector data.
Definition: simulator_builder.h:256
const std::string program_name
Local varible for the program name.
Definition: simulator_builder.h:213
bool dakota_use
Variable set in parse_inputs which determines whether the program is being called from DAKOTA...
Definition: simulator_builder.h:320
Definition: simulator_builder.h:59
void convert_file(std::string main_file)
Opens project specified by main file.
This application is used to compute the polarization curve for a given fuel cell model.
Definition: polarization_curve.h:101
Definition: simulator_builder.h:60
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:346
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:247
bool save_transfer_files
Set to true if you want to keep the mesh and solution from the simulation.
Definition: simulator_builder.h:303
boost::shared_ptr< FuelCell::ApplicationCore::AdaptiveRefinement< dim > > solver
Pointer to a solver application which applies adaptive refinement to the grid.
Definition: simulator_builder.h:241
virtual void run()
Run the simulation.
bool dakota_direct
Decision varible for using the direct dakota interface.
Definition: simulator_builder.h:325
std::string optimization_parameter_file_name
Stores the name of the parameter file containing the optimization data.
Definition: simulator_builder.h:329
~SimulatorBuilder()
Destructor.
ParameterHandler param
Parameter handler object that will be used to store all input data for the application.
Definition: simulator_builder.h:225
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.
FileConversionOption
Definition: simulator_builder.h:56
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:351
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:335