The SKIRT project
advanced radiative transfer for astrophysics
TimeGrid Class Referenceabstract

#include <TimeGrid.hpp>

Inheritance diagram for TimeGrid:

Classes

class  Bin

Public Member Functions

int binForDistance (double distance) const
int binForTime (double time) const
double left (int k) const
int numBins () const
Range range () const
double right (int k) const
double time (int k) const
double width (int k) 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

 TimeGrid ()
virtual void getTimeBins (vector< Bin > &bins) const =0
void setupSelfBefore () override
Protected Member Functions inherited from SimulationItem
 SimulationItem ()
virtual bool offersInterface (const std::type_info &interfaceTypeInfo) const
virtual void setupSelfAfter ()
Protected Member Functions inherited from Item
 Item ()

Private Types

using BaseType
using ItemType

Private Attributes

vector< Bin_bins
vector< double > _borders
vector< int > _indices

Friends

class ItemRegistry

Detailed Description

TimeGrid is an abstract class that defines the interface for time grids that can be used, for example, to specify the time bins in a light curve instrument.

A time grid consists of one or more non-overlapping, nonempty time bins in increasing time order. Each bin is defined by its left and right borders and has a characteristic time that falls inside the bin. The left border is considered to be inside the bin; the right border is considered to be outside of the bin. Neighboring bins may have a common border but can also be disconnected. Note that time values can be negative.

Formally, assuming \(N>0\) bins with zero-based indices, we have

\[ t^\mathrm{left}_k \le t^\mathrm{c}_k < t^\mathrm{right}_k, \quad k=0\dots N-1 \]

and if \(N>1\), we additionally have

\[ t^\mathrm{right}_k \le t^\mathrm{left}_{k+1}, \quad k=0\dots N-2. \]

Finally, each bin of course has an associated bin width,

\[t^\mathrm{right}_k - t^\mathrm{left}_k > 0, \quad k=0\dots N-1.\]

The public interface offers functions to obtain the properties of each bin, and to determine the (index of the) bin that contains a given time point.

A TimeGrid subclass is expected to implement the getTimeBins() function, which is invoked by this base class during setup to initialize the time grid.

Constructor & Destructor Documentation

◆ TimeGrid()

TimeGrid::TimeGrid ( )
inlineprotected

Default constructor for abstract Item subclass TimeGrid: "a time grid".

Member Function Documentation

◆ binForDistance()

int TimeGrid::binForDistance ( double distance) const

This function returns the index \(k\) of the time bin that contains the time corresponding to the specified distance \(d\) at the speed of light, i.e. the bin for which \(t^\mathrm{left}_k \le d/c < t^\mathrm{right}_k\). If no times bins match this condition, the function returns -1.

◆ binForTime()

int TimeGrid::binForTime ( double time) const

This function returns the index \(k\) of the time bin that contains the specified time \(t\), i.e. for which \(t^\mathrm{left}_k \le t < t^\mathrm{right}_k\). If no times bins match this condition, the function returns -1.

◆ getTimeBins()

virtual void TimeGrid::getTimeBins ( vector< Bin > & bins) const
protectedpure virtual

This function must be implemented in a subclass; it is invoked by this base class during setup. The function must place the time bins for this grid in the specified vector, which is guaranteed to be empty upon invocation. The bins must be sorted in increasing order and must otherwise conform to the restrictions listed in the class header.

Implemented in FileTimeGrid, LinTimeGrid, and LogTimeGrid.

◆ left()

double TimeGrid::left ( int k) const

This function returns the left border \(t^\mathrm{left}_k\) of the bin corresponding to the index \(k\).

◆ numBins()

int TimeGrid::numBins ( ) const

This function returns the number of bins \(N\) in the grid.

◆ range()

Range TimeGrid::range ( ) const

This function returns the range covered by the time grid, running from the left border of the leftmost bin to the right border of the rightmost bin.

◆ right()

double TimeGrid::right ( int k) const

This function returns the right border \(t^\mathrm{right}_k\) of the bin corresponding to the index \(k\).

◆ setupSelfBefore()

void TimeGrid::setupSelfBefore ( )
overrideprotectedvirtual

This function invokes the getTimeBins() function, implemented in each subclass, to obtain a list of time bins. After verifying that the bins are properly formed and sorted, the function builds a data structure that allows the bin() function, implemented here, to efficiently locate the bin containing a given time point.

Reimplemented from SimulationItem.

◆ time()

double TimeGrid::time ( int k) const

This function returns the characteristic time \(t^\mathrm{c}_k\) for the bin corresponding to the index \(k\).

◆ width()

double TimeGrid::width ( int k) const

This function returns width \(t^\mathrm{right}_k - t^\mathrm{left}_k\) of the bin corresponding to the index \(k\).


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