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

#include <ProbeSystem.hpp>

Inheritance diagram for ProbeSystem:
Inheritance graph
[legend]

Public Member Functions

void probePrimary (int iter)
 
void probeRun ()
 
const vector< Probe * > & probes () const
 
void probeSecondary (int iter)
 
void probeSetup ()
 
- 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

 ProbeSystem ()
 
- 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 = ProbeSystem
 

Private Attributes

vector< Probe * > _probes
 

Friends

class ItemRegistry
 

Detailed Description

A ProbeSystem instance maintains a list of zero or more probes (instances of Probe subclasses) and helps ensure that these probes are invoked at the appropriate times.

SKIRT essentially writes two kinds of output. A first type of output can be called "mock observations", i.e. the fluxes and surface densities obtained by detecting photon packets launched (or peeled-off) during the simulation. This output is written by the Instrument subclasses at the end of the simulation run, and it is often the main simulation result. A second type of output is information on any of the data structures constructed in preparation for or during the simulation run, i.e. internal data. This includes diagnostics used to verify configuration and operation of the code and physical quantities that are computed by the simulation but cannot be “observed” from the outside. The goal of the probe system is to move responsibility for producing the second type of output to a separate set of classes/objects as opposed to embedding it in the simulation code itself.

This design has a number of benefits. From a user perspective, the probe objects can take additional attributes to customize the output; for example, requesting a cut through the medium density at some offset from the coordinate plane. The probe list can also contain multiple probes of the same kind; for example, requesting a cut through the medium density at two or more offsets from the coordinate plane. From a developer perspective, there is a more explicit interface between the simulation and output code portions, resulting in improved data encapsulation. The simulation code is not cluttered with output code, and new probe types can be implemented without changing the simulation code (at least, in most cases; see below).

There are essentially two scenarios for probes to retrieve information from item(s) in the simulation hierarchy (the target). In the preferred scenario, a probe uses public members of the target to retrieve data, and implements the output procedure in the probe. This might involve adding some getters to target classes specifically for supporting probe(s). In more involved situations, the data can be prepared for output in a public function of the target class, while still performing the actual output in the probe, possibly through a callback mechanism. This scenario is less preferable because it breaks the clean separation between simulation and output code. However, it can be the appropriate choice when the output is best implemented through a hierarchy of virtual functions. In any case, probes cannot change the data structures held by the target.

Each Monte Carlo simulation hierarchy has a single ProbeSystem instance, which holds a list of Probe subclasses configured by the user. The probeXXX() functions of the probe system, and thereby the corresponding probeXXX() functions in each probe object are called at the following times during a simulation:

Name Called at the end of
probeSetup() the setup phase, i.e. after all simulation items have performed setup
probeRun() the run phase, i.e. after all photon packets have been emitted and detected
probePrimary() each iteration over primary emission
probeSecondary() each iteration over secondary emission (which may include primary emission)

Constructor & Destructor Documentation

◆ ProbeSystem()

ProbeSystem::ProbeSystem ( )
inlineprotected

Default constructor for concrete Item subclass ProbeSystem : "a probe system" .

Member Function Documentation

◆ probePrimary()

void ProbeSystem::probePrimary ( int  iter)

This function is called at the end of each iteration over primary emission, i.e. after all photon packets have been processed and the medium state and the radiation field have been updated if needed. The function argument specifies the one-based iteration index. This function invokes the function of the same name on all probes in the probe system.

◆ probeRun()

void ProbeSystem::probeRun ( )

This function is called at the end of the run phase, i.e. after all photon packets have been emitted and detected. It invokes the function of the same name on all probes in the probe system.

◆ probes()

ProbeSystem::probes ( ) const
inline

This function returns the value of the discoverable item list property probes : "the probes" .

The default value for this property is given by the conditional value expression "!NoMedium:ConvergenceInfoProbe;LuminosityProbe" .

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

◆ probeSecondary()

void ProbeSystem::probeSecondary ( int  iter)

This function is called at the end of each iteration over secondary emission, i.e. after all photon packets have been processed and the medium state and the radiation field have been updated if needed. In some execution flows, the iteration may include both a primary and secondary emission segment. The function argument specifies the one-based iteration index. This function invokes the function of the same name on all probes in the probe system.

◆ probeSetup()

void ProbeSystem::probeSetup ( )

This function is called at the end of the setup phase, i.e. after all simulation items have performed setup. It invokes the function of the same name on all probes in the probe system.


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