1.2.2
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 (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 flag_cell=false) const
 
double getVolume (bool flag_cell=false) const
 
VectorDouble getExtends (bool flag_cell=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 node, 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)
 
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
 
const VectorDouble getRotAngles () const
 
const VectorDouble getRotMat () const
 
double getRotAngle (int idim) const
 
const VectorInt getNXs () const
 
const VectorDouble getX0s () const
 
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, int flag_cell, VectorInt &nx, VectorDouble &dx, VectorDouble &x0) const
 
void divider (const VectorInt &nmult, int flag_cell, 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::Grid ( int  ndim = 0,
const VectorInt nx = VectorInt(),
const VectorDouble x0 = VectorDouble(),
const VectorDouble dx = VectorDouble() 
)
Grid::Grid ( const Grid r)
Grid::~Grid ( )
virtual

Member Function Documentation

VectorInt Grid::coordinateToIndices ( const VectorDouble coor,
bool  centered = false,
double  eps = EPSILON6 
) const
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
int Grid::coordinateToRank ( const VectorDouble coor,
bool  centered = false,
double  eps = EPSILON6 
) const
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
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
void Grid::divider ( const VectorInt nmult,
int  flag_cell,
VectorInt nx,
VectorDouble dx,
VectorDouble x0 
) const

Returns the characteristics of a divider grid

Parameters
[in]nmultArray of subdivision coefficients
[in]flag_cell1 for cell matching; 0 for point matching
[out]nxArray of number of grid meshes
[out]dxArray of grid meshes
[out]x0Array of grid origins
bool Grid::empty ( ) const
VectorInt Grid::generateGridIndices ( const String string,
bool  startFromZero = true,
bool  invert = true,
bool  verbose = false 
)
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
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
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)
double Grid::getCellSize ( ) const
VectorInt Grid::getCenterIndices ( ) const
double Grid::getCoordinate ( int  rank,
int  idim,
bool  flag_rotate = true 
) const
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
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
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
double Grid::getDX ( int  idim) const
const VectorDouble Grid::getDXs ( ) const
inline
double Grid::getExtend ( int  idim,
bool  flag_cell = false 
) const
VectorDouble Grid::getExtends ( bool  flag_cell = false) const
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
int Grid::getNDim ( ) const
inline
int Grid::getNTotal ( ) const
int Grid::getNX ( int  idim) const
const VectorInt Grid::getNXs ( ) const
inline
double Grid::getRotAngle ( int  idim) const
inline
const VectorDouble Grid::getRotAngles ( ) const
inline
const Rotation& Grid::getRotation ( ) const
inline
const VectorDouble Grid::getRotMat ( ) const
inline
double Grid::getVolume ( bool  flag_cell = false) const
double Grid::getX0 ( int  idim) const
const VectorDouble Grid::getX0s ( ) const
inline
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
VectorDouble Grid::indicesToCoordinate ( const VectorInt indice,
const VectorDouble percent = VectorDouble() 
) const
void Grid::indicesToCoordinateInPlace ( const VectorInt indice,
VectorDouble coor,
const VectorDouble percent = VectorDouble(),
bool  flag_rotate = true 
) const
double Grid::indiceToCoordinate ( int  idim0,
const VectorInt indice,
const VectorDouble percent = VectorDouble(),
bool  flag_rotate = true 
) const
int Grid::indiceToRank ( const VectorInt indice) const
bool Grid::isRotated ( ) const
inline
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
bool Grid::isSameMesh ( const Grid grid) const
bool Grid::isSameRotation ( const Grid grid) const
inline
void Grid::iteratorInit ( const VectorInt order = VectorInt())

Initialize an iterator on the grid

Parameters
orderArray giving the order of the Space Dimensions when iterating
VectorInt Grid::iteratorNext ( void  )

Return the vector of grid indices for each iteration

Returns
void Grid::multiple ( const VectorInt nmult,
int  flag_cell,
VectorInt nx,
VectorDouble dx,
VectorDouble x0 
) const

Returns the characteristics of a multiple grid

Parameters
[in]nmultArray of multiplicity coefficients
[in]flag_cell1 for cell matching; 0 for point matching
[out]nxArray of number of grid meshes
[out]dxArray of grid meshes
[out]x0Array of grid origins
Grid & Grid::operator= ( const Grid r)
double Grid::rankToCoordinate ( int  idim0,
int  rank,
const VectorDouble percent = VectorDouble() 
) const
VectorDouble Grid::rankToCoordinates ( int  rank,
const VectorDouble percent = VectorDouble() 
) const
void Grid::rankToCoordinatesInPlace ( int  rank,
VectorDouble coor,
const VectorDouble percent = VectorDouble() 
) const
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.
void Grid::resetFromGrid ( Grid grid)
void Grid::resetFromSpaceDimension ( int  ndim)
int Grid::resetFromVector ( const VectorInt nx = VectorInt(),
const VectorDouble dx = VectorDouble(),
const VectorDouble x0 = VectorDouble(),
const VectorDouble angles = VectorDouble() 
)
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
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
void Grid::setDX ( int  idim,
double  value 
)
void Grid::setNX ( int  idim,
int  value 
)
void Grid::setRotationByAngle ( double  angle)

Define the rotation by the value of its first angle

Parameters
angleValue of the first rotation angle
void Grid::setRotationByAngles ( VectorDouble  angles)
void Grid::setRotationByMatrix ( const MatrixSquareGeneral rotmat)
void Grid::setRotationByVector ( const VectorDouble rotmat)
void Grid::setX0 ( int  idim,
double  value 
)
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: