The SKIRT project
advanced radiative transfer for astrophysics
Classes | Public Member Functions | Private Attributes | List of all members
SpatialGridPath Class Reference

#include <SpatialGridPath.hpp>

Inheritance diagram for SpatialGridPath:
Inheritance graph
[legend]

Classes

class  Segment
 

Public Member Functions

 SpatialGridPath ()
 
 SpatialGridPath (const Position &bfr, const Direction &bfk)
 
void addSegment (int m, double ds)
 
void clear ()
 
Direction direction () const
 
void findInteractionPoint (double tauinteract)
 
int interactionCellIndex () const
 
double interactionDistance () const
 
double interactionOpticalDepth () const
 
Position moveInside (const Box &box, double eps)
 
Position position () const
 
void propagatePosition (double s)
 
vector< Segment > & segments ()
 
const vector< Segment > & segments () const
 
void setDirection (const Direction &bfk)
 
void setInteractionPoint (int m, double s, double tauAbs=0.)
 
void setPosition (const Position &bfr)
 
double totalOpticalDepth () const
 

Private Attributes

Direction _bfk
 
Position _bfr
 
int _interactionCellIndex
 
double _interactionDistance
 
double _interactionOpticalDepth
 
double _s
 
vector< Segment_segments
 

Detailed Description

A SpatialGridPath object contains the geometric details of a path through a spatial grid. Given a spatial grid, i.e. some partition of space into cells, a starting position \({\bf{r}}\) and a propagation direction \({\bf{k}}\), one can calculate the path through the grid. A SpatialGridPath object maintains a record for each cell crossed by the path, called a segment. A segment stores the spatial cell index (so the cell can be identified in the grid), together with the physical path length \(\Delta s\) covered within the cell, and the path length \(s\) covered along the entire path up to the end of the cell.

Updating the initial position and/or the direction of the path invalidates all segments in the path, but the segments are not automatically cleared. One should call the clear() function or the moveInside() function to do so.

In addition to the geometric data, a SpatialGridPath object allows client code to store optical depth information with each path segment, as well as information on the interaction point along the path corresponding to a given optical depth. Specifically, each path segment can store either an extinction optical depth (for forced-scattering photon life cycles without explicit absorption) or both a scattering and absorption optical depth (for forced-scattering photon life cycles with explicit absorption). The interaction point information includes the spatial cell index, the cumulative distance, and the cumulative absorption optical depth (for the second type of photon cycle).

Constructor & Destructor Documentation

◆ SpatialGridPath() [1/2]

SpatialGridPath::SpatialGridPath ( const Position bfr,
const Direction bfk 
)

This constructor creates an empty path with the specified initial position and propagation direction.

◆ SpatialGridPath() [2/2]

SpatialGridPath::SpatialGridPath ( )

This constructor creates an empty path with the initial position and propagation direction initialized to null values. After using this constructor, invoke the setPosition() and setDirection() functions to set these properties to appropriate values.

Member Function Documentation

◆ addSegment()

void SpatialGridPath::addSegment ( int  m,
double  ds 
)

This function adds a segment in cell \(m\) with length \(\Delta s\) to the path. If \(\Delta s\le 0\), the function does nothing.

◆ clear()

void SpatialGridPath::clear ( )

This function removes all path segments, resulting in an empty path with the original initial position and propagation direction.

◆ direction()

Direction SpatialGridPath::direction ( ) const
inline

This function returns the propagation direction along the path.

◆ findInteractionPoint()

void SpatialGridPath::findInteractionPoint ( double  tauinteract)

This function determines the interaction point along the path corresponding to the specified interaction optical depth, and stores relevant information about it in data members for later retrieval through the interactionCellIndex(), interactionDistance() and interactionOpticalDepth() functions.

Specifically, the function first determines the path segment for which the exit optical depth becomes larger than the specified interaction optical depth. The procedure uses the extinction or scattering optical depth depending on which one has been stored in the segments by the client code. The function then calculates the distance covered along the path until the interaction optical depth has been reached by linear interpolation within the interacting cell. If applicable, it similarly interpolates and the absorption optical depth at the interaction point. Using linear interpolation is equivalent to assuming exponential behavior of the extinction with distance within the cell. Finally, the function stores the index of the spatial cell corresponding to the interacting segment plus the interpolated values in data members for later retrieval.

The function assumes that both the geometric and optical depth information for the path have been set; if this is not the case, the behavior is undefined.

◆ interactionCellIndex()

int SpatialGridPath::interactionCellIndex ( ) const
inline

This function returns the spatial cell index corresponding to the interaction point most recently set by one of the findInteractionPoint() or setInteractionPoint() functions, or -1 if these functions have never been called or if there was no interaction point within the path.

◆ interactionDistance()

double SpatialGridPath::interactionDistance ( ) const
inline

This function returns the distance along the path from its initial position to the interaction point most recently set by one of the findInteractionPoint() or setInteractionPoint() functions, or zero if these functions have never been called or if there was no interaction point within the path.

◆ interactionOpticalDepth()

double SpatialGridPath::interactionOpticalDepth ( ) const
inline

This function returns the cumulative absorption optical depth along the path from its initial position to the interaction point most recently set by one of the findInteractionPoint() or setInteractionPoint() functions, or zero if these functions has never been called.

◆ moveInside()

Position SpatialGridPath::moveInside ( const Box box,
double  eps 
)

This function clears the path, adds any segments needed to move the initial position along the propagation direction (both specified in the constructor) inside a given box, and finally returns the resulting position. The small value specified by eps is added to the path length beyond the intersection point so that the final position is well inside the box, guarding against rounding errors. If the initial position is already inside the box, no segments are added. If the half-ray formed by the initial position and the propagation direction does not intersect the box, the function returns some arbitrary position outside the box.

◆ position()

Position SpatialGridPath::position ( ) const
inline

This function returns the initial position of the path.

◆ propagatePosition()

void SpatialGridPath::propagatePosition ( double  s)
inline

This function propagates the initial position of the path over a distance \(s\). In other words, it updates the position from \({\bf{r}}\) to \({\bf{r}}+s\,{\bf{k}}\).

◆ segments() [1/2]

vector< Segment > & SpatialGridPath::segments ( )
inline

This function returns a writable reference to the list of the current segments in the path. Because the segments are writable, the client code can update the stored optical depth information.

◆ segments() [2/2]

const vector< Segment > & SpatialGridPath::segments ( ) const
inline

This function returns a read-only reference to the list of the current segments in the path.

◆ setDirection()

void SpatialGridPath::setDirection ( const Direction bfk)
inline

This function sets the propagation direction along the path to a new value.

◆ setInteractionPoint()

void SpatialGridPath::setInteractionPoint ( int  m,
double  s,
double  tauAbs = 0. 
)

This function stores the specified spatial cell index, distance and cumulative absorption optical depth to the initial position of the interaction point for later retrieval through the interactionCellIndex(), interactionDistance(), and interactionOpticalDepth() functions.

◆ setPosition()

void SpatialGridPath::setPosition ( const Position bfr)
inline

This function sets the initial position of the path to a new value.

◆ totalOpticalDepth()

double SpatialGridPath::totalOpticalDepth ( ) const

This function returns the optical depth corresponding to the end of the last path segment in the path, or zero if the path has no segments. The procedure uses the extinction or scattering optical depth depending on which one has been stored in the segments by the client code.

The function assumes that both the geometric and optical depth information for the path have been set; if this is not the case, the behavior is undefined.


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