OpenFCST: The open-source Fuel Cell Simulation Toolbox
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
List of all members
SimulatorBuilder< dim > Class Template Reference

This class is used to output data or to initialize and launch simulations. More...

#include <simulator_builder.h>

Public Member Functions

Constructors, destructor, and initalization
 SimulatorBuilder ()
 Constructor. More...
 
 ~SimulatorBuilder ()
 Destructor. More...
 
void parse_inputs (int argc, char *argv[])
 Member function used to read in the command line and initialize the necessary data. More...
 
void scan ()
 Member function used to call the declaration of the parameters, initialize data and set the application and solver objects to those specified in the input file. More...
 
Execute
virtual void run ()
 Run the simulation. More...
 

Protected Member Functions

Initialization (called by scan())
void declare_parameters (ParameterHandler &param) const
 Declare all necessary parameters to read the input files. More...
 
void initialize (ParameterHandler &param)
 Initialize the local variables declared by the parameter handler. More...
 
void open_logfile (const std::string &)
 Member function used to attach the deal.II logfile to the application and provide the name of the file. More...
 
Execution routines (called by run)
void run_optimization ()
 Set up the required optimization objects (i.e. More...
 
void run_test ()
 This routine is mainly used for testing single member functions in classes. More...
 
XML converters:
void output_default_main ()
 Outputs the SimulatorBuilder parameter options to file "main.xml" in current working directory. More...
 
void output_default_other (std::string main_file)
 Outputs the AdaptiveRefinement and DakotaApplication parameters options to files "data.xml" and "opt.xml" in current working directory. More...
 
void convert_file (std::string main_file)
 Opens project specified by main file. More...
 
Print info
void print_logo () const
 Member function that is used to print information about the program. More...
 
void print_timer_info () const
 Print timer info. More...
 

Protected Attributes

Constant parameters
const std::string program_name
 Local varible for the program name. More...
 
const std::string program_version
 Local variable for the program version. More...
 
Objects storing data read from all data files, linear applications and ApplicationWrapper applications
ParameterHandler param
 Parameter handler object that will be used to store all input data for the application. More...
 
boost::shared_ptr
< FuelCell::ApplicationCore::ApplicationData
data
 Data structure storing information to be shared between applications. More...
 
boost::shared_ptr
< FuelCell::ApplicationCore::OptimizationBlockMatrixApplication
< dim > > 
app_lin
 Pointer where linear application is stored. More...
 
boost::shared_ptr
< FuelCell::ApplicationCore::ApplicationWrapper
newton
 Pointer to the non-linear solver. More...
 
boost::shared_ptr
< FuelCell::ApplicationCore::AdaptiveRefinement
< dim > > 
solver
 Pointer to a solver application which applies adaptive refinement to the grid. More...
 
boost::shared_ptr
< SimulationSelector< dim > > 
sim_selector
 Object which stores the name of the application and solver Allows the user to select the application and set objects to the empty pointers. More...
 
File names and general options:
std::string input_file
 Stores the name of the input file with the application selector data. More...
 
boost::shared_ptr< std::ofstream > log_file
 Stores a pointer to the log file object. More...
 
std::string simulator_parameter_file_name
 Stores the name of the parameter file containing the physical data for the simulation. More...
 
std::string analysis_type
 Decision varible for selecting the type of analysis. More...
 
bool save_transfer_files
 Set to true if you want to keep the mesh and solution from the simulation. More...
 
Auxiliary data:
Timer timer
 Object used to calculate the CPU and Run time for the simulation. More...
 
Dakota dependent parameters
bool dakota_use
 Variable set in parse_inputs which determines whether the program is being called from DAKOTA. More...
 
bool dakota_direct
 Decision varible for using the direct dakota interface. More...
 
std::string optimization_parameter_file_name
 Stores the name of the parameter file containing the optimization data. More...
 
std::string dakota_results
 Variable set in parse_inputs which stores the name of the results (responses) file if the simulation is being called from DAKOTA. More...
 
std::string dakota_parameters
 Variable set in parse_inputs which stores the name of the parameter file if the simulation is being called from DAKOTA. More...
 
Polarization curve parameters:
FuelCell::PolarizationCurve< dimcurve
 Polarization curve object. More...
 
Parametric study section:
FuelCell::ParametricStudy< dimparam_study
 Polarization curve object. More...
 

Detailed Description

template<int dim>
class SimulatorBuilder< dim >

This class is used to output data or to initialize and launch simulations.

It reads from the command line either an input file or any other flag and acts accordingly. Based on the flags it will print instructions to screen or setup a simulation.

Note
This is the only class called in main and it manages the problem to be solved.
Author
M. Secanell, P. Wardlaw and P. Dobson.

and the concept of sequential applications and simplified parameter study without Dakota by

Author
Valentin N. Zingan

Constructor & Destructor Documentation

template<int dim>
SimulatorBuilder< dim >::SimulatorBuilder ( )

Constructor.

template<int dim>
SimulatorBuilder< dim >::~SimulatorBuilder ( )

Destructor.

Member Function Documentation

template<int dim>
void SimulatorBuilder< dim >::convert_file ( std::string  main_file)
protected

Opens project specified by main file.

Parameters
main_fileand outputs corresponding "main" "data" and "opt" in current working directory.

Possible options for conversion are xml2prm and prm2xml.

Note
"opt.xml" is only produced if compiling with Dakota and if opt file is found
template<int dim>
void SimulatorBuilder< dim >::declare_parameters ( ParameterHandler &  param) const
protected

Declare all necessary parameters to read the input files.

The following parameters are set here:

  • "Dakota direct": Set to true if you would like to solve an optimization problem using Dakota. Transfer of information between the application and Dakota is via the class DakotaDirectInterface
  • "simulator parameter file name": Specify the file that contains all the application (See the application that you would like to run, e.g. AppCathode)
  • "optimization parameter file name" : Name of the file that specifies all the information related to the optimization class (See DakotaApplication for parameters)
  • "Run tests" : Set to true if you would like to run a single function. This routine can be re-implemented to test different objects without running a full simulation
  • "save transfer files": If set to false the mesh and solution from a parametric study will be deleted.
template<int dim>
void SimulatorBuilder< dim >::initialize ( ParameterHandler &  param)
protected

Initialize the local variables declared by the parameter handler.

template<int dim>
void SimulatorBuilder< dim >::open_logfile ( const std::string &  )
protected

Member function used to attach the deal.II logfile to the application and provide the name of the file.

If no name is given, then the machine hostname is used.

template<int dim>
void SimulatorBuilder< dim >::output_default_main ( )
protected

Outputs the SimulatorBuilder parameter options to file "main.xml" in current working directory.

template<int dim>
void SimulatorBuilder< dim >::output_default_other ( std::string  main_file)
protected

Outputs the AdaptiveRefinement and DakotaApplication parameters options to files "data.xml" and "opt.xml" in current working directory.

Note
"opt.xml" is only produced if compiling with Dakota
template<int dim>
void SimulatorBuilder< dim >::parse_inputs ( int  argc,
char *  argv[] 
)

Member function used to read in the command line and initialize the necessary data.

template<int dim>
void SimulatorBuilder< dim >::print_logo ( ) const
protected

Member function that is used to print information about the program.

The info in print logo appears everytime the program is executed.

template<int dim>
void SimulatorBuilder< dim >::print_timer_info ( ) const
protected

Print timer info.

template<int dim>
virtual void SimulatorBuilder< dim >::run ( )
virtual

Run the simulation.

Determines whether optimization is being used and runs a single simulation or optimization routines

template<int dim>
void SimulatorBuilder< dim >::run_optimization ( )
protected

Set up the required optimization objects (i.e.

  • Dakota::ParallelLibrary: Is where you specify what type of Message Passing Interface (MPI) you would like to run. E.g. Running in "serial mode" single processor, or in "parallel" on multiple processors.
  • Dakota::ProblemDescDB: Stores optimization problem description and optimization strategy
  • DakotaApplication: Manages inputs and sends data to application via DakotaDirectInterface (See DakotaApplication for more detials)
  • DirectApplicInterface: Communicates Dakota parameters to application, sets up application (manages input from Dakota to Application), runs application and results from the Application to Dakota.

It must be a child of Dakota::DirectApplicInterface

http://dakota.sandia.gov/docs/dakota/5.2/html-dev/DakLibrary.html

Low Priority Todo:
Print results to file from direct interface?
template<int dim>
void SimulatorBuilder< dim >::run_test ( )
protected

This routine is mainly used for testing single member functions in classes.

It will run in isolation from the main simulation framework, so that you are not solving a finite element problem.

template<int dim>
void SimulatorBuilder< dim >::scan ( )

Member function used to call the declaration of the parameters, initialize data and set the application and solver objects to those specified in the input file.

Member Data Documentation

template<int dim>
std::string SimulatorBuilder< dim >::analysis_type
protected

Decision varible for selecting the type of analysis.

This variable is set in the input file in:

* subsection Simulator
* set Analysis type =
* end
*

Possible options are:

  • Unit Tests
  • Analysis
  • Parametric Study
  • Polarization Curve
  • Optimization where the options specify the type of study you would like to perform. The options are:
  • Unit Tests: Performs internal tests to make sure openFCST is running correctly.
  • Analysis: Performs an analysis run, i.e. uses the model in simulator name and the provided here to perform an analysis run.
  • Parametric Study: Performs a parameteric study using same values as analysis run and modifying parameter specified in Parametric study.
  • Polarization Curve: Computes a polarization curve using same values as analysis run.
  • Optimization: Solves an optimization problem using the values in the analysis files and the data in Optimization study and within.
template<int dim>
boost::shared_ptr<FuelCell::ApplicationCore::OptimizationBlockMatrixApplication<dim> > SimulatorBuilder< dim >::app_lin
protected

Pointer where linear application is stored.

template<int dim>
FuelCell::PolarizationCurve<dim> SimulatorBuilder< dim >::curve
protected

Polarization curve object.

template<int dim>
bool SimulatorBuilder< dim >::dakota_direct
protected

Decision varible for using the direct dakota interface.

template<int dim>
std::string SimulatorBuilder< dim >::dakota_parameters
protected

Variable set in parse_inputs which stores the name of the parameter file if the simulation is being called from DAKOTA.

template<int dim>
std::string SimulatorBuilder< dim >::dakota_results
protected

Variable set in parse_inputs which stores the name of the results (responses) file if the simulation is being called from DAKOTA.

template<int dim>
bool SimulatorBuilder< dim >::dakota_use
protected

Variable set in parse_inputs which determines whether the program is being called from DAKOTA.

template<int dim>
boost::shared_ptr<FuelCell::ApplicationCore::ApplicationData> SimulatorBuilder< dim >::data
protected

Data structure storing information to be shared between applications.

template<int dim>
std::string SimulatorBuilder< dim >::input_file
protected

Stores the name of the input file with the application selector data.

This value is specified as the argument when you launch openFCST.

template<int dim>
boost::shared_ptr<std::ofstream> SimulatorBuilder< dim >::log_file
protected

Stores a pointer to the log file object.

This value is specified in the main.xml file under section

* subsection Log
*
* end
*
template<int dim>
boost::shared_ptr<FuelCell::ApplicationCore::ApplicationWrapper> SimulatorBuilder< dim >::newton
protected

Pointer to the non-linear solver.

template<int dim>
std::string SimulatorBuilder< dim >::optimization_parameter_file_name
protected

Stores the name of the parameter file containing the optimization data.

template<int dim>
ParameterHandler SimulatorBuilder< dim >::param
protected

Parameter handler object that will be used to store all input data for the application.

template<int dim>
FuelCell::ParametricStudy<dim> SimulatorBuilder< dim >::param_study
protected

Polarization curve object.

template<int dim>
const std::string SimulatorBuilder< dim >::program_name
protected

Local varible for the program name.

template<int dim>
const std::string SimulatorBuilder< dim >::program_version
protected

Local variable for the program version.

template<int dim>
bool SimulatorBuilder< dim >::save_transfer_files
protected

Set to true if you want to keep the mesh and solution from the simulation.

template<int dim>
boost::shared_ptr< SimulationSelector<dim> > SimulatorBuilder< dim >::sim_selector
protected

Object which stores the name of the application and solver Allows the user to select the application and set objects to the empty pointers.

template<int dim>
std::string SimulatorBuilder< dim >::simulator_parameter_file_name
protected

Stores the name of the parameter file containing the physical data for the simulation.

I.e. Fuel cell data.

template<int dim>
boost::shared_ptr<FuelCell::ApplicationCore::AdaptiveRefinement<dim> > SimulatorBuilder< dim >::solver
protected

Pointer to a solver application which applies adaptive refinement to the grid.

template<int dim>
Timer SimulatorBuilder< dim >::timer
protected

Object used to calculate the CPU and Run time for the simulation.


The documentation for this class was generated from the following file: