The SKIRT project
advanced radiative transfer for astrophysics
ClipGeometryDecorator Class Referenceabstract

#include <ClipGeometryDecorator.hpp>

Inheritance diagram for ClipGeometryDecorator:

Public Types

enum class  Remove : int { Inside , Outside }

Public Member Functions

double density (Position bfr) const override
Position generatePosition () const override
Geometrygeometry () const
Remove remove () const
double SigmaX () const override
double SigmaY () const override
double SigmaZ () const override
Public Member Functions inherited from Geometry
virtual int dimension () const =0
Public Member Functions inherited from SimulationItem
template<class T>
T * find (bool setup=true) const
template<class T>
T * interface (int upLevels, int downLevels, bool setup) 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

 ClipGeometryDecorator ()
virtual bool inside (Position bfr) const =0
double norm () const
void setupSelfAfter () override
Protected Member Functions inherited from Geometry
 Geometry ()
Randomrandom () const
void setupSelfBefore () override
Protected Member Functions inherited from SimulationItem
 SimulationItem ()
virtual bool offersInterface (const std::type_info &interfaceTypeInfo) const
Protected Member Functions inherited from Item
 Item ()

Private Types

using BaseType
using ItemType

Private Attributes

Geometry_geometry
double _norm
Remove _remove

Friends

class ItemRegistry

Detailed Description

The abstract ClipGeometryDecorator class implements a decorator that adjusts another geometry by setting the density equal to zero inside or outside a region defined in a subclass. Each ClipGeometryDecorator subclass must implement the virtual functions dimension() and inside(). The decorator increases the density in the remaining region with a single constant factor \(1/(1-\chi)\), where \(\chi\) is the (Monte Carlo estimated) fraction of the original mass taken away by the clipping, to ensure that the total mass of the decorated geometry remains equal to one. The density(), generatePosition() functions (and, indirectly, any Monte Carlo sampling of positions) fully reflect this renormalization.

The SigmaX(), SigmaY() and SigmaZ() functions implemented by this base class, on the other hand, simply return the corresponding value for the geometry being decorated, without applying the renormalization factor described above. This is a deliberate choice rather than an oversight. A clip generally removes a different fraction of mass along each of the three coordinate axes, so the single, uniform renormalization factor is exact for at most one of them; applying it to all three regardless would make some of the reported values exact (or nearly so) while leaving the others approximate, without any way for client code to tell which is which. Because these functions are used, among other purposes, to help normalize the mass of medium components, such a partially-corrected, inconsistent result could bias the simulation output in a way that is difficult to predict or diagnose. Simply returning the undecorated geometry's own values sacrifices precision on an individual axis, but is predictable and consistent, both across all three axes and across all subclasses of this class. A subclass may still override one of these functions where a genuinely exact special case applies for the particular shape of its clip region.

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

Member Enumeration Documentation

◆ Remove

enum class ClipGeometryDecorator::Remove : int
strong

The enumeration type indicating which region to remove (Inside or Outside).

Inside : "the inner region (creating a cavity)".

Outside : "the outer region (cropping)".

Constructor & Destructor Documentation

◆ ClipGeometryDecorator()

ClipGeometryDecorator::ClipGeometryDecorator ( )
inlineprotected

Default constructor for abstract Item subclass ClipGeometryDecorator: "a decorator that clips another geometry".

Member Function Documentation

◆ density()

double ClipGeometryDecorator::density ( Position bfr) const
overridevirtual

This function returns the density \(\rho({\bf{r}})\) at the position \({\bf{r}}\). It is zero in the removed region, and equal to the density of the geometry being decorated elsewhere, after an adjustment is made to account for the clipping.

Implements Geometry.

◆ generatePosition()

Position ClipGeometryDecorator::generatePosition ( ) const
overridevirtual

This function generates a random position from the geometry, by drawing a random point from the three-dimensional probability density \(p({\bf{r}})\, {\text{d}}{\bf{r}} = \rho({\bf{r}})\, {\text{d}}{\bf{r}}\). It repeatedly calls the density() function for the geometry being decorated until a position is returned that does not lie in the removed region.

Implements Geometry.

◆ geometry()

Geometry * ClipGeometryDecorator::geometry ( ) const
inline

This function returns the value of the discoverable item property geometry: "the geometry to be clipped".

◆ inside()

virtual bool ClipGeometryDecorator::inside ( Position bfr) const
protectedpure virtual

This pure virtual function, to be implemented by a subclass, returns true if the specified position is inside the boundary defined by the subclass, i.e. the point is in the region that would be carved away when creating a cavity, or in the region that would be retained when cropping.

Implemented in BoxClipGeometryDecorator, CylindricalClipGeometryDecorator, and SphericalClipGeometryDecorator.

◆ norm()

double ClipGeometryDecorator::norm ( ) const
protected

This function returns the normalization factor calculated by this class during setup.

◆ remove()

Remove ClipGeometryDecorator::remove ( ) const
inline

This function returns the value of the discoverable Remove enumeration property remove: "the region to be removed".

◆ setupSelfAfter()

void ClipGeometryDecorator::setupSelfAfter ( )
overrideprotectedvirtual

This function estimates the fraction \(\chi\) of the mass from the original model taken away by the clipping. It samples the density of the geometry being decorated, and counts the number of generated positions that fall in the removed region. This value is used to renormalize the decorated density distribution to unity: the factor by which the original density has to be multiplied is simply \(1/(1-\chi)\).

Reimplemented from SimulationItem.

◆ SigmaX()

double ClipGeometryDecorator::SigmaX ( ) const
overridevirtual

This function returns the X-axis surface density, i.e. the integration of the density along the entire X-axis,

\[ \Sigma_X = \int_{-\infty}^\infty \rho(x,0,0)\,{\text{d}}x. \]

As explained in the class documentation, it simply returns the corresponding value of the geometry being decorated, without attempting to correct for the clipping.

Implements Geometry.

◆ SigmaY()

double ClipGeometryDecorator::SigmaY ( ) const
overridevirtual

This function returns the Y-axis surface density, i.e. the integration of the density along the entire Y-axis,

\[ \Sigma_Y = \int_{-\infty}^\infty \rho(0,y,0)\,{\text{d}}y. \]

As explained in the class documentation, it simply returns the corresponding value of the geometry being decorated, without attempting to correct for the clipping.

Implements Geometry.

◆ SigmaZ()

double ClipGeometryDecorator::SigmaZ ( ) const
overridevirtual

This function returns the Z-axis surface density, i.e. the integration of the density along the entire Z-axis,

\[ \Sigma_Z = \int_{-\infty}^\infty \rho(0,0,z)\,{\text{d}}z. \]

As explained in the class documentation, it simply returns the corresponding value of the geometry being decorated, without attempting to correct for the clipping.

Implements Geometry.

Reimplemented in CylindricalClipGeometryDecorator.


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