Gromacs  2018.8
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Functions
gmx::anonymous_namespace{grid.cpp} Namespace Reference

Functions

void centerPeriodicValueAroundZero (double *x, double period)
 Modify x so that it is periodic in [-period/2, +period/2). More...
 
int indexWithinPeriod (int x, int period)
 If period>0, retrun x so that it is periodic in [0, period), else return x. More...
 
double getIntervalLengthPeriodic (double origin, double end, double period)
 Get the length of the interval (origin, end). More...
 
double getDeviationPeriodic (double x, double x0, double period)
 Get the deviation x - x0. More...
 
int multiDimGridIndexToLinear (const std::vector< GridAxis > &axis, const awh_ivec indexMulti)
 Convert a multidimensional grid point index to a linear one. More...
 
bool stepInMultiDimArray (int numDim, const awh_ivec numPoints, awh_ivec indexDim)
 Take a step in a multidimensional array. More...
 
void gridToSubgridIndex (const Grid &grid, const awh_ivec subgridOrigin, const awh_ivec subgridNpoints, int point, awh_ivec subgridIndex)
 Transforms a grid point index to to the multidimensional index of a subgrid. More...
 
bool subgridToGridIndex (const Grid &grid, const awh_ivec subgridOrigin, const awh_ivec subgridIndex, int *gridIndex)
 Transform a multidimensional subgrid index to a grid point index. More...
 
void setNeighborsOfGridPoint (int pointIndex, const Grid &grid, std::vector< int > *neighborIndexArray)
 Find and set the neighbors of a grid point. More...
 

Function Documentation

void gmx::anonymous_namespace{grid.cpp}::centerPeriodicValueAroundZero ( double *  x,
double  period 
)

Modify x so that it is periodic in [-period/2, +period/2).

x is modified by shifting its value by a +/- a period if needed. Thus, it is assumed that x is at most one period away from this interval. For period = 0, x is not modified.

Parameters
[in,out]xPointer to the value to modify.
[in]periodThe period, or 0 if not periodic.
double gmx::anonymous_namespace{grid.cpp}::getDeviationPeriodic ( double  x,
double  x0,
double  period 
)

Get the deviation x - x0.

For period > 0, the deviation with minimum absolute value is returned, i.e. with a value in the interval [-period/2, +period/2). Also for period > 0, it is assumed that |x - x0| < period.

Parameters
[in]xFrom value.
[in]x0To value.
[in]periodThe period, or 0 if not periodic.
Returns
the deviation from x to x0.
double gmx::anonymous_namespace{grid.cpp}::getIntervalLengthPeriodic ( double  origin,
double  end,
double  period 
)

Get the length of the interval (origin, end).

This returns the distance obtained by connecting the origin point to the end point in the positive direction. Note that this is generally not the shortest distance. For period > 0, both origin and end are expected to take values in the same periodic interval, ie. |origin - end| < period.

Parameters
[in]originStart value of the interval.
[in]endEnd value of the interval.
[in]periodThe period, or 0 if not periodic.
Returns
the interval length from origin to end.
void gmx::anonymous_namespace{grid.cpp}::gridToSubgridIndex ( const Grid &  grid,
const awh_ivec  subgridOrigin,
const awh_ivec  subgridNpoints,
int  point,
awh_ivec  subgridIndex 
)

Transforms a grid point index to to the multidimensional index of a subgrid.

The subgrid is defined by the location of its origin and the number of points along each dimension. The index transformation thus consists of a projection of the linear index onto each dimension, followed by a translation of the origin. The subgrid may have parts that don't overlap with the grid. E.g. the origin vector can have negative components meaning the origin lies outside of the grid. However, the given point needs to be both a grid and subgrid point.

Periodic boundaries are taken care of by wrapping the subgrid around the grid. Thus, for periodic dimensions the number of subgrid points need to be less than the number of points in a period to prevent problems of wrapping around.

Parameters
[in]gridThe grid.
[in]subgridOriginVector locating the subgrid origin relative to the grid origin.
[in]subgridNpointsThe number of subgrid points in each dimension.
[in]pointGrid point to get subgrid index for.
[in,out]subgridIndexSubgrid multidimensional index.
int gmx::anonymous_namespace{grid.cpp}::indexWithinPeriod ( int  x,
int  period 
)

If period>0, retrun x so that it is periodic in [0, period), else return x.

Return x is shifted its value by a +/- a period, if needed. Thus, it is assumed that x is at most one period away from this interval. For this domain and period > 0 this is equivalent to x = x % period. For period = 0, x is not modified.

Parameters
[in,out]xPointer to the value to modify, should be >= 0.
[in]periodThe period, or 0 if not periodic.
Returns
for period>0: index value witin [0, period), otherwise: x.
int gmx::anonymous_namespace{grid.cpp}::multiDimGridIndexToLinear ( const std::vector< GridAxis > &  axis,
const awh_ivec  indexMulti 
)

Convert a multidimensional grid point index to a linear one.

Parameters
[in]axisThe grid axes.
[in]indexMultiMultidimensional grid point index to convert to a linear one.
Returns
the linear index.
void gmx::anonymous_namespace{grid.cpp}::setNeighborsOfGridPoint ( int  pointIndex,
const Grid &  grid,
std::vector< int > *  neighborIndexArray 
)

Find and set the neighbors of a grid point.

The search space for neighbors is a subgrid with size set by a scope cutoff. In general not all point within scope will be valid grid points.

Parameters
[in]pointIndexGrid point index.
[in]gridThe grid.
[in,out]neighborIndexArrayArray to fill with neighbor indices.
bool gmx::anonymous_namespace{grid.cpp}::stepInMultiDimArray ( int  numDim,
const awh_ivec  numPoints,
awh_ivec  indexDim 
)

Take a step in a multidimensional array.

The multidimensional index gives the starting point to step from. Dimensions are stepped through in order of decreasing dimensional index such that the index is incremented in the highest dimension possible. If the starting point is the end of the array, a step cannot be taken and the index is not modified.

Parameters
[in]numDimNumber of dimensions of the array.
[in]numPointsVector with the number of points along each dimension.
[in,out]indexDimMultidimensional index, each with values in [0, numPoints[d] - 1].
Returns
true if a step was taken, false if not.
bool gmx::anonymous_namespace{grid.cpp}::subgridToGridIndex ( const Grid &  grid,
const awh_ivec  subgridOrigin,
const awh_ivec  subgridIndex,
int *  gridIndex 
)

Transform a multidimensional subgrid index to a grid point index.

If the given subgrid point is not a grid point the transformation will not be successful and the grid point index will not be set. Periodic boundaries are taken care of by wrapping the subgrid around the grid.

Parameters
[in]gridThe grid.
[in]subgridOriginVector locating the subgrid origin relative to the grid origin.
[in]subgridIndexSubgrid multidimensional index to get grid point index for.
[in,out]gridIndexGrid point index.
Returns
true if the transformation was successful.