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

#include <VoronoiMeshSpatialGrid.hpp>

Inheritance diagram for VoronoiMeshSpatialGrid:
Inheritance graph
[legend]

Public Types

enum class  Policy : int {
  Uniform , CentralPeak , DustDensity , ElectronDensity ,
  GasDensity , File , ImportedSites , ImportedMesh
}
 

Public Member Functions

 ~VoronoiMeshSpatialGrid ()
 
int cellIndex (Position bfr) const override
 
Position centralPositionInCell (int m) const override
 
std::unique_ptr< PathSegmentGeneratorcreatePathSegmentGenerator () const override
 
double diagonal (int m) const override
 
string filename () const
 
double numberDensity (int h, int m) const override
 
int numCells () const override
 
int numSites () const
 
Policy policy () const
 
Position randomPositionInCell (int m) const override
 
bool relaxSites () const
 
double volume (int m) const override
 
void writeGridPlotFiles (const SimulationItem *probe) const override
 
- Public Member Functions inherited from BoxSpatialGrid
Box boundingBox () const override
 
int dimension () const override
 
double maxX () const
 
double maxY () const
 
double maxZ () const
 
double minX () const
 
double minY () const
 
double minZ () const
 
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
 
- Public Member Functions inherited from Box
 Box ()
 
 Box (double xmin, double ymin, double zmin, double xmax, double ymax, double zmax)
 
 Box (Vec rmin, Vec rmax)
 
void cellIndices (int &i, int &j, int &k, Vec r, int nx, int ny, int nz) const
 
Vec center () const
 
bool contains (const Box &box) const
 
bool contains (double x, double y, double z) const
 
bool contains (Vec r) const
 
double diagonal () const
 
const Boxextent () const
 
void extent (double &xmin, double &ymin, double &zmin, double &xmax, double &ymax, double &zmax) const
 
Vec fracPos (double xfrac, double yfrac, double zfrac) const
 
Vec fracPos (int xd, int yd, int zd, int xn, int yn, int zn) const
 
bool intersects (const Box &box) const
 
bool intersects (Vec r, const Vec k, double &smin, double &smax) const
 
bool intersects (Vec rc, double r) const
 
Vec rmax () const
 
Vec rmin () const
 
double volume () const
 
Vec widths () const
 
double xmax () const
 
double xmin () const
 
double xwidth () const
 
double ymax () const
 
double ymin () const
 
double ywidth () const
 
double zmax () const
 
double zmin () const
 
double zwidth () const
 
- Public Member Functions inherited from DensityInCellInterface
virtual ~DensityInCellInterface ()
 
virtual double numberDensity (int h, int m) const =0
 

Protected Member Functions

 VoronoiMeshSpatialGrid ()
 
bool offersInterface (const std::type_info &interfaceTypeInfo) const override
 
void setupSelfBefore () override
 
- Protected Member Functions inherited from BoxSpatialGrid
 BoxSpatialGrid ()
 
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 ()
 
- Protected Member Functions inherited from Box
void setExtent (const Box &extent)
 
void setExtent (double xmin, double ymin, double zmin, double xmax, double ymax, double zmax)
 
- Protected Member Functions inherited from DensityInCellInterface
 DensityInCellInterface ()
 

Private Types

using BaseType = BoxSpatialGrid
 
using ItemType = VoronoiMeshSpatialGrid
 

Private Attributes

string _filename
 
VoronoiMeshSnapshot_mesh
 
double _norm
 
int _numSites
 
Policy _policy
 
bool _relaxSites
 

Friends

class ItemRegistry
 

Detailed Description

VoronoiMeshSpatialGrid is a concrete subclass of the SpatialGrid class. It represents a three-dimensional grid based on a Voronoi tesselation of the cuboidal spatial domain of the simulation. See the VoronoiMeshSnapshot class for more information on Voronoi tesselations.

The class offers several options for determining the positions of the sites generating the Voronoi tesselation. A specified number of sites can be distributed randomly over the domain, either uniformly or with the same overall density distribution as the medium. Alternatively, the positions can be copied from the sites in the imported distribution(s).

Furthermore, the user can opt to perform a relaxation step on the site positions to avoid overly elongated cells.

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

◆ Policy

enum class VoronoiMeshSpatialGrid::Policy : int
strong

The enumeration type indicating the policy for determining the positions of the sites.

Uniform : "random from uniform distribution" .

CentralPeak : "random from distribution with a steep central peak" .

DustDensity : "random from dust density distribution" .

ElectronDensity : "random from electron density distribution" .

GasDensity : "random from gas density distribution" .

File : "loaded from text column data file" .

ImportedSites : "positions of particles, sites or cells in imported distribution" .

ImportedMesh : "employ imported Voronoi mesh in medium system" .

Constructor & Destructor Documentation

◆ VoronoiMeshSpatialGrid()

VoronoiMeshSpatialGrid::VoronoiMeshSpatialGrid ( )
inlineprotected

Default constructor for concrete Item subclass VoronoiMeshSpatialGrid : "a Voronoi tessellation-based spatial grid" .

◆ ~VoronoiMeshSpatialGrid()

VoronoiMeshSpatialGrid::~VoronoiMeshSpatialGrid ( )

The destructor releases the Voronoi mesh if this object owns it.

Member Function Documentation

◆ cellIndex()

int VoronoiMeshSpatialGrid::cellIndex ( Position  bfr) const
overridevirtual

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

Implements SpatialGrid.

◆ centralPositionInCell()

Position VoronoiMeshSpatialGrid::centralPositionInCell ( int  m) const
overridevirtual

This function returns the central location of the cell with index \(m\). In this class the function returns the centroid of the Voronoi cell.

Implements SpatialGrid.

◆ createPathSegmentGenerator()

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

This function creates and hands over ownership of a path segment generator (an instance of a PathSegmentGenerator subclass) appropriate for this spatial grid type. For the Voronoi mesh grid, the path segment generator is actually implemented in the VoronoiMeshSnapshot class.

Implements SpatialGrid.

◆ diagonal()

double VoronoiMeshSpatialGrid::diagonal ( int  m) const
overridevirtual

This function returns the approximate diagonal of the cell with index \(m\). For a Voronoi grid, it returns \((3V)^(1/3)\) where \(V\) is the volume of the cell. This corresponds to the correct diagonal only for cubical cells.

Implements SpatialGrid.

◆ filename()

VoronoiMeshSpatialGrid::filename ( ) const
inline

This function returns the value of the discoverable string property filename : "the name of the file containing the site positions" .

This property is relevant only if the Boolean expression "policyFile" evaluates to true after replacing the names by true or false depending on their presence.

◆ numberDensity()

double VoronoiMeshSpatialGrid::numberDensity ( int  h,
int  m 
) const
overridevirtual

This function implements the DensityInCellInterface interface. It returns the number density for medium component \(h\) in the grid cell with index \(m\). For a Voronoi mesh grid, this interface can be offered only if the "ImportedMesh" policy has been configured, and the medium system consists of a single component, which then, by definition, supplies the Voronoi mesh. Thus, the component index \(h\) passed to this function should always be zero; in fact, its value is actually ignored.

Implements DensityInCellInterface.

◆ numCells()

int VoronoiMeshSpatialGrid::numCells ( ) const
overridevirtual

This function returns the number of cells in the grid.

Implements SpatialGrid.

◆ numSites()

VoronoiMeshSpatialGrid::numSites ( ) const
inline

This function returns the value of the discoverable integer property numSites : "the number of random sites (or cells in the grid)" .

The minimum value for this property is "5" .

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

This property is relevant only if the Boolean expression "policyUniform|policyCentralPeak|policyDustDensity|" "policyElectronDensity|policyGasDensity" evaluates to true after replacing the names by true or false depending on their presence.

◆ offersInterface()

bool VoronoiMeshSpatialGrid::offersInterface ( const std::type_info &  interfaceTypeInfo) const
overrideprotectedvirtual

This function is used by the interface() function to ensure that the receiving item can actually offer the specified interface. If the requested interface is the DensityInCellInterface, the implementation in this class returns true if the "ImportedMesh" policy has been configured and the medium system consists of a single component, and false otherwise. For other requested interfaces, the function invokes its counterpart in the base class.

Reimplemented from SimulationItem.

◆ policy()

VoronoiMeshSpatialGrid::policy ( ) const
inline

This function returns the value of the discoverable Policy enumeration property policy : "the policy for determining the positions of the sites" .

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

◆ randomPositionInCell()

Position VoronoiMeshSpatialGrid::randomPositionInCell ( int  m) const
overridevirtual

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

Implements SpatialGrid.

◆ relaxSites()

VoronoiMeshSpatialGrid::relaxSites ( ) const
inline

This function returns the value of the discoverable Boolean property relaxSites : "perform site relaxation to avoid overly elongated cells" .

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

This property is relevant only if the Boolean expression "!policyImportedMesh" evaluates to true after replacing the names by true or false depending on their presence.

◆ setupSelfBefore()

void VoronoiMeshSpatialGrid::setupSelfBefore ( )
overrideprotectedvirtual

This function verifies that the attributes have been appropriately set, generates or retrieves the site positions for constructing the Voronoi tessellation according to the configured policy, and finally constructs the Voronoi tessellation through an instance of the VoronoiMeshSnapshot class.

Reimplemented from BoxSpatialGrid.

◆ volume()

double VoronoiMeshSpatialGrid::volume ( int  m) const
overridevirtual

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

Implements SpatialGrid.

◆ writeGridPlotFiles()

void VoronoiMeshSpatialGrid::writeGridPlotFiles ( const SimulationItem probe) const
overridevirtual

This function outputs the grid plot files; it is provided here because the regular mechanism does not apply. The function reconstructs the Voronoi tesselation in order to produce the coordinates of the Voronoi cell vertices.

Reimplemented from SpatialGrid.


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