Dakota  Version 6.20
Explore and Predict with Confidence
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
 
Environment operator= (const Environment &env)
 assignment operator
 
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 preprocess_inputs ()
 
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.
 
bool assign_model_pointer () const
 

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

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

Private Attributes

std::shared_ptr< EnvironmentenvironmentRep
 pointer to the letter (initialized only for the envelope)
 

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

◆ Environment() [1/9]

default constructor: empty envelope

Default envelope constructor. environmentRep is NULL in this case.

◆ Environment() [2/9]

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() [3/9]

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() [4/9]

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() [5/9]

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(), and Environment::environmentRep.

◆ Environment() [6/9]

Environment ( const Environment env)

copy constructor

Copy constructor manages sharing of environmentRep.

◆ Environment() [7/9]

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.

Use cases: library with no options, no MPI comm

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

◆ Environment() [8/9]

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.

Use cases: executable with command-line args

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

◆ Environment() [9/9]

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.

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

◆ exit_mode()

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().

◆ parse()

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().

◆ get_environment()

std::shared_ptr< 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.


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