The SKIRT project
advanced radiative transfer for astrophysics
Public Types | Public Member Functions | Protected Member Functions | Private Types | Private Attributes | Friends | List of all members
Simulation Class Referenceabstract

#include <Simulation.hpp>

Inheritance diagram for Simulation:
Inheritance graph
[legend]

Public Types

enum class  UserLevel : int { Basic , Regular , Expert }
 

Public Member Functions

FilePathsfilePaths () const
 
Loglog () const
 
ParallelFactoryparallelFactory () const
 
Randomrandom () const
 
void setupAndRun ()
 
Unitsunits () const
 
UserLevel userLevel () const
 
- Public Member Functions inherited from SimulationItem
template<class T >
T * find (bool setup=true) const
 
template<class T >
T * interface (int levels=-999999, bool setup=true) const
 
virtual string itemName () const
 
void setup ()
 
string typeAndName () const
 
- Public Member Functions inherited from Item
 Item (const Item &)=delete
 
virtual ~Item ()
 
void addChild (Item *child)
 
const vector< Item * > & children () const
 
virtual void clearItemListProperty (const PropertyDef *property)
 
void destroyChild (Item *child)
 
virtual bool getBoolProperty (const PropertyDef *property) const
 
virtual vector< double > getDoubleListProperty (const PropertyDef *property) const
 
virtual double getDoubleProperty (const PropertyDef *property) const
 
virtual string getEnumProperty (const PropertyDef *property) const
 
virtual int getIntProperty (const PropertyDef *property) const
 
virtual vector< Item * > getItemListProperty (const PropertyDef *property) const
 
virtual ItemgetItemProperty (const PropertyDef *property) const
 
virtual string getStringProperty (const PropertyDef *property) const
 
int getUtilityProperty (string name) const
 
virtual void insertIntoItemListProperty (const PropertyDef *property, int index, Item *item)
 
Itemoperator= (const Item &)=delete
 
Itemparent () const
 
virtual void removeFromItemListProperty (const PropertyDef *property, int index)
 
virtual void setBoolProperty (const PropertyDef *property, bool value)
 
virtual void setDoubleListProperty (const PropertyDef *property, vector< double > value)
 
virtual void setDoubleProperty (const PropertyDef *property, double value)
 
virtual void setEnumProperty (const PropertyDef *property, string value)
 
virtual void setIntProperty (const PropertyDef *property, int value)
 
virtual void setItemProperty (const PropertyDef *property, Item *item)
 
virtual void setStringProperty (const PropertyDef *property, string value)
 
void setUtilityProperty (string name, int value)
 
virtual string type () const
 

Protected Member Functions

 Simulation ()
 
virtual void runSimulation ()=0
 
virtual void setupSimulation ()=0
 
- Protected Member Functions inherited from SimulationItem
 SimulationItem ()
 
virtual bool offersInterface (const std::type_info &interfaceTypeInfo) const
 
virtual void setupSelfAfter ()
 
virtual void setupSelfBefore ()
 
- Protected Member Functions inherited from Item
 Item ()
 

Private Types

using BaseType = SimulationItem
 
using ItemType = Simulation
 

Private Attributes

ParallelFactory_factory
 
Log_log
 
FilePaths_paths
 
Random_random
 
Units_units
 
UserLevel _userLevel
 

Friends

class ItemRegistry
 

Detailed Description

Simulation is the abstract base class for a simulation item that represents a complete simulation and sits at the top of a run-time simulation hierarchy (i.e. it has no parent). A Simulation instance holds a number of essential simulation-wide property instances. Some of these (a random number generator and a system of units) are discoverable and hence fully user-configurable. The other properties (a file paths object, a logging mechanism, and a parallel factory) are not discoverable. When a Simulation instance is constructed, a default instance is created for each of these properties. A reference to these property instances can be retrieved through the corresponding getter, and in some cases, the property can be further configured under program control (e.g., to set the input and output file paths for the simulation).

Specifically, when a Simulation instance is constructed, the log property is set to an instance of the ConsoleLog class; the filePaths property is set to an instance of the FilePaths class with default paths and no filename prefix; and the parallelFactory property is set to an instance of the ParallelFactory class with the default maximum number of parallel threads.

Member Enumeration Documentation

◆ UserLevel

enum class Simulation::UserLevel : int
strong

The enumeration type indicating the user experience level:

  • Level 1: Basic

    Basic : "Basic: for beginning users (hides many options)" .

    Regular : "Regular: for regular users (hides esoteric options)" .

    Expert : "Expert: for expert users (hides no options)" .

Constructor & Destructor Documentation

◆ Simulation()

Simulation::Simulation ( )
inlineprotected

Default constructor for abstract Item subclass Simulation : "the simulation" .

Member Function Documentation

◆ filePaths()

FilePaths * Simulation::filePaths ( ) const

Returns the input/output file paths object for this simulation hierarchy.

◆ log()

Log * Simulation::log ( ) const

Returns the logging mechanism for this simulation hierarchy.

◆ parallelFactory()

ParallelFactory * Simulation::parallelFactory ( ) const

Returns the logging mechanism for this simulation hierarchy.

◆ random()

Simulation::random ( ) const
inline

This function returns the value of the discoverable item property random : "the random number generator" .

The default value for this property is given by the conditional value expression "Random" .

This property is displayed only if the Boolean expression "Level3" evaluates to true after replacing the names by true or false depending on their presence.

◆ runSimulation()

virtual void Simulation::runSimulation ( )
protectedpure virtual

This function actually runs the simulation, assuming that setup has been already performed. Its implementation must be provided by a subclass.

Implemented in MonteCarloSimulation.

◆ setupAndRun()

void Simulation::setupAndRun ( )

This function performs setup for the complete simulation hierarchy by invoking the setup() function defined in the SimulationItem base class, and then runs the simulation by invoking the run() function which must be defined in a subclass. The complete operation is surrounded by start/finish log messages.

It is highly recommended for the creator/manager of a simulation hierarchy to immediately call setupAndRun() on the Simulation instance rather than first calling the setup() function.

◆ setupSimulation()

virtual void Simulation::setupSimulation ( )
protectedpure virtual

This function actually performs setup for the complete simulation hierarchy. Its implementation must be provided by a subclass.

Implemented in MonteCarloSimulation.

◆ units()

Simulation::units ( ) const
inline

This function returns the value of the discoverable item property units : "the units system" .

The default value for this property is given by the conditional value expression "ExtragalacticUnits" .

◆ userLevel()

Simulation::userLevel ( ) const
inline

This function returns the value of the discoverable UserLevel enumeration property userLevel : "the user experience level" .

The default value for this property is given by the conditional value expression "Regular" .

When a value is entered for this property, the names provided by the conditional value expression "userLevelBasic:Level1;userLevelRegular:Level1,Level2;userLevelExpert:Level1,Level2,Level3" are inserted into the name sets used for evaluating Boolean expressions.


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