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

#include <Cylinder2DSpatialGrid.hpp>

Inheritance diagram for Cylinder2DSpatialGrid:
Inheritance graph
[legend]

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
 
MoveableMeshmeshZ () 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 minZ () const
 
- Public Member Functions inherited from SpatialGrid
virtual Box boundingBox () const =0
 
virtual int cellIndex (Position bfr) const =0
 
virtual Position centralPositionInCell (int m) const =0
 
virtual std::unique_ptr< PathSegmentGeneratorcreatePathSegmentGenerator () const =0
 
virtual double diagonal (int m) const =0
 
virtual int dimension () const =0
 
virtual int numCells () const =0
 
virtual Position randomPositionInCell (int m) const =0
 
virtual double volume (int m) const =0
 
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_xy (SpatialGridPlotFile *outfile) const
 
virtual void write_xyz (SpatialGridPlotFile *outfile) const
 
virtual void write_xz (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
 
virtual void setupSelfAfter ()
 
virtual void setupSelfBefore ()
 
- Protected Member Functions inherited from Item
 Item ()
 

Private Types

using BaseType = CylinderSpatialGrid
 
using ItemType = Cylinder2DSpatialGrid
 

Private Member Functions

int index (int i, int k) const
 
void invertIndex (int m, int &i, int &k) const
 

Private Attributes

Mesh_meshRadial
 
MoveableMesh_meshZ
 
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 a set of \(N_R+1\) radial grid points \(R_i\) (with \(i=0,\ldots,N_R\)) and a set of \(N_z+1\) vertical grid points \(z_k\) (with \(k=0,\ldots,N_z\)). In total there are \(N_{\text{cells}} = N_R\,N_z\) cells in the Spatial 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 : "an axisymmetric spatial grid in cylindrical coordinates" .

Member Function Documentation

◆ cellIndex()

int Cylinder2DSpatialGrid::cellIndex ( Position  bfr) const
overridevirtual

This function returns the number of the cell that contains the position \({\bf{r}}\). It just determines the radial and vertical bin indices 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 from the cell with index \(m\). For an axisymmetric grid, the function first determines the radial and vertical bin indices \(i\) and \(k\) that correspond 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} \]

A position with these cylindrical coordinates is returned.

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 an axisymmetric grid, implemented as a private PathSegmentGenerator subclass.

The algorithm used to construct the path is fairly straightforward because of the symmetry in the grid.

Implements SpatialGrid.

◆ diagonal()

double Cylinder2DSpatialGrid::diagonal ( int  m) const
overridevirtual

This function returns the "diagonal" of the cell with index \(m\). For 2D cylindrical grids, it returns 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 for this class.

Implements SpatialGrid.

◆ index()

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

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

◆ invertIndex()

void Cylinder2DSpatialGrid::invertIndex ( int  m,
int &  i,
int &  k 
) const
private

This private function calculates the radial index \(i\) and the vertical index \(k\) from a cell index \(m\). As the correspondence between \(m\), \(i\) and \(k\) is given by \(m=k+N_z\,i\), one directly obtains \(i=\lfloor m/N_z \rfloor\) and \(k=m\!\mod N_z\).

◆ meshRadial()

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

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 in the grid.

Implements SpatialGrid.

◆ randomPositionInCell()

Position Cylinder2DSpatialGrid::randomPositionInCell ( int  m) const
overridevirtual

This function returns a random location from the cell with index \(m\). For an axisymmetric grid, the function first determines the radial and vertical bin indices \(i\) and \(k\) that correspond to the index \(m\). Then a random radius \(R\), a random azimuth \(\phi\), and a random height \(z\) are determined 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. A position with these cylindrical coordinates is returned.

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\). For an axisymmetric grid, the function determines the radial and vertical bin indices \(i\) and \(k\) that correspond to the index \(m\), and then calculates the volume as

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

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: