1.4.1
CCC
 
Grid Class Reference

#include <Grid.hpp>

Inheritance diagram for Grid:
AStringable

Public Member Functions

 Grid (int ndim=0, const VectorInt &nx=VectorInt(), const VectorDouble &x0=VectorDouble(), const VectorDouble &dx=VectorDouble())
 
 Grid (const Grid &r)
 
Gridoperator= (const Grid &r)
 
virtual ~Grid ()
 
void resetFromSpaceDimension (int ndim)
 
void resetFromGrid (Grid *grid)
 
int resetFromVector (const VectorInt &nx=VectorInt(), const VectorDouble &dx=VectorDouble(), const VectorDouble &x0=VectorDouble(), const VectorDouble &angles=VectorDouble())
 
void setX0 (int idim, double value)
 
void setDX (int idim, double value)
 
void setNX (int idim, int value)
 
void setRotationByMatrix (const MatrixSquareGeneral &rotmat)
 
void setRotationByVector (const VectorDouble &rotmat)
 
void setRotationByAngles (const VectorDouble &angles)
 
void setRotationByAngle (double angle)
 
int getNDim () const
 
double getX0 (int idim) const
 
double getDX (int idim) const
 
int getNX (int idim) const
 
int getNTotal () const
 
double getCellSize () const
 
double getExtend (int idim, bool flagCell=false) const
 
double getVolume (bool flagCell=false) const
 
VectorDouble getExtends (bool flagCell=false) const
 
virtual String toString (const AStringFormat *strfmt=nullptr) const override
 Interface to AStringable. More...
 
void copyParams (int mode, const Grid &gridaux)
 
double getCoordinate (int rank, int idim, bool flag_rotate=true) const
 
VectorDouble getCoordinatesByRank (int rank, bool flag_rotate=true) const
 
VectorDouble getCoordinatesByIndice (const VectorInt &indice, bool flag_rotate=true, const VectorInt &shift=VectorInt(), const VectorDouble &dxsPerCell=VectorDouble()) const
 
VectorDouble getCoordinatesByCorner (const VectorInt &icorner) const
 
VectorDouble getCellCoordinatesByCorner (int node, const VectorInt &shift=VectorInt(), const VectorDouble &dxsPerCell=VectorDouble()) const
 
double indiceToCoordinate (int idim0, const VectorInt &indice, const VectorDouble &percent=VectorDouble(), bool flag_rotate=true) const
 
VectorDouble indicesToCoordinate (const VectorInt &indice, const VectorDouble &percent=VectorDouble()) const
 
void indicesToCoordinateInPlace (const VectorInt &indice, VectorDouble &coor, const VectorDouble &percent=VectorDouble(), bool flag_rotate=true) const
 
double rankToCoordinate (int idim0, int rank, const VectorDouble &percent=VectorDouble()) const
 
VectorDouble rankToCoordinates (int rank, const VectorDouble &percent=VectorDouble()) const
 
void rankToCoordinatesInPlace (int rank, VectorDouble &coor, const VectorDouble &percent=VectorDouble()) const
 
int indiceToRank (const VectorInt &indice) const
 
void rankToIndice (int rank, VectorInt &indices, bool minusOne=false) const
 
VectorInt coordinateToIndices (const VectorDouble &coor, bool centered=false, double eps=EPSILON6) const
 
int coordinateToIndicesInPlace (const VectorDouble &coor, VectorInt &indice, bool centered=false, double eps=EPSILON6) const
 
int coordinateToRank (const VectorDouble &coor, bool centered=false, double eps=EPSILON6) const
 
VectorInt getCenterIndices () const
 
VectorInt generateGridIndices (const String &string, bool startFromZero=true, bool invert=true, bool verbose=false) const
 
bool sampleBelongsToCell (const VectorDouble &coor, const VectorDouble &center, const VectorDouble &dxsPerCell=VectorDouble()) const
 
bool sampleBelongsToCell (const VectorDouble &coor, int rank, const VectorDouble &dxsPerCell=VectorDouble()) const
 
VectorDouble getRotAngles () const
 
VectorDouble getRotMat () const
 
double getRotAngle (int idim) const
 
VectorInt getNXs () const
 
VectorDouble getX0s () const
 
VectorDouble getDXs () const
 
const RotationgetRotation () const
 
bool isSame (const Grid &grid) const
 
bool isSameMesh (const Grid &grid) const
 
bool isRotated () const
 
bool isSameRotation (const Grid &grid) const
 
VectorDouble getAxis (int idim) const
 
void iteratorInit (const VectorInt &order=VectorInt())
 
VectorInt iteratorNext (void)
 
bool empty () const
 
void dilate (int mode, const VectorInt &nshift, VectorInt &nx, VectorDouble &dx, VectorDouble &x0) const
 
void multiple (const VectorInt &nmult, bool flagCell, VectorInt &nx, VectorDouble &dx, VectorDouble &x0) const
 
void divider (const VectorInt &nmult, bool flagCell, VectorInt &nx, VectorDouble &dx, VectorDouble &x0) const
 
int getMirrorIndex (int idim, int ix) const
 
- Public Member Functions inherited from AStringable
 AStringable ()
 
 AStringable (const AStringable &r)
 
AStringableoperator= (const AStringable &r)
 
virtual ~AStringable ()
 
virtual void display (const AStringFormat *strfmt=nullptr) const final
 
virtual void display (int level) const final
 

Static Public Member Functions

static VectorInt gridIndices (const VectorInt &nx, const String &string, bool startFromZero=true, bool invert=true, bool verbose=false)
 
static int generateMirrorIndex (int nx, int ix)
 

Constructor & Destructor Documentation

◆ Grid() [1/2]

Grid::Grid ( int  ndim = 0,
const VectorInt nx = VectorInt(),
const VectorDouble x0 = VectorDouble(),
const VectorDouble dx = VectorDouble() 
)

◆ Grid() [2/2]

Grid::Grid ( const Grid r)

◆ ~Grid()

Grid::~Grid ( )
virtual

Member Function Documentation

◆ coordinateToIndices()

VectorInt Grid::coordinateToIndices ( const VectorDouble coor,
bool  centered = false,
double  eps = EPSILON6 
) const

◆ coordinateToIndicesInPlace()

int Grid::coordinateToIndicesInPlace ( const VectorDouble coor,
VectorInt indice,
bool  centered = false,
double  eps = EPSILON6 
) const

Find the grid node to which the current sample is assigned

Parameters
coorSample coordinates
indiceIndices of the assigned grid node
centeredTrue for grid cell centered
epsEpsilon to over-pass roundoff problem
Returns
Error return code

◆ coordinateToRank()

int Grid::coordinateToRank ( const VectorDouble coor,
bool  centered = false,
double  eps = EPSILON6 
) const

◆ copyParams()

void Grid::copyParams ( int  mode,
const Grid gridaux 
)

Copy some parameters from Gridaux

Parameters
modeType of parameters to be copied 1 : Array of Grid Number of meshes 2 : Array of Grid origin 3 : Array of Grid Meshes 4 : Rotation
gridauxSource Grid structure

◆ dilate()

void Grid::dilate ( int  mode,
const VectorInt nshift,
VectorInt nx,
VectorDouble dx,
VectorDouble x0 
) const

Returns the characteristics of a dilated grid

Parameters
[in]mode1 for extending; -1 for compressing
[in]nshiftArray of shifts
[out]nxArray of number of grid meshes
[out]dxArray of grid meshes
[out]x0Array of grid origins

◆ divider()

void Grid::divider ( const VectorInt nmult,
bool  flagCell,
VectorInt nx,
VectorDouble dx,
VectorDouble x0 
) const

Returns the characteristics of a divider grid

Parameters
[in]nmultArray of subdivision coefficients
[in]flagCelltrue for cell matching; 0 for point matching
[out]nxArray of number of grid meshes
[out]dxArray of grid meshes
[out]x0Array of grid origins

◆ empty()

bool Grid::empty ( ) const

◆ generateGridIndices()

VectorInt Grid::generateGridIndices ( const String string,
bool  startFromZero = true,
bool  invert = true,
bool  verbose = false 
) const

◆ generateMirrorIndex()

int Grid::generateMirrorIndex ( int  nx,
int  ix 
)
static

Return the index of a sample when calculated from mirroring within an array whose indices vary between 0 and nx-1

Returns
Rank of the restrained cell
Parameters
[in]nxNumber of cells
[in]ixRank of the cell to be restrained

◆ getAxis()

VectorDouble Grid::getAxis ( int  idim) const

Returns a vector with the coordinates along one axis. This is needed for the label of Grid representation Warning: Not considering any possible rotation.

Parameters
idimIndex of the Space Dimension
Returns

◆ getCellCoordinatesByCorner()

VectorDouble Grid::getCellCoordinatesByCorner ( int  node,
const VectorInt shift = VectorInt(),
const VectorDouble dxsPerCell = VectorDouble() 
) const

Returns the coordinates of a Grid cell corner

Parameters
nodeRank of the Target cell
shiftVector of shifts (dimension: ndim) 0 : no shift; -1 : minus half a cell-width; +1 plus half a cell-width
dxsPerCellVector of variable mesh extensions at target cell
Returns
The coordinates of a cell corner (possibly shifted)

◆ getCellSize()

double Grid::getCellSize ( ) const

◆ getCenterIndices()

VectorInt Grid::getCenterIndices ( ) const

◆ getCoordinate()

double Grid::getCoordinate ( int  rank,
int  idim,
bool  flag_rotate = true 
) const

◆ getCoordinatesByCorner()

VectorDouble Grid::getCoordinatesByCorner ( const VectorInt icorner) const

Returns the coordinates of a Grid corner

Parameters
icornerVector specifying the corner (0: minimum; 1: maximum). (Dimension: ndim)
Returns
The coordinates of a corner

◆ getCoordinatesByIndice()

VectorDouble Grid::getCoordinatesByIndice ( const VectorInt indice,
bool  flag_rotate = true,
const VectorInt shift = VectorInt(),
const VectorDouble dxsPerCell = VectorDouble() 
) const

Returns the coordinates of a grid node, defined by its indices

Parameters
indiceVector of indices defining the target grid node
flag_rotateTrue if the grid rotation must be taken into account
shiftVector of shifts (dimension: ndim) 0 : no shift; -1 : minus half a cell-width; +1 plus half a cell-width
dxsPerCellVector of variable grid meshes (optional)
Returns

◆ getCoordinatesByRank()

VectorDouble Grid::getCoordinatesByRank ( int  rank,
bool  flag_rotate = true 
) const

Return the Vector of coordinates for a given grid node

Parameters
rankRank of the target grid node
flag_rotateTRUE: perform the rotation; FALSE: skip rotation
Returns
Vector of coordinates

◆ getDX()

double Grid::getDX ( int  idim) const

◆ getDXs()

VectorDouble Grid::getDXs ( ) const
inline

◆ getExtend()

double Grid::getExtend ( int  idim,
bool  flagCell = false 
) const

◆ getExtends()

VectorDouble Grid::getExtends ( bool  flagCell = false) const

◆ getMirrorIndex()

int Grid::getMirrorIndex ( int  idim,
int  ix 
) const

Return the index of a sample when calculated from mirroring within an array whose indices vary between 0 and nx-1

Returns
Rank of the restrained cell
Parameters
[in]idimRank of the space dimension
[in]ixRank of the cell to be restrained

◆ getNDim()

int Grid::getNDim ( ) const
inline

◆ getNTotal()

int Grid::getNTotal ( ) const

◆ getNX()

int Grid::getNX ( int  idim) const

◆ getNXs()

VectorInt Grid::getNXs ( ) const
inline

◆ getRotAngle()

double Grid::getRotAngle ( int  idim) const
inline

◆ getRotAngles()

VectorDouble Grid::getRotAngles ( ) const
inline

◆ getRotation()

const Rotation& Grid::getRotation ( ) const
inline

◆ getRotMat()

VectorDouble Grid::getRotMat ( ) const
inline

◆ getVolume()

double Grid::getVolume ( bool  flagCell = false) const

◆ getX0()

double Grid::getX0 ( int  idim) const

◆ getX0s()

VectorDouble Grid::getX0s ( ) const
inline

◆ gridIndices()

VectorInt Grid::gridIndices ( const VectorInt nx,
const String string,
bool  startFromZero = true,
bool  invert = true,
bool  verbose = false 
)
static

Returns an array giving the ranks of the nodes (according to user's order) coded with standard order (according to gstlearn internal order)

Returns
Array of indices
Parameters
[in]nxArray giving the number of cells per direction
[in]stringString describing the sorting order
[in]startFromZeroTrue if numbering must start from 0 (1 otherwise)
[in]invertWay to use the resulting array (see remark)
[in]verboseVerbose flag
Remarks
Example of string: "+x2-x1"
if 'rank' designates the resulting vector of indices
invert=True:
rank[i] is the location of element 'i' of the user's array
within a regular grid of gstlearn
invert=False:
rank[i] is the rank of the element of the user's array
in position 'i' of the regular grid of gstlearn

◆ indicesToCoordinate()

VectorDouble Grid::indicesToCoordinate ( const VectorInt indice,
const VectorDouble percent = VectorDouble() 
) const

◆ indicesToCoordinateInPlace()

void Grid::indicesToCoordinateInPlace ( const VectorInt indice,
VectorDouble coor,
const VectorDouble percent = VectorDouble(),
bool  flag_rotate = true 
) const

◆ indiceToCoordinate()

double Grid::indiceToCoordinate ( int  idim0,
const VectorInt indice,
const VectorDouble percent = VectorDouble(),
bool  flag_rotate = true 
) const

◆ indiceToRank()

int Grid::indiceToRank ( const VectorInt indice) const

◆ isRotated()

bool Grid::isRotated ( ) const
inline

◆ isSame()

bool Grid::isSame ( const Grid grid) const

Check that the current grid match the one provided as argument up to their common Space Dimension

Parameters
gridTarget grid to be checked against the current one
Returns
True if the grid match

◆ isSameMesh()

bool Grid::isSameMesh ( const Grid grid) const

◆ isSameRotation()

bool Grid::isSameRotation ( const Grid grid) const
inline

◆ iteratorInit()

void Grid::iteratorInit ( const VectorInt order = VectorInt())

Initialize an iterator on the grid

Parameters
orderArray giving the order of the Space Dimensions when iterating

◆ iteratorNext()

VectorInt Grid::iteratorNext ( void  )

Return the vector of grid indices for each iteration

Returns

◆ multiple()

void Grid::multiple ( const VectorInt nmult,
bool  flagCell,
VectorInt nx,
VectorDouble dx,
VectorDouble x0 
) const

Returns the characteristics of a multiple grid

Parameters
[in]nmultArray of multiplicity coefficients
[in]flagCelltrue for cell matching; 0 for point matching
[out]nxArray of number of grid meshes
[out]dxArray of grid meshes
[out]x0Array of grid origins

◆ operator=()

Grid & Grid::operator= ( const Grid r)

◆ rankToCoordinate()

double Grid::rankToCoordinate ( int  idim0,
int  rank,
const VectorDouble percent = VectorDouble() 
) const

◆ rankToCoordinates()

VectorDouble Grid::rankToCoordinates ( int  rank,
const VectorDouble percent = VectorDouble() 
) const

◆ rankToCoordinatesInPlace()

void Grid::rankToCoordinatesInPlace ( int  rank,
VectorDouble coor,
const VectorDouble percent = VectorDouble() 
) const

◆ rankToIndice()

void Grid::rankToIndice ( int  rank,
VectorInt indices,
bool  minusOne = false 
) const
Parameters
rankRank of the Node (in the meshing)
indicesIndices of the node in the grid system
minusOneConsider that the number of cells in each direction should be reduced by one.
Remarks
: The number of nodes in the grid per direction
: must be adapted (subtracting 1) due to interval.

◆ resetFromGrid()

void Grid::resetFromGrid ( Grid grid)

◆ resetFromSpaceDimension()

void Grid::resetFromSpaceDimension ( int  ndim)

◆ resetFromVector()

int Grid::resetFromVector ( const VectorInt nx = VectorInt(),
const VectorDouble dx = VectorDouble(),
const VectorDouble x0 = VectorDouble(),
const VectorDouble angles = VectorDouble() 
)

◆ sampleBelongsToCell() [1/2]

bool Grid::sampleBelongsToCell ( const VectorDouble coor,
const VectorDouble center,
const VectorDouble dxsPerCell = VectorDouble() 
) const

Check if a sample belongs to a Grid Cell

Parameters
coorSample coordinates
centerCoordinates of the grid node center
dxsPerCellWhen defined, vector of cell extension; otherwise use dx
Returns
Error return code
Remarks
Samples located exactly on the edge are considered as INSIDE

◆ sampleBelongsToCell() [2/2]

bool Grid::sampleBelongsToCell ( const VectorDouble coor,
int  rank,
const VectorDouble dxsPerCell = VectorDouble() 
) const

Check if a sample belongs to a Grid Cell

Parameters
coorSample coordinates (can be lower space dimension than the current Grid)
rankRank of the Grid cell
dxsPerCellWhen defined, vector of cell extension; otherwise use dx
Returns
Error return code
Remarks
Samples located exactly on the edge are considered as INSIDE

◆ setDX()

void Grid::setDX ( int  idim,
double  value 
)

◆ setNX()

void Grid::setNX ( int  idim,
int  value 
)

◆ setRotationByAngle()

void Grid::setRotationByAngle ( double  angle)

Define the rotation by the value of its first angle

Parameters
angleValue of the first rotation angle

◆ setRotationByAngles()

void Grid::setRotationByAngles ( const VectorDouble angles)

◆ setRotationByMatrix()

void Grid::setRotationByMatrix ( const MatrixSquareGeneral rotmat)

◆ setRotationByVector()

void Grid::setRotationByVector ( const VectorDouble rotmat)

◆ setX0()

void Grid::setX0 ( int  idim,
double  value 
)

◆ toString()

String Grid::toString ( const AStringFormat strfmt = nullptr) const
overridevirtual

Interface to AStringable.

Reimplemented from AStringable.


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