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

#include <SpatialGrid.hpp>

Inheritance diagram for SpatialGrid:
Inheritance graph
[legend]

Public Member Functions

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

 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 = SimulationItem
 
using ItemType = SpatialGrid
 

Private Attributes

Random_random
 

Friends

class ItemRegistry
 

Detailed Description

The SpatialGrid class is an abstract base class for grids that tessellate the spatial domain of the simulation. Each position in the computational domain corresponds to a single spatial cell. A SpatialGrid subclass instance represents only purely geometric properties, i.e. it contains no information on the actual distribution of material over the grid.

Constructor & Destructor Documentation

◆ SpatialGrid()

SpatialGrid::SpatialGrid ( )
inlineprotected

Default constructor for abstract Item subclass SpatialGrid : "a spatial grid" .

Member Function Documentation

◆ boundingBox()

virtual Box SpatialGrid::boundingBox ( ) const
pure virtual

This function returns the bounding box that encloses the grid.

Implemented in AdaptiveMeshSpatialGrid, BoxSpatialGrid, CylinderSpatialGrid, and SphereSpatialGrid.

◆ cellIndex()

virtual int SpatialGrid::cellIndex ( Position  bfr) const
pure virtual

This function returns the index \(m\) of the cell that contains the position \({\bf{r}}\).

Implemented in AdaptiveMeshSpatialGrid, CartesianSpatialGrid, Cylinder2DSpatialGrid, Sphere1DSpatialGrid, Sphere2DSpatialGrid, TreeSpatialGrid, and VoronoiMeshSpatialGrid.

◆ centralPositionInCell()

virtual Position SpatialGrid::centralPositionInCell ( int  m) const
pure virtual

This function returns the central location of the cell with index \(m\).

Implemented in AdaptiveMeshSpatialGrid, CartesianSpatialGrid, Cylinder2DSpatialGrid, Sphere1DSpatialGrid, Sphere2DSpatialGrid, TreeSpatialGrid, and VoronoiMeshSpatialGrid.

◆ createPathSegmentGenerator()

virtual std::unique_ptr< PathSegmentGenerator > SpatialGrid::createPathSegmentGenerator ( ) const
pure virtual

This function creates and hands over ownership of a path segment generator (an instance of a PathSegmentGenerator subclass) for the spatial grid. The function must be implemented in each subclass to produce a path segment generator of a type corresponding to the specific type of spatial grid.

Implemented in AdaptiveMeshSpatialGrid, CartesianSpatialGrid, Cylinder2DSpatialGrid, Sphere1DSpatialGrid, Sphere2DSpatialGrid, TreeSpatialGrid, and VoronoiMeshSpatialGrid.

◆ diagonal()

virtual double SpatialGrid::diagonal ( int  m) const
pure virtual

This function returns the actual or approximate diagonal of the cell with index \(m\). For cuboidal cells, the function returns the actual diagonal. For other geometric forms, it returns some approximate diagonal.

Implemented in AdaptiveMeshSpatialGrid, CartesianSpatialGrid, Cylinder2DSpatialGrid, Sphere1DSpatialGrid, Sphere2DSpatialGrid, TreeSpatialGrid, and VoronoiMeshSpatialGrid.

◆ dimension()

virtual int SpatialGrid::dimension ( ) const
pure virtual

This function returns the dimension of the grid, which depends on its (lack of) symmetry. A value of 1 means spherical symmetry, 2 means axial symmetry and 3 means none of these symmetries.

Implemented in AdaptiveMeshSpatialGrid, BoxSpatialGrid, Cylinder2DSpatialGrid, Sphere1DSpatialGrid, and Sphere2DSpatialGrid.

◆ numCells()

virtual int SpatialGrid::numCells ( ) const
pure virtual

◆ random()

Random * SpatialGrid::random ( ) const
inlineprotected

This function returns the simulation's random generator as a service to subclasses.

◆ randomPositionInCell()

virtual Position SpatialGrid::randomPositionInCell ( int  m) const
pure virtual

This function returns a random location from the cell with index \(m\).

Implemented in AdaptiveMeshSpatialGrid, CartesianSpatialGrid, Cylinder2DSpatialGrid, Sphere1DSpatialGrid, Sphere2DSpatialGrid, TreeSpatialGrid, and VoronoiMeshSpatialGrid.

◆ setupSelfBefore()

void SpatialGrid::setupSelfBefore ( )
overrideprotectedvirtual

This function caches the simulation's random generator for use by subclasses.

Reimplemented from SimulationItem.

Reimplemented in VoronoiMeshSpatialGrid.

◆ volume()

virtual double SpatialGrid::volume ( int  m) const
pure virtual

This function returns the volume of the cell with index \(m\).

Implemented in AdaptiveMeshSpatialGrid, CartesianSpatialGrid, Cylinder2DSpatialGrid, Sphere1DSpatialGrid, Sphere2DSpatialGrid, TreeSpatialGrid, and VoronoiMeshSpatialGrid.

◆ write_xy()

virtual void SpatialGrid::write_xy ( SpatialGridPlotFile outfile) const
protectedvirtual

This function writes the intersection of the grid with the xy plane to the specified SpatialGridPlotFile object. The default implementation does nothing.

Reimplemented in AdaptiveMeshSpatialGrid, CartesianSpatialGrid, Cylinder2DSpatialGrid, Sphere1DSpatialGrid, Sphere2DSpatialGrid, and TreeSpatialGrid.

◆ write_xyz()

virtual void SpatialGrid::write_xyz ( SpatialGridPlotFile outfile) const
protectedvirtual

This function writes 3D information for all or part of the cells in the grid structure to the specified SpatialGridPlotFile object. The default implementation does nothing.

Reimplemented in AdaptiveMeshSpatialGrid, CartesianSpatialGrid, and TreeSpatialGrid.

◆ write_xz()

virtual void SpatialGrid::write_xz ( SpatialGridPlotFile outfile) const
protectedvirtual

This function writes the intersection of the grid with the xz plane to the specified SpatialGridPlotFile object. The default implementation does nothing.

Reimplemented in AdaptiveMeshSpatialGrid, CartesianSpatialGrid, Cylinder2DSpatialGrid, Sphere2DSpatialGrid, and TreeSpatialGrid.

◆ write_yz()

virtual void SpatialGrid::write_yz ( SpatialGridPlotFile outfile) const
protectedvirtual

This function writes the intersection of the grid with the yz plane to the specified SpatialGridPlotFile object. The default implementation does nothing.

Reimplemented in AdaptiveMeshSpatialGrid, CartesianSpatialGrid, and TreeSpatialGrid.

◆ writeGridPlotFiles()

virtual void SpatialGrid::writeGridPlotFiles ( const SimulationItem probe) const
virtual

This function outputs text data files that allow plotting the structure of the spatial grid. The number of data files written depends on the dimension of the spatial grid: for spherical symmetry only the intersection with the xy plane is written, for axial symmetry the intersections with the xy and xz planes are written, and for general geometries all three intersections are written. In the latter case, an extra file with three-dimensional information is written as well.

The function is called from the SpatialGridPlotProbe class, and receives a pointer to the probe as its argument. The output files are called prefix_probe_grid_XXX.dat, where XXX is replaced by "xy", "xz", "yz" or "xyz" depending on the file under consideration. Within a file, each line contains two coordinates seperated by whitespace or is empty. Consecutive nonempty lines represent a sequence of "lineto" commands; an empty line marks a "moveto" command.

The default implementation of this function invokes the write_XXX() functions as appropriate for the dimension of the grid. Subclasses usually override the write_XXX() functions, but can opt to override this function instead if that makes more sense.

Reimplemented in VoronoiMeshSpatialGrid.


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