1.8.0
CCC
 
Loading...
Searching...
No Matches
gstlrn::Grid Class Reference

#include <Grid.hpp>

Inheritance diagram for gstlrn::Grid:
gstlrn::AStringable gstlrn::ASerializable

Public Member Functions

 Grid (Id ndim=0, const 1 &nx=1(), const 1 &x0=1(), const 1 &dx=1())
 
 Grid (const Grid &r)
 
Gridoperator= (const Grid &r)
 
virtual ~Grid ()
 
void initThread () const
 
void resetFromSpaceDimension (Id ndim)
 
void resetFromGrid (Grid *grid)
 
Id resetFromVector (const 1 &nx=1(), const 1 &dx=1(), const 1 &x0=1(), const 1 &angles=1())
 
void setX0 (Id idim, double value)
 
void setDX (Id idim, double value)
 
void setNX (Id idim, Id value)
 
void setRotationByMatrix (const MatrixSquare &rotmat)
 
void setRotationByVector (const 1 &rotmat)
 
void setRotationByAngles (const 1 &angles)
 
void setRotationByAngle (double angle)
 
Id getNDim () const
 
double getX0 (Id idim) const
 
double getDX (Id idim) const
 
Id getNX (Id idim) const
 
Id getNTotal () const
 
double getCellSize () const
 
double getExtend (Id idim, bool flagCell=false) const
 
double getVolume (bool flagCell=false) const
 
 getExtends (bool flagCell=false) const
 
String toString (const AStringFormat *strfmt=nullptr) const override
 Interface to AStringable.
 
void copyParams (Id mode, const Grid &gridaux)
 
double getCoordinate (Id rank, Id idim, bool flag_rotate=true) const
 
 getCoordinatesByRank (Id rank, bool flag_rotate=true) const
 
void getCoordinatesByRankInPlace (1 &coor, Id rank, bool flag_rotate) const
 
 getCoordinatesByIndice (const 1 &indice, bool flag_rotate=true, const 1 &shift=1(), const 1 &dxsPerCell=1()) const
 
void getCoordinatesByIndiceInPlace (1 &coor, const 1 &indice, bool flag_rotate=true, const 1 &shift=1(), const 1 &dxsPerCell=1()) const
 
 getCoordinatesByCorner (const 1 &icorner) const
 
void getCoordinatesByCornerInPlace (1 &coor, const 1 &icorner) const
 
 getCellCoordinatesByCorner (Id node, const 1 &shift=1(), const 1 &dxsPerCell=1()) const
 
void getCellCoordinatesByCornerInPlace (1 &coor, Id node, const 1 &shift=1(), const 1 &dxsPerCell=1()) const
 
double indiceToCoordinate (Id idim0, const constvectint indice, const constvect percent={}, bool flag_rotate=true) const
 
 indicesToCoordinate (const 1 &indice, const 1 &percent=1()) const
 
void indicesToCoordinateInPlace (const constvectint indice, const vect coor, const constvect percent={}, bool flag_rotate=true) const
 
double rankToCoordinate (Id idim0, Id rank, const 1 &percent=1()) const
 
 rankToCoordinates (Id rank, const 1 &percent=1()) const
 
void rankToCoordinatesInPlace (Id rank, 1 &coor, const 1 &percent=1()) const
 
Id indiceToRank (const constvectint indice) const
 
void rankToIndice (Id rank, vectint indices, bool minusOne=false) const
 
 coordinateToIndices (const 1 &coor, bool centered=false, double eps=EPSILON6) const
 
void coordinateToIndicesInPlace (1 &indices, const 1 &coor, bool centered, double eps) const
 
Id coordinateToIndicesInPlace (const 1 &coor, 1 &indice, bool centered=false, double eps=EPSILON6) const
 
Id coordinateToRank (const 1 &coor, bool centered=false, double eps=EPSILON6) const
 
 getCenterIndices (bool flagSup=false) const
 
void getCenterIndicesInPlace (1 &indices, bool flagSup) const
 
 generateGridIndices (const String &string, bool startFromZero=true, bool invert=true, bool verbose=false) const
 
bool sampleBelongsToCell (constvect coor, constvect center, const 1 &dxsPerCell) const
 
bool sampleBelongsToCell (const 1 &coor, const 1 &center, const 1 &dxsPerCell=1()) const
 
bool sampleBelongsToCell (const 1 &coor, Id rank, const 1 &dxsPerCell=1()) const
 
 getRotAngles () const
 
 getRotMat () const
 
double getRotAngle (Id idim) const
 
 getNXs () const
 
 getX0s () const
 
 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
 
 getAxis (Id idim) const
 
void iteratorInit (const 1 &order=1())
 
 iteratorNext (void)
 
void iteratorNext (std::vector< Id > &indices)
 
bool empty () const
 
void dilate (Id mode, const 1 &nshift, 1 &nx, 1 &dx, 1 &x0) const
 
void multiple (const 1 &nmult, bool flagCell, 1 &nx, 1 &dx, 1 &x0) const
 
void divider (const 1 &nmult, bool flagCell, 1 &nx, 1 &dx, 1 &x0) const
 
Id getMirrorIndex (Id idim, Id ix) const
 
bool isInside (const 1 &indices) const
 
- Public Member Functions inherited from gstlrn::AStringable
 AStringable ()
 
 AStringable (const AStringable &r)
 
AStringableoperator= (const AStringable &r)
 
virtual ~AStringable ()
 
virtual void display (const AStringFormat *strfmt=nullptr) const final
 
virtual void display (Id level) const final
 
- Public Member Functions inherited from gstlrn::ASerializable
 ASerializable ()
 
 ASerializable (const ASerializable &r)
 
ASerializableoperator= (const ASerializable &r)
 
 ASerializable (ASerializable &&r) noexcept
 
ASerializableoperator= (ASerializable &&r) noexcept
 
virtual ~ASerializable ()
 
bool dumpToNF (const String &NFFilename, const EFormatNF &format=EFormatNF::fromKey("DEFAULT"), bool verbose=false) const
 Dump the contents of an object into an Output File using a given Output NF Format.
 
void setDefaultFormatNF (const EFormatNF &format)
 

Static Public Member Functions

static gridIndices (const 1 &nx, const String &string, bool startFromZero=true, bool invert=true, bool verbose=false)
 
static Id generateMirrorIndex (Id nx, Id ix)
 
- Static Public Member Functions inherited from gstlrn::ASerializable
static String buildFileName (Id status, const String &filename, bool ensureDirExist=false)
 
static String getFileIdentity (const String &filename, bool verbose=false)
 
static void setPrefixName (const String &prefixName)
 
static void unsetPrefixName ()
 
static const StringgetPrefixName ()
 

Friends

class DbGrid
 

Constructor & Destructor Documentation

◆ Grid() [1/2]

gstlrn::Grid::Grid ( Id  ndim = 0,
const 1 &  nx = 1(),
const 1 &  x0 = 1(),
const 1 &  dx = 1() 
)

◆ Grid() [2/2]

gstlrn::Grid::Grid ( const Grid r)

◆ ~Grid()

gstlrn::Grid::~Grid ( )
virtual

Member Function Documentation

◆ coordinateToIndices()

gstlrn::Grid::coordinateToIndices ( const 1 &  coor,
bool  centered = false,
double  eps = EPSILON6 
) const

◆ coordinateToIndicesInPlace() [1/2]

void gstlrn::Grid::coordinateToIndicesInPlace ( 1 &  indices,
const 1 &  coor,
bool  centered,
double  eps 
) const

◆ coordinateToIndicesInPlace() [2/2]

Id gstlrn::Grid::coordinateToIndicesInPlace ( const 1 &  coor,
1 &  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()

Id gstlrn::Grid::coordinateToRank ( const 1 &  coor,
bool  centered = false,
double  eps = EPSILON6 
) const

◆ copyParams()

void gstlrn::Grid::copyParams ( Id  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 gstlrn::Grid::dilate ( Id  mode,
const 1 &  nshift,
1 &  nx,
1 &  dx,
1 &  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 gstlrn::Grid::divider ( const 1 &  nmult,
bool  flagCell,
1 &  nx,
1 &  dx,
1 &  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 gstlrn::Grid::empty ( ) const

◆ generateGridIndices()

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

◆ generateMirrorIndex()

Id gstlrn::Grid::generateMirrorIndex ( Id  nx,
Id  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()

gstlrn::Grid::getAxis ( Id  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()

gstlrn::Grid::getCellCoordinatesByCorner ( Id  node,
const 1 &  shift = 1(),
const 1 &  dxsPerCell = 1() 
) 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)

◆ getCellCoordinatesByCornerInPlace()

void gstlrn::Grid::getCellCoordinatesByCornerInPlace ( 1 &  coor,
Id  node,
const 1 &  shift = 1(),
const 1 &  dxsPerCell = 1() 
) const

◆ getCellSize()

double gstlrn::Grid::getCellSize ( ) const

◆ getCenterIndices()

gstlrn::Grid::getCenterIndices ( bool  flagSup = false) const

◆ getCenterIndicesInPlace()

void gstlrn::Grid::getCenterIndicesInPlace ( 1 &  indices,
bool  flagSup 
) const

◆ getCoordinate()

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

◆ getCoordinatesByCorner()

gstlrn::Grid::getCoordinatesByCorner ( const 1 &  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

◆ getCoordinatesByCornerInPlace()

void gstlrn::Grid::getCoordinatesByCornerInPlace ( 1 &  coor,
const 1 &  icorner 
) const

◆ getCoordinatesByIndice()

gstlrn::Grid::getCoordinatesByIndice ( const 1 &  indice,
bool  flag_rotate = true,
const 1 &  shift = 1(),
const 1 &  dxsPerCell = 1() 
) 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

◆ getCoordinatesByIndiceInPlace()

void gstlrn::Grid::getCoordinatesByIndiceInPlace ( 1 &  coor,
const 1 &  indice,
bool  flag_rotate = true,
const 1 &  shift = 1(),
const 1 &  dxsPerCell = 1() 
) const

◆ getCoordinatesByRank()

gstlrn::Grid::getCoordinatesByRank ( Id  rank,
bool  flag_rotate = true 
) const

◆ getCoordinatesByRankInPlace()

void gstlrn::Grid::getCoordinatesByRankInPlace ( 1 &  coor,
Id  rank,
bool  flag_rotate 
) const

Return the Vector of coordinates for a given grid node

Parameters
coorOutput Vector of coordinates (dimension: _nDim)
rankRank of the target grid node
flag_rotateTRUE: perform the rotation; FALSE: skip rotation

◆ getDX()

double gstlrn::Grid::getDX ( Id  idim) const

◆ getDXs()

gstlrn::Grid::getDXs ( ) const
inline

◆ getExtend()

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

◆ getExtends()

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

◆ getMirrorIndex()

Id gstlrn::Grid::getMirrorIndex ( Id  idim,
Id  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()

Id gstlrn::Grid::getNDim ( ) const
inline

◆ getNTotal()

Id gstlrn::Grid::getNTotal ( ) const

◆ getNX()

Id gstlrn::Grid::getNX ( Id  idim) const

◆ getNXs()

gstlrn::Grid::getNXs ( ) const
inline

◆ getRotAngle()

double gstlrn::Grid::getRotAngle ( Id  idim) const
inline

◆ getRotAngles()

gstlrn::Grid::getRotAngles ( ) const
inline

◆ getRotation()

const Rotation & gstlrn::Grid::getRotation ( ) const
inline

◆ getRotMat()

gstlrn::Grid::getRotMat ( ) const
inline

◆ getVolume()

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

◆ getX0()

double gstlrn::Grid::getX0 ( Id  idim) const

◆ getX0s()

gstlrn::Grid::getX0s ( ) const
inline

◆ gridIndices()

gstlrn::Grid::gridIndices ( const 1 &  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()

gstlrn::Grid::indicesToCoordinate ( const 1 &  indice,
const 1 &  percent = 1() 
) const

◆ indicesToCoordinateInPlace()

void gstlrn::Grid::indicesToCoordinateInPlace ( const constvectint  indice,
const vect  coor,
const constvect  percent = {},
bool  flag_rotate = true 
) const

◆ indiceToCoordinate()

double gstlrn::Grid::indiceToCoordinate ( Id  idim0,
const constvectint  indice,
const constvect  percent = {},
bool  flag_rotate = true 
) const

◆ indiceToRank()

Id gstlrn::Grid::indiceToRank ( const constvectint  indice) const

◆ initThread()

void gstlrn::Grid::initThread ( ) const

◆ isInside()

bool gstlrn::Grid::isInside ( const 1 &  indices) const

◆ isRotated()

bool gstlrn::Grid::isRotated ( ) const
inline

◆ isSame()

bool gstlrn::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 gstlrn::Grid::isSameMesh ( const Grid grid) const

◆ isSameRotation()

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

◆ iteratorInit()

void gstlrn::Grid::iteratorInit ( const 1 &  order = 1())

Initialize an iterator on the grid

Parameters
orderArray giving the order of the Space Dimensions when iterating

◆ iteratorNext() [1/2]

void gstlrn::Grid::iteratorNext ( std::vector< Id > &  indices)

◆ iteratorNext() [2/2]

gstlrn::Grid::iteratorNext ( void  )

Return the vector of grid indices for each iteration

Returns

◆ multiple()

void gstlrn::Grid::multiple ( const 1 &  nmult,
bool  flagCell,
1 &  nx,
1 &  dx,
1 &  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 & gstlrn::Grid::operator= ( const Grid r)

◆ rankToCoordinate()

double gstlrn::Grid::rankToCoordinate ( Id  idim0,
Id  rank,
const 1 &  percent = 1() 
) const

◆ rankToCoordinates()

gstlrn::Grid::rankToCoordinates ( Id  rank,
const 1 &  percent = 1() 
) const

◆ rankToCoordinatesInPlace()

void gstlrn::Grid::rankToCoordinatesInPlace ( Id  rank,
1 &  coor,
const 1 &  percent = 1() 
) const

◆ rankToIndice()

void gstlrn::Grid::rankToIndice ( Id  rank,
vectint  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 gstlrn::Grid::resetFromGrid ( Grid grid)

◆ resetFromSpaceDimension()

void gstlrn::Grid::resetFromSpaceDimension ( Id  ndim)

◆ resetFromVector()

Id gstlrn::Grid::resetFromVector ( const 1 &  nx = 1(),
const 1 &  dx = 1(),
const 1 &  x0 = 1(),
const 1 &  angles = 1() 
)

◆ sampleBelongsToCell() [1/3]

bool gstlrn::Grid::sampleBelongsToCell ( const 1 &  coor,
const 1 &  center,
const 1 &  dxsPerCell = 1() 
) const

◆ sampleBelongsToCell() [2/3]

bool gstlrn::Grid::sampleBelongsToCell ( const 1 &  coor,
Id  rank,
const 1 &  dxsPerCell = 1() 
) 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

◆ sampleBelongsToCell() [3/3]

bool gstlrn::Grid::sampleBelongsToCell ( constvect  coor,
constvect  center,
const 1 &  dxsPerCell 
) 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

◆ setDX()

void gstlrn::Grid::setDX ( Id  idim,
double  value 
)

◆ setNX()

void gstlrn::Grid::setNX ( Id  idim,
Id  value 
)

◆ setRotationByAngle()

void gstlrn::Grid::setRotationByAngle ( double  angle)

Define the rotation by the value of its first angle

Parameters
angleValue of the first rotation angle

◆ setRotationByAngles()

void gstlrn::Grid::setRotationByAngles ( const 1 &  angles)

◆ setRotationByMatrix()

void gstlrn::Grid::setRotationByMatrix ( const MatrixSquare rotmat)

◆ setRotationByVector()

void gstlrn::Grid::setRotationByVector ( const 1 &  rotmat)

◆ setX0()

void gstlrn::Grid::setX0 ( Id  idim,
double  value 
)

◆ toString()

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

Interface to AStringable.

Reimplemented from gstlrn::AStringable.

Friends And Related Symbol Documentation

◆ DbGrid

friend class DbGrid
friend

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