Gradient Augmented Levelset Implementation in CPU & GPU
Grid< T, DIM > Class Template Reference

#include <grid.h>

Public Types

using value_type = T
 
using position_type = Vec3< T >
 

Public Member Functions

 Grid (int nx, int ny, int nz)
 
 Grid (int nx, int ny)
 
 Grid (int nx)
 
 ~Grid ()
 
Vec3< T > & x (const int i, const int j=0, const int k=0)
 
const int dimension () const
 
const int size () const
 
const int * getMask () const
 
const Vec3< int > numCells () const
 
const size_t totalCells () const
 
const int getPadding () const
 
const std::size_t index (const int i, const int j, const int k) const
 
const std::size_t index (const Vec3< int > node_id) const
 
const Vec3< int > baseNodeId (const Vec3< T > &x) const
 
const Vec3< T > & dX () const
 
const Vec3< T > & oneOverDX () const
 
const Vec3< T > & operator() (const int i, const int j, const int k) const
 
const Vec3< T > & operator() (const Vec3< int > node_id) const
 
void setPadding (const int pad)
 
void generate (T x_min, T x_max, T y_min, T y_max, T z_min, T z_max)
 

Static Public Attributes

static constexpr int dim = DIM
 Dimension. More...
 
static const Mat3< int > axis_vectors = Mat3<int>(1, 0, 0, 0, 1, 0, 0, 0, 1)
 vector along x: {1, 0, 0}; y: {0, 1, 0}; z: {0, 0, 1}. More...
 
static const Mat3< T > identity_mat = Mat3<T>(1, 0, 0, 0, 1, 0, 0, 0, 1)
 
static constexpr int num_mixed_derivatives = GALS::CPU::num_mixed_derivatives(DIM)
 Number of mixed derivatives. More...
 

Detailed Description

template<typename T, int DIM = 3>
class GALS::CPU::Grid< T, DIM >

Class to create grid.

Definition at line 68 of file grid.h.

Member Typedef Documentation

using position_type = Vec3<T>

Definition at line 72 of file grid.h.

using value_type = T

Definition at line 71 of file grid.h.

Constructor & Destructor Documentation

Grid ( int  nx,
int  ny,
int  nz 
)

Constructor with arguments for number of cells across x, y, z.

Parameters
nxNo. of cells across x-direction.
nyNo. of cells across y-direction.
nzNo. of cells across z-direction.

Definition at line 41 of file grid.cc.

Grid ( int  nx,
int  ny 
)

Constructor with arguments for number of cells across x, y.

Number of cells across z-direction is defaulted to 1.

Parameters
nxNo. of cells across x-direction.
nyNo. of cells across y-direction.

Definition at line 58 of file grid.cc.

Grid ( int  nx)

Constructor with arguments for number of cells across x.

Number of cells across y, z-directions are defaulted to 1.

Parameters
nxNo. of cells across x-direction.

Definition at line 63 of file grid.cc.

~Grid ( )

Destructor

Definition at line 68 of file grid.cc.

Member Function Documentation

const GALS::CPU::Vec3< int > baseNodeId ( const Vec3< T > &  x) const

Return base node id (i, j, k) that encloses given position.

Parameters
xposition.
Returns
base node id (i, j, k).

Definition at line 132 of file grid.cc.

const int dimension ( ) const

Returns dimension of grid.

Returns
dimension of grid.

Definition at line 81 of file grid.cc.

const GALS::CPU::Vec3< T > & dX ( ) const

Returns cell size which is a vector of size 3.

Returns
cell size.

Definition at line 144 of file grid.cc.

void generate ( x_min,
x_max,
y_min,
y_max,
z_min,
z_max 
)

Generate grid using domain bounding box.

Parameters
x_minminimum x-coordinate.
x_maxmaximum x-coordinate.
y_minminimum y-coordinate.
y_maxmaximum y-coordinate.
z_minminimum z-coordinate.
z_maxmaximum z-coordinate.

Definition at line 174 of file grid.cc.

const int * getMask ( ) const

Returns pointer to mask.

For efficient computation of 3D index to 1D index a mask is used to differentiate between 1, 2, 3 dimentions.

  • mask = {1, 0, 0} for 1D
  • mask = {1, 1, 0} for 2D
  • mask = {1, 1, 1} for 3D
Returns
integer pointer that points to integer array of size 3.

Definition at line 93 of file grid.cc.

const int getPadding ( ) const

Return current padding.

Returns
padding.

Definition at line 111 of file grid.cc.

const std::size_t index ( const int  i,
const int  j,
const int  k 
) const

Returns 1D index in stored array.

3D to 1D index mapping.

Parameters
izero based index along x-direction.
jzero based index along y-direction.
kzero based index along z-direction.
Returns
1D index.

Definition at line 117 of file grid.cc.

const std::size_t index ( const Vec3< int >  node_id) const

Given a node id, returns 1D index in stored array.

Parameters
node_idnode id of type GALS::CPU::Vec3<int>.
Returns
1D index.

Definition at line 126 of file grid.cc.

const GALS::CPU::Vec3< int > numCells ( ) const

Returns a vector of size 3 with number of cells along x, y, z directions.

Vector of size 3: {nx, ny, nz}.

Returns
vector of size 3.

Definition at line 99 of file grid.cc.

const GALS::CPU::Vec3< T > & oneOverDX ( ) const

Returns one over cell size which is a vector of size 3.

Returns
one over cell size.

Definition at line 150 of file grid.cc.

const GALS::CPU::Vec3< T > & operator() ( const int  i,
const int  j,
const int  k 
) const

Operator overloaded to return co-ordinate values at a given 3D index.

Returns
position.

Definition at line 156 of file grid.cc.

const GALS::CPU::Vec3< T > & operator() ( const Vec3< int >  node_id) const

Operator overloaded to return co-ordinate values at a given 3D index.

Parameters
node_idnode index of type NodeId.
Returns
position.

Definition at line 162 of file grid.cc.

void setPadding ( const int  pad)

Set new padding value.

When used this, generate(...) function must be called immediately after setting new padding.

Parameters
padnew padding value.

Definition at line 168 of file grid.cc.

const int size ( ) const

Returns 1D array size of grid.

Data of grid is stored in 1D array with some padding. This function returns 1D array size.

Returns
1D array size.

Definition at line 87 of file grid.cc.

const size_t totalCells ( ) const

Returns total number of cells excluding ghost (padded) cells.

Returns
number of cells of type size_t.

Definition at line 105 of file grid.cc.

GALS::CPU::Vec3< T > & x ( const int  i,
const int  j = 0,
const int  k = 0 
)

Returns position at a given index.

Parameters
izero based index along x-direction.
jzero based index along y-direction.
kzero based index along z-direction.
Returns
3D position vector.

Definition at line 75 of file grid.cc.

Field Documentation

const Mat3< int > axis_vectors = Mat3<int>(1, 0, 0, 0, 1, 0, 0, 0, 1)
static

vector along x: {1, 0, 0}; y: {0, 1, 0}; z: {0, 0, 1}.

Definition at line 78 of file grid.h.

constexpr int dim = DIM
static

Dimension.

Definition at line 75 of file grid.h.

const Mat3< T > identity_mat = Mat3<T>(1, 0, 0, 0, 1, 0, 0, 0, 1)
static

Definition at line 79 of file grid.h.

constexpr int num_mixed_derivatives = GALS::CPU::num_mixed_derivatives(DIM)
static

Number of mixed derivatives.

Definition at line 82 of file grid.h.


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