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

#include <DensityTreePolicy.hpp>

Inheritance diagram for DensityTreePolicy:
Inheritance graph
[legend]

Public Member Functions

vector< TreeNode * > constructTree (TreeNode *root) override
 
double maxDustDensityDispersion () const
 
double maxDustFraction () const
 
double maxDustOpticalDepth () const
 
double maxElectronFraction () const
 
double maxGasFraction () const
 
virtual bool needsSubdivide (TreeNode *node)
 
double wavelength () const
 
Range wavelengthRange () const override
 
- Public Member Functions inherited from TreePolicy
virtual vector< TreeNode * > constructTree (TreeNode *root)=0
 
int maxLevel () const
 
int minLevel () 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
 
- Public Member Functions inherited from MaterialWavelengthRangeInterface
virtual WavelengthGridmaterialWavelengthGrid () const
 
- Public Member Functions inherited from WavelengthRangeInterface
virtual ~WavelengthRangeInterface ()
 
virtual Range wavelengthRange () const =0
 

Protected Member Functions

 DensityTreePolicy ()
 
void setupSelfBefore () override
 
- Protected Member Functions inherited from TreePolicy
 TreePolicy ()
 
void setupSelfBefore () override
 
- 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 ()
 
- Protected Member Functions inherited from MaterialWavelengthRangeInterface
 MaterialWavelengthRangeInterface ()
 
- Protected Member Functions inherited from WavelengthRangeInterface
 WavelengthRangeInterface ()
 

Private Types

using BaseType = TreePolicy
 
using ItemType = DensityTreePolicy
 

Private Attributes

double _dustKappa
 
double _dustMass
 
vector< Medium * > _dustMedia
 
vector< Medium * > _electronMedia
 
double _electronNumber
 
vector< Medium * > _gasMedia
 
double _gasNumber
 
bool _hasAny
 
bool _hasDustAny
 
bool _hasDustDensityDispersion
 
bool _hasDustFraction
 
bool _hasDustOpticalDepth
 
bool _hasElectronFraction
 
bool _hasGasFraction
 
double _maxDustDensityDispersion
 
double _maxDustFraction
 
double _maxDustOpticalDepth
 
double _maxElectronFraction
 
double _maxGasFraction
 
int _numSamples
 
Random_random
 
double _wavelength
 

Friends

class ItemRegistry
 

Detailed Description

DensityTreePolicy represents the configurable options and the corresponding implementation mechanisms for constructing spatial tree grids based on the density distribution of the media in the medium system.

This policy offers several options for configuring the recursive subdivision of the hierarchical tree. First of all, the minimum and maximum tree subdvision levels (actually offered by the base class) override the other subdvision criteria described below. Tree nodes are always subdivided up to the minimum level, and nodes are never subdivided beyond the maximum level, regardless of the outcome of the other criteria.

The remaining subdvision criteria consist of the maximum mass fraction \(\delta_\text{max}\) for each material type (dust, electrons, gas), the maximum diagonal dust optical depth \(\tau_{\lambda,\text{max}}\) at wavelength \(\lambda\), and the maximum dust density dispersion \(q_\text{max}\). A node is subdivided as long as the value calculated for the node for one or more of these five criteria exceeds the corresponding configured maximum value. A criterion is automatically disabled if the corresponding material type is not present in the model, and it can be explicitly disabled by configuring a zero maximum value. Configuring an impossibly high maximum value has the same effect, but may require substantial calculation to verify the criterion for each node.

We first discuss the three criteria related to dust. For this material type, we use mass and mass density (as opposed to number and number density) because it is the appropriate quantity for dust in case multiple dust medium components have a different mass per hydrogen atom value. The total dust mass in the model, \(M_\text{model}\), and the dust density at a given position, \(\rho(\bf{r})\), are obtained by summing the corresponding quantity for each dust medium. The average dust density \(\rho\) inside a given node is estimated from density samples in \(N\) random positions \(\bf{r}_i\) distributed uniformly across the volume \(V\) of the node:

\[\rho = \frac{1}{N}\,\sum_{i=1}^{N}\rho(\bf{r}_i) .\]

The fraction of the mass \(\delta\) within the node is then easily found as

\[\delta = \frac{\rho V} {M_\text{model}}.\]

The estimated optical depth \(\tau_\lambda\) at wavelength \(\lambda\) across the diagonal \(\Delta s\) of a node can now be expressed as

\[\tau_\lambda = \kappa_\lambda \,\rho\,\Delta s\]

where \(\kappa_\lambda\) is a representative extinction mass coefficient for the dust in the medium. For the sake of performance this value is assumed to be constant across the spatial domain, and it is determined as an average of the \(\kappa_\lambda\) values of the dust media components, taken at the origin of the model coordinate system.

Finally, a measure for the dust density dispersion \(q\) within the node is determined as

\[ q = \begin{cases} \;\dfrac{\rho_{\text{max}}-\rho_{\text{min}}}{\rho_{\text{max}}} & \quad\text{if $\rho_{\text{max}}>0$,} \\ \;0 & \quad\text{if $\rho_{\text{max}}=0$.} \end{cases} \]

where \(\rho_{\text{min}}\) and \(\rho_{\text{max}}\) are the smallest and largest sampled density values from the list of \(N\) sampled positions in the node. The quantity \(q\) is a simple measure for the uniformity of the density within the node: for a constant density, \(q=0\), whereas \(q\) approaches 1 if a steep gradient is present. The special case \(\rho_{\text{max}}=0\) is included because it is possible that a node is empty, in which case the uniform value \(q=0\) should be returned. With a configured value of \(0<q_\text{max}<1\), nodes that contain a sharp edge with empty space one side will continue to be subdivided for ever, because such cells have a density dispersion measure of \(q=1\). It is thus important to always specify a reasonable maximum subdivision level when using this subdivision criterion.

For electrons and for gas, only the maximum mass fraction criterion is offered. For these material types, the number \(\mathcal{N}\) and number density \(n\) are used instead of the mass \(M\) and mass density \(\rho\). Other than this, the procedure is the same as the one described for dust.

This class implements the MaterialWavelengthRangeInterface to indicate that wavelength-dependent material properties will be required in case the optical depth criterion is enabled.

Constructor & Destructor Documentation

◆ DensityTreePolicy()

DensityTreePolicy::DensityTreePolicy ( )
inlineprotected

Default constructor for concrete Item subclass DensityTreePolicy : "a tree grid construction policy using the medium density distribution" .

Member Function Documentation

◆ constructTree()

vector< TreeNode * > DensityTreePolicy::constructTree ( TreeNode root)
overridevirtual

This function constructs the hierarchical tree and all (interconnected) nodes forming the tree as described for the corresponding pure virtual function in the base class. The implementation for this class loops over the tree subdivision levels. For each level, the function alternates between evaluating all of the nodes (i.e. determining which nodes need subdivision) and actually subdividing the nodes that need it.

These operations are split over two phases because the first one can be parallelized (the only output is a Boolean flag), while the second one cannot (the tree structure is updated in various ways). Parallelizing the first operation is often meaningful, because determining whether a node needs subdivision can be resource-intensive. For example, it may require sampling densities in the source distribution.

Implements TreePolicy.

◆ maxDustDensityDispersion()

DensityTreePolicy::maxDustDensityDispersion ( ) const
inline

This function returns the value of the discoverable double property maxDustDensityDispersion : "the maximum dust density dispersion in each cell" .

The minimum value for this property is "[0" .

The maximum value for this property is "1]" .

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

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

◆ maxDustFraction()

DensityTreePolicy::maxDustFraction ( ) const
inline

This function returns the value of the discoverable double property maxDustFraction : "the maximum fraction of dust contained in each cell" .

The minimum value for this property is "[0" .

The maximum value for this property is "1e-2]" .

The default value for this property is given by the conditional value expression "1e-6" .

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

◆ maxDustOpticalDepth()

DensityTreePolicy::maxDustOpticalDepth ( ) const
inline

This function returns the value of the discoverable double property maxDustOpticalDepth : "the maximum diagonal dust optical depth for each cell" .

The minimum value for this property is "[0" .

The maximum value for this property is "100]" .

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

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

◆ maxElectronFraction()

DensityTreePolicy::maxElectronFraction ( ) const
inline

This function returns the value of the discoverable double property maxElectronFraction : "the maximum fraction of electrons contained in each cell" .

The minimum value for this property is "[0" .

The maximum value for this property is "1e-2]" .

The default value for this property is given by the conditional value expression "1e-6" .

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

◆ maxGasFraction()

DensityTreePolicy::maxGasFraction ( ) const
inline

This function returns the value of the discoverable double property maxGasFraction : "the maximum fraction of gas contained in each cell" .

The minimum value for this property is "[0" .

The maximum value for this property is "1e-2]" .

The default value for this property is given by the conditional value expression "1e-6" .

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

◆ needsSubdivide()

virtual bool DensityTreePolicy::needsSubdivide ( TreeNode node)
virtual

This function returns true if the given node needs to be subdivided according to the criteria configured for this policy, including minimum and maximum level, and false otherwise.

Reimplemented in NestedDensityTreePolicy.

◆ setupSelfBefore()

void DensityTreePolicy::setupSelfBefore ( )
overrideprotectedvirtual

This function obtains and caches information used by the needsSubdivide() function to evaluate the configured criteria.

Reimplemented from SimulationItem.

Reimplemented in NestedDensityTreePolicy.

◆ wavelength()

DensityTreePolicy::wavelength ( ) const
inline

This function returns the value of the discoverable double property wavelength : "the wavelength at which to evaluate the optical depth" .

This property represents a physical quantity of type "wavelength" .

The minimum value for this property is "1 pm" .

The maximum value for this property is "1 m" .

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

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

◆ wavelengthRange()

Range DensityTreePolicy::wavelengthRange ( ) const
overridevirtual

If the optical depth criterion is enabled, this function returns a wavelength range corresponding to the related user-configured wavelength, indicating that wavelength-dependent material properties will be required for this wavelength. Otherwise, the function returns a null range.

Implements WavelengthRangeInterface.


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