The SKIRT project
advanced radiative transfer for astrophysics
Cylinder2DSpatialGrid Class Reference

#include <Cylinder2DSpatialGrid.hpp>

Inheritance diagram for Cylinder2DSpatialGrid:

Public Member Functions

int cellIndex (Position bfr) const override
Position centralPositionInCell (int m) const override
std::unique_ptr< PathSegmentGeneratorcreatePathSegmentGenerator () const override
double diagonal (int m) const override
int dimension () const override
MeshmeshRadial () const
MeshmeshZ () const
int numCells () const override
Position randomPositionInCell (int m) const override
void setupSelfAfter () override
double volume (int m) const override
Public Member Functions inherited from CylinderSpatialGrid
double maxRadius () const
double maxZ () const
double minRadius () const
double minZ () const
Public Member Functions inherited from SpatialGrid
virtual void writeGridPlotFiles (const SimulationItem *probe) 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

 Cylinder2DSpatialGrid ()
void write_xy (SpatialGridPlotFile *outfile) const override
void write_xz (SpatialGridPlotFile *outfile) const override
Protected Member Functions inherited from CylinderSpatialGrid
 CylinderSpatialGrid ()
Box boundingBox () const override
void setupSelfBefore () override
Protected Member Functions inherited from SpatialGrid
 SpatialGrid ()
Randomrandom () const
void setupSelfBefore () override
virtual void write_xyz (SpatialGridPlotFile *outfile) const
virtual void write_yz (SpatialGridPlotFile *outfile) const
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 Member Functions

bool getCoords (int m, double &Rmin, double &zmin, double &Rmax, double &zmax) const
int index (int i, int k) const

Private Attributes

Mesh_meshRadial
Mesh_meshZ
int _Ncells
int _NR
int _Nz
Array _Rv
Array _zv

Friends

class ItemRegistry
class MySegmentGenerator

Detailed Description

The Cylinder2DSpatialGrid class is subclass of the CylinderSpatialGrid class, and represents axisymmetric spatial grids based on cylindrical coordinates. The grid is defined in the meridional plane and rotated around the z-axis. The meridional grid is specified through two sets of grid points:

  • \(N_R+1\) radial grid points \(R_i, \,i=0,\ldots,N_R\), with \(0\le R_\text{min} = R_0\), \(R_i<R_{i+1}\), and \(R_{N_R} = R_\text{max}\).
  • \(N_z+1\) vertical grid points \(z_k, \,k=0,\ldots,N_z\), with \(z_\text{min} = z_0\), \(z_i<z_{i+1}\), and \(z_{N_z} = z_\text{max}\).

In total there are \(N_{\text{cells}} = N_R\,N_z\) cells in the grid.

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

Constructor & Destructor Documentation

◆ Cylinder2DSpatialGrid()

Cylinder2DSpatialGrid::Cylinder2DSpatialGrid ( )
inlineprotected

Default constructor for concrete Item subclass Cylinder2DSpatialGrid: "a 2D axisymmetric spatial grid in cylindrical coordinates".

Member Function Documentation

◆ cellIndex()

int Cylinder2DSpatialGrid::cellIndex ( Position bfr) const
overridevirtual

This function returns the index \(m\) of the cell that contains the position \({\bf{r}}\). It determines the radial and vertical bin indices \(i\) and \(k\) of the cell containing the position and calculates the correct cell index based on these two numbers.

Implements SpatialGrid.

◆ centralPositionInCell()

Position Cylinder2DSpatialGrid::centralPositionInCell ( int m) const
overridevirtual

This function returns the central location of the cell with index \(m\). It determines the radial and vertical bin indices \(i\) and \(k\) corresponding to the index \(m\). The cylindrical coordinates of the central position are subsequently determined from

\[\begin{split} R &= \frac{R_i + R_{i+1}}{2} \\ \phi &= 0 \\ z &= \frac{z_k + z_{k+1}}{2} \end{split} \]

Implements SpatialGrid.

◆ createPathSegmentGenerator()

std::unique_ptr< PathSegmentGenerator > Cylinder2DSpatialGrid::createPathSegmentGenerator ( ) const
overridevirtual

This function creates and hands over ownership of a path segment generator (an instance of a PathSegmentGenerator subclass) appropriate for a 2D cylindrical grid, implemented as a private PathSegmentGenerator subclass.

The figure above is a projection on the equatorial plane. It shows coordinate system origin \(\bf{o}\) and the path under consideration, defined by its projected starting point \(\bf{R}\) and projected direction vector \(\bf{k}_\text{q}\). Now consider the point of closest approach \(\bf{c}\). The distance \(q\) from \(\bf{c}\) to \(\bf{R}\) can be obtained by projecting the position vector \({\bf{R}}\) onto the line formed by the path. This distance is given by \(q=\bf{R}\cdot\bf{k}_\text{q}/||\bf{k}_\text{q}||\), where we divided the dot product by the norm of the projected direction vector because it is not normalized. The resulting value is negative if \(\bf{R}\) is before \(\bf{c}\) (i.e. it is going inward) and positive if \(\bf{R}\) is after \(\bf{c}\) (i.e. it is going outward). We further define the impact parameter \(p\) as the distance of closest approach. From the rectangular triangles illustrated in the figure it is easily seen that \(p^2 + q^2 = R^2\) and \(p^2 + q_*^2 = R_*^2\). To obtain the actual 3D distance traveled, the \(q\) values must be divided by the projected direction cosine \(||\bf{k}_\text{q}||\).

In the vertical direction, the distance to the intersection of the path with a horizontal plane at height \(z_*\) is given by \((z_*-z)/k_\text{z}\) as usual.

The segment generator uses these relations to step the path through the cells, finding the nearest intersection and updating the values of \(q\), \(\bf{R}\) and \(z\) along the way as a proxy for updating the 3D position \({\bf{r}}\).

Implements SpatialGrid.

◆ diagonal()

double Cylinder2DSpatialGrid::diagonal ( int m) const
overridevirtual

This function returns the "diagonal" of the cell with index \(m\). It determines the radial and vertical bin indices \(i\) and \(k\) corresponding to the index \(m\), and then calculates the distance between the outer/upper and inner/lower corners of the cell in the meridional plane.

Implements SpatialGrid.

◆ dimension()

int Cylinder2DSpatialGrid::dimension ( ) const
overridevirtual

This function returns the dimension of the grid, which is 2.

Implements SpatialGrid.

◆ getCoords()

bool Cylinder2DSpatialGrid::getCoords ( int m,
double & Rmin,
double & zmin,
double & Rmax,
double & zmax ) const
private

This function obtains the coordinates in the meridional plane for the corners of the cell with index \(m\). It determines the radial and vertical bin indices \(i\) and \(k\) corresponding to the index \(m\) using \(i=\lfloor m/N_z \rfloor\) and \(k=m\,\text{mod}\,N_z\).

If both the resulting bin indices are within range, the function stores the corresponding cell corner coordinates in the provided arguments and returns true. If any of the indices are out of range, the function returns false and the contents of the provided arguments remains unchanged.

◆ index()

int Cylinder2DSpatialGrid::index ( int i,
int k ) const
private

This function returns the index \(m\) corresponding to the radial index \(i\) and the vertical index \(k\). The correspondence is simply \(m=k+N_z\,i\).

◆ meshRadial()

Mesh * Cylinder2DSpatialGrid::meshRadial ( ) const
inline

This function returns the value of the discoverable item property meshRadial: "the bin distribution in the radial direction".

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

◆ meshZ()

Mesh * Cylinder2DSpatialGrid::meshZ ( ) const
inline

This function returns the value of the discoverable item property meshZ: "the bin distribution in the Z direction".

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

◆ numCells()

int Cylinder2DSpatialGrid::numCells ( ) const
overridevirtual

This function returns the number of cells \(N_R\,N_z\) in the grid.

Implements SpatialGrid.

◆ randomPositionInCell()

Position Cylinder2DSpatialGrid::randomPositionInCell ( int m) const
overridevirtual

This function returns a random location in the cell with index \(m\). It determines the radial and vertical bin indices \(i\) and \(k\) corresponding to the index \(m\), and then generates the cylindrical coordinates of a random position using

\[ \begin{split} R &= \sqrt{R_i^2 + {\cal{X}}_1\,(R_{i+1}^2-R_i^2)} \\ \phi &= 2\pi\,{\cal{X}}_2 \\ z &= z_k + {\cal{X}}_3\, (z_{k+1}-z_k), \end{split} \]

with \({\cal{X}}_1\), \({\cal{X}}_2\) and \({\cal{X}}_3\) three uniform deviates.

Implements SpatialGrid.

◆ setupSelfAfter()

void Cylinder2DSpatialGrid::setupSelfAfter ( )
overridevirtual

This function sets up a number of data members that depend on the Mesh objects configured for this grid.

Reimplemented from SimulationItem.

◆ volume()

double Cylinder2DSpatialGrid::volume ( int m) const
overridevirtual

This function returns the volume of the cell with index \(m\). It determines the radial and vertical bin indices \(i\) and \(k\) corresponding to the index \(m\), and then calculates the volume as

\[ V = \pi (R_{i+1}^2-R_i^2) (z_{k+1}-z_k). \]

Implements SpatialGrid.

◆ write_xy()

void Cylinder2DSpatialGrid::write_xy ( SpatialGridPlotFile * outfile) const
overrideprotectedvirtual

This function writes the intersection of the grid with the xy plane to the specified SpatialGridPlotFile object.

Reimplemented from SpatialGrid.

◆ write_xz()

void Cylinder2DSpatialGrid::write_xz ( SpatialGridPlotFile * outfile) const
overrideprotectedvirtual

This function writes the intersection of the grid with the xz plane to the specified SpatialGridPlotFile object.

Reimplemented from SpatialGrid.


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