SSAGES
0.9.3
Software Suite for Advanced General Ensemble Simulations
|
#include <Grid.h>
Classes | |
class | GridIterator |
Custom Iterator. More... | |
Public Types | |
typedef GridIterator< T > | iterator |
Custom iterator over a grid. | |
typedef GridIterator< const T > | const_iterator |
Custom constant iterator over a grid. | |
Public Member Functions | |
Grid (std::vector< int > numPoints, std::vector< double > lower, std::vector< double > upper, std::vector< bool > isPeriodic) | |
Constructor. More... | |
iterator | begin () |
Return iterator at first grid point. More... | |
iterator | end () |
Return iterator after last valid grid point. More... | |
const_iterator | begin () const |
Return const iterator at first grid point. More... | |
const_iterator | end () const |
Return const iterator after last valid grid point. More... | |
void | WriteToFile (const std::string &filename) |
Write grid out to file. More... | |
void | LoadFromFile (const std::string &filename) |
Builds a grid from file. More... | |
Public Member Functions inherited from SSAGES::GridBase< T > | |
void | syncGrid () |
Sync the grid. | |
size_t | GetDimension () const |
Get the dimension. More... | |
const std::vector< int > | GetNumPoints () const |
Get the number of points for all dimensions. More... | |
int | GetNumPoints (size_t dim) const |
Get the number of points for a specific dimension. More... | |
const std::vector< double > | GetLower () const |
Return the lower edges of the Grid. More... | |
double | GetLower (size_t dim) const |
Get the lower edge for a specific dimension. More... | |
const std::vector< double > | GetUpper () const |
Return the upper edges of the Grid. More... | |
double | GetUpper (size_t dim) const |
Get the upper edge for a specific dimension. More... | |
const std::vector< bool > & | GetPeriodic () const |
Return the periodicity of the Grid. More... | |
bool | GetPeriodic (size_t dim) const |
Get the periodicity in a specific dimension. More... | |
size_t | size () const |
Get the size of the internal storage vector. More... | |
T * | data () |
Get pointer to the internal data storage vector. More... | |
T const * | data () const |
Get pointer to const of the internal data storage vector. More... | |
std::vector< int > | GetIndices (const std::vector< double > &x) const |
Return the Grid indices for a given point. More... | |
int | GetIndex (double x) const |
Return linear interpolation on a coordinate. More... | |
std::vector< double > | GetCoordinates (const std::vector< int > &indices) |
! Return the distance to adjacent grid center points from given coordinates More... | |
double | GetCoordinate (int index) |
Return center point of 1d-grid. More... | |
const T & | at (const std::vector< int > &indices) const |
Access Grid element read-only. More... | |
T & | at (const std::vector< int > &indices) |
Access Grid element read/write. More... | |
template<typename R > | |
const T & | at (std::initializer_list< R > &&x) const |
Const access of Grid element via initializer list. More... | |
template<typename R > | |
T & | at (std::initializer_list< R > &&x) |
Access Grid element via initializer list. More... | |
const T & | at (int index) const |
Access 1d Grid by index, read-only. More... | |
T & | at (int index) |
Access 1d Grid by index, read-write. More... | |
const T & | at (const std::vector< double > &x) const |
Access Grid element pertaining to a specific point – read-only. More... | |
T & | at (const std::vector< double > &x) |
Access Grid element pertaining to a specific point – read/write. More... | |
const T & | at (double x) const |
Access 1d-Grid by point - read-only. More... | |
T & | at (double x) |
Access 1d-Grid by point - read-write. More... | |
const T & | operator[] (const std::vector< int > &indices) const |
Access Grid element per [] read-only. More... | |
T & | operator[] (const std::vector< int > &indices) |
Access Grid element per [] read-write. More... | |
template<typename R > | |
const T & | operator[] (std::initializer_list< R > &&x) const |
Const access of Grid element via initializer list. More... | |
template<typename R > | |
T & | operator[] (std::initializer_list< R > &&x) |
Access Grid element via initializer list. More... | |
const T & | operator[] (int index) const |
Access 1d-Grid per [] operator, read-only. More... | |
T & | operator[] (int index) |
Access 1d-Grid per [] operator, read-write. More... | |
const T & | operator[] (const std::vector< double > &x) const |
Access Grid element pertaining to a specific point per [] read-only. More... | |
T & | operator[] (const std::vector< double > &x) |
Access Grid element pertaining to a specific point per [] read-write. More... | |
const T & | operator[] (double x) const |
Access 1d-Grid via specific point, read-only. More... | |
T & | operator[] (double x) |
Access 1d-Grid via specific point, read-write. More... | |
virtual | ~GridBase () |
Destructor. | |
Static Public Member Functions | |
static Grid< T > * | BuildGrid (const Json::Value &json) |
Set up the grid. More... | |
static Grid< T > * | BuildGrid (const Json::Value &json, const std::string &path) |
Set up the grid. More... | |
Private Member Functions | |
size_t | mapTo1d (const std::vector< int > &indices) const override |
Map d-dimensional indices to 1-d data vector. More... | |
Additional Inherited Members | |
Protected Member Functions inherited from SSAGES::GridBase< T > | |
std::vector< int > | wrapIndices (const std::vector< int > &indices) const |
Wrap the index around periodic boundaries. More... | |
GridBase (std::vector< int > numPoints, std::vector< double > lower, std::vector< double > upper, std::vector< bool > isPeriodic) | |
Constructor. More... | |
Protected Attributes inherited from SSAGES::GridBase< T > | |
std::vector< T > | data_ |
Internal storage of the data. | |
size_t | dimension_ |
Dimension of the grid. | |
std::vector< int > | numPoints_ |
Number of points in each dimension. | |
std::pair< std::vector< double >, std::vector< double > > | edges_ |
Edges of the Grid in each dimension. | |
std::vector< bool > | isPeriodic_ |
Periodicity of the Grid. | |
Basic Grid.
T | type of data to be stored in the grid. |
A Grid is a method to store data in SSAGES. It is used to discretize a continuous number, typically a collective variable or a function, into number_points
grid points. At each grid point, an arbitrary type of data can be stored, specified via the template parameter T
.
The grid can be of arbitrary dimension. For each dimension, the lower bound, the upper bound and the number of grid points need to be specified. Furthermore, the grid can be defined as periodic or non-periodic in the respective dimension. By default, the grid is non-periodic. The grid points are indexed from 0 to number_points-1 following the standard C/C++ convention.
The grid spacing Delta
is given by (upper - lower)/number_points. Thus, grid point n
corresponds to the interval [lower + n*Delta, lower + (n+1)*Delta). Note that n follows the C/C++ convention, i.e. n = 0 for the first interval. The bin indices pertaining to a given point can be obtained via GetIndices().
|
inline |
Constructor.
numPoints | Number of grid points in each dimension. |
lower | Lower edges of the grid. |
upper | Upper edges of the grid. |
isPeriodic | Bools specifying the periodicity in the respective dimension. |
The dimension of the grid is determined by the size of the parameter vectors.
Definition at line 103 of file Grid.h.
Referenced by SSAGES::Grid< T >::BuildGrid().
|
inline |
Return iterator at first grid point.
The first grid point is defined as the grid point with index 0 in all dimensions.
Definition at line 527 of file Grid.h.
Referenced by SSAGES::ANN::ANN(), SSAGES::CFF::CFF(), SSAGES::ANN::PreSimulation(), SSAGES::BFS::PrintBias(), SSAGES::BFS::ProjectBias(), SSAGES::BasisEvaluator::UpdateBias(), SSAGES::BasisEvaluator::UpdateCoeff(), and SSAGES::Grid< T >::WriteToFile().
|
inline |
|
inlinestatic |
Set up the grid.
json | JSON value containing all input information. |
This function builds a grid from a JSON node. It will return a nullptr if an unknown error occured, but generally, it will throw a BuildException of failure.
Definition at line 127 of file Grid.h.
Referenced by SSAGES::ANN::Build().
|
inlinestatic |
Set up the grid.
This function builds a grid from a JSON node. It will return a nullptr if an unknown error occured, but generally, it will throw a BuildException on failure.
Definition at line 142 of file Grid.h.
References Json::Requirement::GetErrors(), SSAGES::Grid< T >::Grid(), Json::Requirement::HasErrors(), Json::ObjectRequirement::Parse(), SSAGES::GridBase< T >::size(), and Json::ObjectRequirement::Validate().
|
inline |
Return iterator after last valid grid point.
The last valid grid point has index num_points - 1 in all dimensions.
Definition at line 540 of file Grid.h.
Referenced by SSAGES::ANN::ANN(), SSAGES::CFF::CFF(), SSAGES::ANN::PreSimulation(), SSAGES::BasisEvaluator::UpdateBias(), SSAGES::BasisEvaluator::UpdateCoeff(), and SSAGES::Grid< T >::WriteToFile().
|
inline |
|
inline |
Builds a grid from file.
filename | Filename containing grid data. |
This function builds a grid from a text data file.
Definition at line 629 of file Grid.h.
Referenced by SSAGES::ABF::Build().
|
inlineoverrideprivatevirtual |
Map d-dimensional indices to 1-d data vector.
indices | Vector specifying the grid point. |
Map a set of indices to the index of the 1d data vector. Keep in mind, that the data includes underflow (index -1) and overflow (index numPoints) bins in periodic dimension.
Implements SSAGES::GridBase< T >.
Definition at line 70 of file Grid.h.
|
inline |
Write grid out to file.
filename | Name of the output file. |
Definition at line 586 of file Grid.h.
References SSAGES::Grid< T >::begin(), SSAGES::Grid< T >::end(), SSAGES::GridBase< T >::GetLower(), SSAGES::GridBase< T >::GetNumPoints(), and SSAGES::GridBase< T >::GetUpper().