Dakota  Version 6.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | Private Attributes | List of all members
Environment Class Reference

Base class for the environment class hierarchy. More...

Inheritance diagram for Environment:
ExecutableEnvironment LibraryEnvironment

Public Member Functions

 Environment ()
 default constructor: empty envelope More...
 
 Environment (int argc, char *argv[])
 envelope constructor for ExecutableEnvironment letter More...
 
 Environment (ProgramOptions prog_opts)
 
 Environment (MPI_Comm dakota_mpi_comm, ProgramOptions prog_opts=ProgramOptions())
 
 Environment (const String &env_type)
 envelope constructor for letter type identifed by String More...
 
 Environment (const Environment &env)
 copy constructor More...
 
virtual ~Environment ()
 destructor More...
 
Environment operator= (const Environment &env)
 assignment operator More...
 
virtual void execute ()
 the run function for the environment: invoke the iterator(s) on the model(s). Called from main.cpp.
 
bool check () const
 Print status of check and return true if in a "check" mode, including version and help. Return false if proceeding to a run mode.
 
MPIManagermpi_manager ()
 return mpiManager
 
ProgramOptionsprogram_options ()
 return programOptions
 
OutputManageroutput_manager ()
 return outputManager
 
ParallelLibraryparallel_library ()
 return parallelLib
 
ProblemDescDBproblem_description_db ()
 return probDescDB
 
const Variablesvariables_results () const
 return the final environment solution (variables)
 
const Responseresponse_results () const
 return the final environment solution (response)
 
void exit_mode (const String &mode="exit")
 allow environment clients to set Dakota exit behavior (throw vs. exit) More...
 

Protected Member Functions

 Environment (BaseConstructor)
 constructor initializes the base class part of default-constructed letters More...
 
 Environment (BaseConstructor, int argc, char *argv[])
 constructor initializes the base class part of executable letter classes More...
 
 Environment (BaseConstructor, ProgramOptions prog_opts, MPI_Comm dakota_mpi_comm=MPI_COMM_WORLD)
 constructor initializes the base class part of library letter classes More...
 
void parse (bool check_bcast_database=true, DbCallbackFunctionPtr callback=NULL, void *callback_data=NULL)
 parse inputs, callbacks, and optionally check and broadcast More...
 
void construct ()
 Instantiate topLevelIterator.
 
void destruct ()
 Deallocate parallel partitioning for topLevelIterator.
 

Protected Attributes

MPIManager mpiManager
 the MPI manager instance
 
ProgramOptions programOptions
 the command line options manager
 
OutputManager outputManager
 (tagged) output stream manager
 
ParallelLibrary parallelLib
 the parallel library instance
 
ProblemDescDB probDescDB
 the parser database instance
 
Iterator topLevelIterator
 the top level (meta-)iterator
 
UsageTracker usageTracker
 tool for Dakota usage tracking (this is a thin wrapper class)
 

Private Member Functions

Environmentget_environment (const String &env_type)
 Used by the envelope to instantiate the correct letter class. More...
 

Private Attributes

EnvironmentenvironmentRep
 pointer to the letter (initialized only for the envelope)
 
int referenceCount
 number of objects sharing environmentRep
 

Detailed Description

Base class for the environment class hierarchy.

The Environment class is the base class for the class hierarchy providing the top level control in DAKOTA. The environment is responsible for creating and managing iterators and models. For memory efficiency and enhanced polymorphism, the environment hierarchy employs the "letter/envelope idiom" (see Coplien "Advanced C++", p. 133), for which the base class (Environment) serves as the envelope and one of the derived classes (selected in Environment::get_environment()) serves as the letter.

Constructor & Destructor Documentation

default constructor: empty envelope

Default envelope constructor. environmentRep is NULL in this case, which makes it necessary to check for NULL in the copy constructor, assignment operator, and destructor.

Environment ( int  argc,
char *  argv[] 
)

envelope constructor for ExecutableEnvironment letter

Envelope constructor for ExecutableEnvironment. Selection of derived type by get_environment() is not necessary in this case.

References Dakota::abort_handler(), and Environment::environmentRep.

Environment ( ProgramOptions  prog_opts)

Envelope constructor for LibraryEnvironment. Selection of derived type by get_environment() is not necessary in this case.

References Dakota::abort_handler(), and Environment::environmentRep.

Environment ( MPI_Comm  dakota_mpi_comm,
ProgramOptions  prog_opts = ProgramOptions() 
)

Envelope constructor for LibraryEnvironment. Selection of derived type by get_environment() is not necessary in this case.

References Dakota::abort_handler(), and Environment::environmentRep.

Environment ( const String &  env_type)

envelope constructor for letter type identifed by String

Alternate construction by String. Envelope constructor invokes get_environment() which instantiates a derived class letter; the derived constructor selects a BaseConstructor constructor in its initialization list to avoid the recursion of a base class constructor calling get_environment() again.

References Dakota::abort_handler(), Environment::environmentRep, and Environment::get_environment().

Environment ( const Environment env)

copy constructor

Copy constructor manages sharing of environmentRep and incrementing of referenceCount.

References Environment::environmentRep, and Environment::referenceCount.

~Environment ( )
virtual

destructor

Destructor decrements referenceCount and only deletes environmentRep when referenceCount reaches zero.

References Environment::destruct(), Environment::environmentRep, and Environment::referenceCount.

Environment ( BaseConstructor  )
protected

constructor initializes the base class part of default-constructed letters

This letter constructor initializes base class data for inherited environments that are default constructed. Since the letter IS the representation, its representation pointer is set to NULL (an uninitialized pointer causes problems in ~Environment).

Use cases: library with no options, no MPI comm

References ProgramOptions::exit_mode(), Environment::exit_mode(), WorkdirHelper::initialize(), and Environment::programOptions.

Environment ( BaseConstructor  ,
int  argc,
char *  argv[] 
)
protected

constructor initializes the base class part of executable letter classes

This letter constructor initializes base class data for inherited environments: instantiate/initialize the environment, options, parallel library, and problem description database objects. Since the letter IS the representation, its representation pointer is set to NULL (an uninitialized pointer causes problems in ~Environment).

Use cases: executable with command-line args

References ProgramOptions::exit_mode(), Environment::exit_mode(), WorkdirHelper::initialize(), and Environment::programOptions.

Environment ( BaseConstructor  ,
ProgramOptions  prog_opts,
MPI_Comm  dakota_mpi_comm = MPI_COMM_WORLD 
)
protected

constructor initializes the base class part of library letter classes

This letter constructor initializes base class data for inherited environments. Since the letter IS the representation, its representation pointer is set to NULL (an uninitialized pointer causes problems in ~Environment).

Use cases: library with program options library with program options and MPI comm

References ProgramOptions::exit_mode(), Environment::exit_mode(), WorkdirHelper::initialize(), and Environment::programOptions.

Member Function Documentation

Environment operator= ( const Environment env)

assignment operator

Assignment operator decrements referenceCount for old environmentRep, assigns new environmentRep, and increments referenceCount for new environmentRep.

References Environment::environmentRep, and Environment::referenceCount.

void exit_mode ( const String &  mode = "exit")

allow environment clients to set Dakota exit behavior (throw vs. exit)

Set the global variable controlling Dakota's exit behavior. Call with no arguments to reset to default behavior.

References Dakota::abort_handler(), and Dakota::abort_mode.

Referenced by Environment::Environment(), and run_dakota_data().

void parse ( bool  check_bcast_database = true,
DbCallbackFunctionPtr  callback = NULL,
void *  callback_data = NULL 
)
protected

parse inputs, callbacks, and optionally check and broadcast

Parse input file and invoked any callbacks, then optionally check and sync database if check_bcast_database = true

References ProblemDescDB::check_and_broadcast(), ProgramOptions::input_file(), ProgramOptions::input_string(), ProblemDescDB::parse_inputs(), Environment::probDescDB, and Environment::programOptions.

Referenced by ExecutableEnvironment::ExecutableEnvironment(), and LibraryEnvironment::LibraryEnvironment().

Environment * get_environment ( const String &  env_type)
private

Used by the envelope to instantiate the correct letter class.

Used only by the envelope constructor to initialize environmentRep to the appropriate derived type, as given by the environmentName attribute.

Referenced by Environment::Environment().


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