criptic v1
Cosmic Ray Interstellar Propagation Tool using Itô Calculus
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Private Attributes | List of all members
criptic::gas::CartesianGrid Class Reference

Describe a gas with properties stored on a Cartesian grid. More...

#include <CartesianGrid.H>

Inheritance diagram for criptic::gas::CartesianGrid:
criptic::gas::Gas

Public Types

enum  gasIdxType {
  denIdx = 0 , ionDenIdx , vxIdx , vyIdx ,
  vzIdx , BxIdx , ByIdx , BzIdx ,
  xH0Idx , xHpIdx , xHe0Idx , xHepIdx ,
  xHep2Idx , xeIdx , ZIdx , nf
}
 Convenience enum to give specify indices in gas array. More...
 

Public Member Functions

 CartesianGrid (const ParmParser &pp, const Geometry &geom_, const IdxType nBB_, const int nGhost_=1)
 Constructor.
 
 CartesianGrid (const IdxVec &nGrid_, const Geometry &geom_, const IdxType nBB_, const int nGhost_=1)
 Constructor with manually-specified grid size.
 
virtual void frame (const RealVec &x, const Real t, RealVec &v, TNBBasis &tnb) const override
 Compute the comoving TNB frame for the gas.
 
virtual GasData gasData (const RealVec &x, const Real t) const override
 Return background gas state.
 
virtual Real dxGhost () const override
 Size of the ghost region in the gas data.
 
void applyBC ()
 Fill the ghost cells using the specified boundary condition.
 
const IdxVecgridSize () const
 Return the grid size.
 
IdxType nComponents () const
 Return the number of components.
 
const RealBoxxBox () const
 Return the domain bounding box.
 
const RealVecxLo () const
 Return low boundary of computational domain.
 
const RealVecxHi () const
 Return high boundary of computational domain.
 
const RealVecxSize () const
 Return size of computational domain.
 
template<class T , std::enable_if_t< std::is_integral< T >::value, bool > = true>
IdxType idx (const Vec3< T > &iv, IdxType n) const
 Convert an ((i,j,k),n) index to a memory location.
 
void posToIdx (const RealVec &x, SIdxVec &iv, RealVec &f) const
 Convert a physical position to cell coordinates.
 
template<class T , std::enable_if_t< std::is_integral< T >::value, bool > = true>
RealVec idxToPos (const Vec3< T > &iv, const RealVec &f=zeroIdxVec) const
 Convert a position in cell coordinates to a physical position.
 
template<class T , std::enable_if_t< std::is_integral< T >::value, bool > = true>
Realoperator() (const Vec3< T > &iv, const IdxType n)
 Access data by index.
 
template<class T , std::enable_if_t< std::is_integral< T >::value, bool > = true>
const Realoperator() (const Vec3< T > &iv, const IdxType n) const
 Access data by index.
 
Realoperator() (const SignedIdxType i, const SignedIdxType j, const SignedIdxType k, const IdxType n)
 Access data by index.
 
const Realoperator() (const SignedIdxType i, const SignedIdxType j, const SignedIdxType k, const IdxType n) const
 Access data by index.
 
template<class T , std::enable_if_t< std::is_integral< T >::value, bool > = true>
std::vector< Realinterp (const Vec3< T > &iv, const RealVec &f, const IdxType sComp=0, const IdxType eComp=maxIdx) const
 Linearly interpolate grid data to specified point.
 
template<class T , std::enable_if_t< std::is_integral< T >::value, bool > = true>
RealVec interpVec (const Vec3< T > &iv, const RealVec &f, const IdxType c) const
 Linearly interpolate one vector component to a given point.
 
template<class T , std::enable_if_t< std::is_integral< T >::value, bool > = true>
RealVec interpGradScalar (const Vec3< T > &iv, const RealVec &f, const IdxType c) const
 Compute gradient of a scalar quantity by linear interpolation.
 
template<class T , std::enable_if_t< std::is_integral< T >::value, bool > = true>
RealTensor2 interpGradVector (const Vec3< T > &iv, const RealVec &f, const IdxType c) const
 Compute gradient of a vector quantity by linear interpolation.
 
- Public Member Functions inherited from criptic::gas::Gas
virtual ~Gas ()
 Empty virtual destructor.
 
virtual void updateState (const Real t, Real &tNext)
 Update the gas data.
 

Private Attributes

const Geometrygeom
 
IdxVec nGrid
 
IdxType nComp
 
IdxType nBB
 
IdxType nGhost
 
RealVec dx
 
std::vector< Realdata
 

Detailed Description

Describe a gas with properties stored on a Cartesian grid.

This class provides the ability to describe a gas whose properties are specified on a time-independent, cell-centered Cartesian grid. Many of the routines in this class make use of the idea of cell coordinates, defined as coordinate system with an integer part iv that specifies which cell the position is in, and a real part f that specifies where within the cell the point is located, with f going from -0.5 to +0.5; f = 0 corresponds to the cell center.

Member Enumeration Documentation

◆ gasIdxType

Convenience enum to give specify indices in gas array.

Radiation fields are not included in this enum, because the number of components is variable.

Enumerator
denIdx 
ionDenIdx 
vxIdx 
vyIdx 
vzIdx 
BxIdx 
ByIdx 
BzIdx 
xH0Idx 
xHpIdx 
xHe0Idx 
xHepIdx 
xHep2Idx 
xeIdx 
ZIdx 
nf 

Constructor & Destructor Documentation

◆ CartesianGrid() [1/2]

CartesianGrid::CartesianGrid ( const ParmParser pp,
const Geometry geom_,
const IdxType  nBB_,
const int  nGhost_ = 1 
)

Constructor.

Parameters
ppcriptic::ParmParser object containing the input deck
geom_criptic::Geometry object describing problem geometry
nBB_Number of blackbody radiation components
nGhost_Number of ghost zones to add to grid

◆ CartesianGrid() [2/2]

CartesianGrid::CartesianGrid ( const IdxVec nGrid_,
const Geometry geom_,
const IdxType  nBB_,
const int  nGhost_ = 1 
)

Constructor with manually-specified grid size.

Parameters
nGrid_Grid size
geom_criptic::Geometry object describing problem geometry
nBB_Number of blackbody radiation components
nGhost_Number of ghost zones to add to grid

Member Function Documentation

◆ applyBC()

void CartesianGrid::applyBC ( )

Fill the ghost cells using the specified boundary condition.

◆ dxGhost()

virtual Real criptic::gas::CartesianGrid::dxGhost ( ) const
inlineoverridevirtual

Size of the ghost region in the gas data.

Returns
Ghost region size

This returns the physical size of the ghost region.

Reimplemented from criptic::gas::Gas.

◆ frame()

void CartesianGrid::frame ( const RealVec x,
const Real  t,
RealVec v,
TNBBasis tnb 
) const
inlineoverridevirtual

Compute the comoving TNB frame for the gas.

Parameters
xPosition
tTime
vComoving velocity at specified position and time
tnbThe TNBBasis at the specified position and time

This function computes the comoving TNB frame for the gas at a specified position and time.

Reimplemented from criptic::gas::Gas.

◆ gasData()

GasData CartesianGrid::gasData ( const RealVec x,
const Real  t 
) const
inlineoverridevirtual

Return background gas state.

Parameters
xPosition
tTime
Returns
GasData at specified (x, t)

This method return the GasData describing the gas at the input (x, t).

Implements criptic::gas::Gas.

◆ gridSize()

const IdxVec & criptic::gas::CartesianGrid::gridSize ( ) const
inline

Return the grid size.

Returns
The number of real (non-ghost) cells in the grid

◆ idx()

template<class T , std::enable_if_t< std::is_integral< T >::value, bool > = true>
IdxType criptic::gas::CartesianGrid::idx ( const Vec3< T > &  iv,
IdxType  n 
) const
inline

Convert an ((i,j,k),n) index to a memory location.

Parameters
ivPosition index (i,j,k)
nField index n
Returns
Offset in memory from start of data array

◆ idxToPos()

template<class T , std::enable_if_t< std::is_integral< T >::value, bool > = true>
RealVec criptic::gas::CartesianGrid::idxToPos ( const Vec3< T > &  iv,
const RealVec f = zeroIdxVec 
) const
inline

Convert a position in cell coordinates to a physical position.

Parameters
ivIndex of cell
fCell position
Returns
Physical position

◆ interp()

template<class T , std::enable_if_t< std::is_integral< T >::value, bool > = true>
std::vector< Real > criptic::gas::CartesianGrid::interp ( const Vec3< T > &  iv,
const RealVec f,
const IdxType  sComp = 0,
const IdxType  eComp = maxIdx 
) const
inline

Linearly interpolate grid data to specified point.

Parameters
ivCell within which target point lies
fPosition within cell in cell coordinates
sCompStarting component
eCompEnding component
Returns
Data interpolated to point

The components returned are [sComp, eComp), so for example if sComp = 2 and eComp = 5, the routine will interpolate components 2, 3, and 4, but not 5.

◆ interpGradScalar()

template<class T , std::enable_if_t< std::is_integral< T >::value, bool > = true>
RealVec criptic::gas::CartesianGrid::interpGradScalar ( const Vec3< T > &  iv,
const RealVec f,
const IdxType  c 
) const
inline

Compute gradient of a scalar quantity by linear interpolation.

Parameters
ivCell within which target point lies
fPosition within cell in cell coordinates
cComponent whose gradient should be computed
Returns
Gradient of quantity at specified point

◆ interpGradVector()

template<class T , std::enable_if_t< std::is_integral< T >::value, bool > = true>
RealTensor2 criptic::gas::CartesianGrid::interpGradVector ( const Vec3< T > &  iv,
const RealVec f,
const IdxType  c 
) const
inline

Compute gradient of a vector quantity by linear interpolation.

Parameters
ivCell within which target point lies
fPosition within cell in cell coordinates
cStarting component of vector quantity
Returns
Gradient of quantity at specified point

◆ interpVec()

template<class T , std::enable_if_t< std::is_integral< T >::value, bool > = true>
RealVec criptic::gas::CartesianGrid::interpVec ( const Vec3< T > &  iv,
const RealVec f,
const IdxType  c 
) const
inline

Linearly interpolate one vector component to a given point.

Parameters
ivCell within which target point lies
fPosition within cell in cell coordinates
cStarting component of vector
Returns
Data interpolated to point

The components returned are [sComp, eComp), so for example if sComp = 2 and eComp = 5, the routine will interpolate components 2, 3, and 4, but not 5.

◆ nComponents()

IdxType criptic::gas::CartesianGrid::nComponents ( ) const
inline

Return the number of components.

Returns
The number of components

◆ operator()() [1/4]

Real & criptic::gas::CartesianGrid::operator() ( const SignedIdxType  i,
const SignedIdxType  j,
const SignedIdxType  k,
const IdxType  n 
)
inline

Access data by index.

Parameters
iFirst index
jSecond index
kThird index
nComponent

◆ operator()() [2/4]

const Real & criptic::gas::CartesianGrid::operator() ( const SignedIdxType  i,
const SignedIdxType  j,
const SignedIdxType  k,
const IdxType  n 
) const
inline

Access data by index.

Parameters
iFirst index
jSecond index
kThird index
nComponent

◆ operator()() [3/4]

template<class T , std::enable_if_t< std::is_integral< T >::value, bool > = true>
Real & criptic::gas::CartesianGrid::operator() ( const Vec3< T > &  iv,
const IdxType  n 
)
inline

Access data by index.

Parameters
ivSpatial index
nComponent

◆ operator()() [4/4]

template<class T , std::enable_if_t< std::is_integral< T >::value, bool > = true>
const Real & criptic::gas::CartesianGrid::operator() ( const Vec3< T > &  iv,
const IdxType  n 
) const
inline

Access data by index.

Parameters
ivSpatial index
nComponent

◆ posToIdx()

void criptic::gas::CartesianGrid::posToIdx ( const RealVec x,
SIdxVec iv,
RealVec f 
) const
inline

Convert a physical position to cell coordinates.

Parameters
xPhysical position
ivIndex of cell containing that position
fFractional position within the cell

◆ xBox()

const RealBox & criptic::gas::CartesianGrid::xBox ( ) const
inline

Return the domain bounding box.

Returns
Domain bounding box

◆ xHi()

const RealVec & criptic::gas::CartesianGrid::xHi ( ) const
inline

Return high boundary of computational domain.

Returns
High boundary of computational domain

◆ xLo()

const RealVec & criptic::gas::CartesianGrid::xLo ( ) const
inline

Return low boundary of computational domain.

Returns
Low boundary of computational domain

◆ xSize()

const RealVec & criptic::gas::CartesianGrid::xSize ( ) const
inline

Return size of computational domain.

Returns
Size of computational domain

Member Data Documentation

◆ data

std::vector<Real> criptic::gas::CartesianGrid::data
private

Data holder

◆ dx

RealVec criptic::gas::CartesianGrid::dx
private

Grid spacing

◆ geom

const Geometry& criptic::gas::CartesianGrid::geom
private

Problem geometry

◆ nBB

IdxType criptic::gas::CartesianGrid::nBB
private

Number of blackbody fields

◆ nComp

IdxType criptic::gas::CartesianGrid::nComp
private

Number of components

◆ nGhost

IdxType criptic::gas::CartesianGrid::nGhost
private

Number of ghost zones

◆ nGrid

IdxVec criptic::gas::CartesianGrid::nGrid
private

Size of grid (real cells only)


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