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

This class is used to initialize and launch simulations or optimization routines. More...

#include <simulator_builder.h>

Public Member Functions

 SimulatorBuilder ()
 Constructor.
 
 ~SimulatorBuilder ()
 Destructor.
 
void usage (int exit_value)
 Message that is printed to screen if the program is run without any flags and input files.
 
void print_logo () const
 Member function that is used to print information about the program.
 
void print_timer_info () const
 Print timer info.
 
void parse_inputs (int argc, char *argv[])
 Member function used to read in the command line and initialize the necessary data.
 
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.
 
virtual void run ()
 Run the simulation.
 

Protected Member Functions

void declare_parameters (ParameterHandler &param) const
 Declare all necessary parameters to read the input files The following parameters are set here:
 
void initialize (ParameterHandler &param)
 Initialize the local variables declared by the parameter handler.
 
void open_logfile (const std::string &)
 
void run_optimization ()
 Set up the required optimization objects (i.e.
 
void run_test ()
 This routine is mainly used for testing single member functions in classes.
 
void random_number (double &val, double min, double max)
 Returns a random number in val argument.
 

Protected Attributes

bool dakota_use
 Variable set in parse_inputs which determines whether the program is being called from DAKOTA.
 
bool dakota_direct
 Decision varible for using the direct dakota interface.
 
bool run_tests
 Decision varible for running tests.
 
std::string input_file
 Stores the name of the input file with the application selector data.
 
boost::shared_ptr< std::ofstream > log_file
 Stores the name of the log file.
 
std::string simulator_parameter_file_name
 Stores the name of the parameter file containing the physical data for the simulation.
 
std::vector< std::string > simulator_parameter_file_names
 This vector stores the names of the parameter files containing the physical data for the same simulation.
 
std::string optimization_parameter_file_name
 Stores the name of the parameter file containing the optimization data.
 
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.
 
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.
 
std::string program_name
 Local varible for the program name.
 
std::string program_version
 Local variable for the program version.
 
bool save_transfer_files
 Set to true if you want to keep the mesh and solution from the simulation.
 
ParameterHandler param
 Parameter handler object that will be used to store all input data for the application.
 
boost::shared_ptr
< AppFrame::OptimizationBlockMatrixApplication
< dim > > 
app_lin
 Pointer where linear application is stored.
 
boost::shared_ptr
< AppFrame::ApplicationCopy
newton
 Pointer to the non-linear solver.
 
boost::shared_ptr
< AppFrame::AdaptiveRefinement
< dim > > 
solver
 Pointer to a solver application which applies adaptive refinement to the grid.
 
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.
 
Timer timer
 Object used to calculate the CPU and Run time for the simulation.
 

Detailed Description

template<int dim>
class SimulatorBuilder< dim >

This class is used to initialize and launch simulations or optimization routines.

Author
P. Dobson, M. Secanell, Ali M. Koupaei

and the concept of sequential applications by

Author
Valentin N. Zingan

$Header$ This class is used to read from the command line the input file and any other flags. Based on the flags it will print instructions to screen or setup a simulation.

This is the only class called in main and it manages the problem to be solved.

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 >::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. TO DO: Create filters for the input parameters
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
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

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

Print timer info.

template<int dim>
void SimulatorBuilder< dim >::random_number ( double &  val,
double  min,
double  max 
)
inlineprotected

Returns a random number in val argument.

The number will be between min and max.

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.

template<int dim>
void SimulatorBuilder< dim >::usage ( int  exit_value)

Message that is printed to screen if the program is run without any flags and input files.

The usage message explain the flabs avaiable and how they work

Member Data Documentation

template<int dim>
boost::shared_ptr<AppFrame::OptimizationBlockMatrixApplication<dim> > SimulatorBuilder< dim >::app_lin
protected

Pointer where linear application is stored.

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>
std::string SimulatorBuilder< dim >::input_file
protected

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

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

Stores the name of the log file.

template<int dim>
boost::shared_ptr<AppFrame::ApplicationCopy> 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>
std::string SimulatorBuilder< dim >::program_name
protected

Local varible for the program name.

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

Local variable for the program version.

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

Decision varible for running tests.

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>
std::vector<std::string> SimulatorBuilder< dim >::simulator_parameter_file_names
protected

This vector stores the names of the parameter files containing the physical data for the same simulation.

Sometimes it might happen that you need to go through the sequential list of the parameter files containing the physical data for the same simulation.

The final solution for the previous run will form the initial guess for the next one.

For example, some fluid flow applications lack the good initial guess which heavily influences the iterative process itself. More often it occurs for high Re numbers.

What we do in this case is:

  • we form the parameter file for some fluid flow app that includes the relatively high dynamic viscosity and therefore relatively low Re number,
  • we use, say, zero initial guess for all solution variables like pressure and velocity,
  • we use the final solution for this problem as the initial guess for the next problem whose parameter file will have lower dynamic viscosity and therefore higher Re number,
  • we repeat till we reach the desirable dynamic viscosity (Re number) of the fluid for which the simulation itself was designed.

Other examples are a steep gradient of membrane water content, high overpotential, and other.

In other words, it may be extremely useful for nonlinear problems to go through the list of conditions from light or moderate towards heavy smartly forming initial guesses for each of those conditions.

template<int dim>
boost::shared_ptr<AppFrame::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: