Gromacs  2018.8
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Namespaces | Classes | Typedefs | Functions
gmx::internal Namespace Reference

Description

Internal GROMACS namespace.

This namespace is used to contain some implementation-specific functions and classes. These are not meant for direct user access, but typically reside in public headers because of implementation reasons.

Namespaces

 anonymous_namespace{selection.cpp}
 

Classes

class  AnalysisDataHandleImpl
 Private implementation class for AnalysisDataHandle. More...
 
class  AnalysisDataStorageImpl
 Private implementation class for AnalysisDataStorage. More...
 
class  AnalysisDataStorageFrameData
 Internal representation for a single stored frame. More...
 
class  BasicAverageHistogramModule
 Implements average histogram module that averages per-frame histograms. More...
 
class  BasicHistogramImpl
 Base class for private implementation classes for histogram modules. More...
 
class  EnumIndexStore
 Type-specific implementation for IOptionValueStore for an enum option. More...
 
class  OptionSectionImpl
 Internal implementation class for storing an option section. More...
 
class  OptionsImpl
 Private implementation class for Options. More...
 
class  SelectionData
 Internal data for a single selection. More...
 
struct  SimdTraits
 Simd traits. More...
 
class  SimdArrayRef
 STL-like container for aligned SIMD type. Used as ArrayRef<SimdReal>. More...
 
class  IExceptionInfo
 Base class for ExceptionInfo. More...
 

Typedefs

typedef std::unique_ptr
< AnalysisDataStorageFrame
AnalysisDataFrameBuilderPointer
 Smart pointer type for managing a storage frame builder.
 
typedef std::vector
< std::exception_ptr > 
NestedExceptionList
 Internal container type for storing a list of nested exceptions.
 
typedef std::unique_ptr
< IExceptionInfo
ExceptionInfoPointer
 Smart pointer to manage IExceptionInfo ownership.
 

Functions

AbstractOptionStoragecreateEnumOptionStorage (const AbstractOption &option, const char *const *enumValues, int count, int defaultValue, int defaultValueIfSet, IOptionValueStore< int > *store)
 Helper to create EnumOptionStorage instances. More...
 
void throwUnlessDerivativeIsConsistentWithFunction (const std::function< double(double)> &function, const std::function< double(double)> &derivative, const std::pair< real, real > &range)
 Ensure analytical derivative is the derivative of analytical function. More...
 
void throwUnlessDerivativeIsConsistentWithFunction (ArrayRef< const double > function, ArrayRef< const double > derivative, double inputSpacing, const std::pair< real, real > &range)
 Ensure vector of derivative values is the derivative of function vector. More...
 
static double quotientOfFunctionAndSecondDerivative (double previousPoint, double thisPoint, double nextPoint, double spacing)
 Calculate absolute quotient of function and its second derivative. More...
 
real findSmallestQuotientOfFunctionAndSecondDerivative (const std::function< double(double)> &f, const std::pair< real, real > &range)
 Find smallest quotient between analytical function and its 2nd derivative. More...
 
real findSmallestQuotientOfFunctionAndSecondDerivative (ArrayRef< const double > function, double inputSpacing, const std::pair< real, real > &range)
 Find smallest quotient between vector of values and its 2nd derivative. More...
 
static double quotientOfFunctionAndThirdDerivative (double previousPreviousPoint, double previousPoint, double thisPoint, double nextPoint, double nextNextPoint, double spacing)
 Calculate absolute quotient of function and its third derivative. More...
 
real findSmallestQuotientOfFunctionAndThirdDerivative (const std::function< double(double)> &f, const std::pair< real, real > &range)
 Find smallest quotient between analytical function and its 3rd derivative. More...
 
real findSmallestQuotientOfFunctionAndThirdDerivative (ArrayRef< const double > function, double inputSpacing, const std::pair< real, real > &range)
 Find smallest quotient between function and 2nd derivative (vectors) More...
 
std::vector< double > vectorSecondDerivative (ArrayRef< const double > f, double spacing)
 Calculate second derivative of vector and return vector of same length. More...
 
template<class T , class U >
void fillMultiplexedTableData (const T inputData, U *multiplexedOutputData, std::size_t valuesPerTablePoint, std::size_t numTables, std::size_t thisTableIndex)
 Copy (temporary) table data into aligned multiplexed vector. More...
 
template<typename T >
static void ignoreValueHelper (const T &)
 Helper for ignoring values in macros. More...
 
void current_function_helper ()
 Helper for defining GMX_CURRENT_FUNCTION.
 
void printFatalErrorHeader (FILE *fp, const char *title, const char *func, const char *file, int line)
 Formats a common header for fatal error messages. More...
 
void printFatalErrorMessageLine (FILE *fp, const char *text, int indent)
 Formats a line of fatal error message text. More...
 
void printFatalErrorFooter (FILE *fp)
 Formats a common footer for fatal error messages. More...
 
void assertHandler (const char *condition, const char *msg, const char *func, const char *file, int line)
 Called when an assert fails. More...
 

Function Documentation

template<class T , class U >
void gmx::internal::fillMultiplexedTableData ( const T  inputData,
U *  multiplexedOutputData,
std::size_t  valuesPerTablePoint,
std::size_t  numTables,
std::size_t  thisTableIndex 
)

Copy (temporary) table data into aligned multiplexed vector.

This routine takes the temporary data generated for a single table and writes multiplexed output into a multiple-table-data vector. If the output vector is empty we will resize it to fit the data, and otherwise we assert the size is correct to add out input data.

Template Parameters
TType of container for input data
UType of container for output data
Parameters
[in]inputDataInput data for single table
[in,out]multiplexedOutputDataMultiplexed output vector, many tables.
[in]valuesPerTablePointNumber of real values for each table point, for instance 4 in DDFZ tables.
[in]numTablesNumber of tables mixed into multiplexed output
[in]thisTableIndexIndex of this table in multiplexed output
Note
The output container type can be different from the input since the latter sometimes uses an aligned allocator so the data can be loaded efficiently in the GROMACS nonbonded kernels.
real gmx::internal::findSmallestQuotientOfFunctionAndSecondDerivative ( const std::function< double(double)> &  f,
const std::pair< real, real > &  range 
)

Find smallest quotient between analytical function and its 2nd derivative.

Used to calculate spacing for quadratic spline tables. This function divides the function value by the second derivative (or a very small number when that is zero), and returns the smallest such quotient found in the range.

Our quadratic tables corresponds to linear interpolation of the derivative, which means the derivative will typically have larger error than the value when interpolating. The spacing required to reach a particular relative tolerance in the derivative depends on the quotient between the first derivative and the third derivative of the function itself.

You should call this routine with the analytical derivative as the "function" parameter, and the quotient between "function and second derivative" will then correspond to the quotient bewteen the derivative and the third derivative of the actual function we want to tabulate.

Since all functions that can be tabulated efficiently are reasonably smooth, we simply check 1,000 points in the interval rather than bother about implementing any complicated global optimization scheme.

Parameters
fAnalytical function
rangeInterval
Returns
Smallest quotient found in range.
Note
The function is always double-valued to avoid accuracy loss.
real gmx::internal::findSmallestQuotientOfFunctionAndSecondDerivative ( ArrayRef< const double >  function,
double  inputSpacing,
const std::pair< real, real > &  range 
)

Find smallest quotient between vector of values and its 2nd derivative.

Used to calculate spacing for quadratic spline tables. This function divides the function value by the second derivative (or a very small number when that is zero), and returns the smallest such quotient found in the range.

Our quadratic tables corresponds to linear interpolation of the derivative, which means the derivative will typically have larger error than the value when interpolating. The spacing required to reach a particular relative tolerance in the derivative depends on the quotient between the first derivative and the third derivative of the function itself.

You should call this routine with the analytical derivative as the "function" parameter, and the quotient between "function and second derivative" will then correspond to the quotient bewteen the derivative and the third derivative of the actual function we want to tabulate.

Parameters
functionVector with function values
inputSpacingSpacing between function values
rangeInterval to check
Returns
Smallest quotient found in range.
Note
The function vector and input spacing are always double-valued to avoid accuracy loss.
real gmx::internal::findSmallestQuotientOfFunctionAndThirdDerivative ( const std::function< double(double)> &  f,
const std::pair< real, real > &  range 
)

Find smallest quotient between analytical function and its 3rd derivative.

Used to calculate table spacing. This function divides the function value by the second derivative (or a very small number when that is zero), and returns the smallest such quotient found in the range.

Our quadratic tables corresponds to linear interpolation of the derivative, which means the derivative will typically have larger error than the value when interpolating. The spacing required to reach a particular relative tolerance in the derivative depends on the quotient between the first derivative and the third derivative of the function itself.

You should call this routine with the analytical derivative as the "function" parameter, and the quotient between "function and second derivative" will then correspond to the quotient bewteen the derivative and the third derivative of the actual function we want to tabulate.

Since all functions that can be tabulated efficiently are reasonably smooth, we simply check 1,000 points in the interval rather than bother about implementing any complicated global optimization scheme.

Parameters
fAnalytical function
rangeInterval
Returns
Smallest quotient found in range.
Note
The function is always double-valued to avoid accuracy loss.
real gmx::internal::findSmallestQuotientOfFunctionAndThirdDerivative ( ArrayRef< const double >  function,
double  inputSpacing,
const std::pair< real, real > &  range 
)

Find smallest quotient between function and 2nd derivative (vectors)

Used to calculate table spacing. This function divides the function value by the second derivative (or a very small number when that is zero), and returns the smallest such quotient found in the range.

Our quadratic tables corresponds to linear interpolation of the derivative, which means the derivative will typically have larger error than the value when interpolating. The spacing required to reach a particular relative tolerance in the derivative depends on the quotient between the first derivative and the third derivative of the function itself.

You should call this routine with the analytical derivative as the "function" parameter, and the quotient between "function and second derivative" will then correspond to the quotient bewteen the derivative and the third derivative of the actual function we want to tabulate.

Parameters
functionVector with function values
inputSpacingSpacing between function values
rangeInterval to check
Returns
Smallest quotient found in range.
Note
The function vector and input spacing are always double-valued to avoid accuracy loss.
static double gmx::internal::quotientOfFunctionAndSecondDerivative ( double  previousPoint,
double  thisPoint,
double  nextPoint,
double  spacing 
)
static

Calculate absolute quotient of function and its second derivative.

This is a utility function used in the functions to find the smallest quotient in a range.

Parameters
[in]previousPointValue of function at x-h.
[in]thisPointValue of function at x.
[in]nextPointValue of function at x+h.
[in]spacingValue of h.
Returns
The absolute value of the quotient. If either the function or second derivative is smaller than sqrt(GMX_REAL_MIN), they will be set to that value.
static double gmx::internal::quotientOfFunctionAndThirdDerivative ( double  previousPreviousPoint,
double  previousPoint,
double  thisPoint,
double  nextPoint,
double  nextNextPoint,
double  spacing 
)
static

Calculate absolute quotient of function and its third derivative.

This is a utility function used in the functions to find the smallest quotient in a range.

Parameters
[in]previousPreviousPointValue of function at x-2h.
[in]previousPointValue of function at x-h.
[in]thisPointValue of function at x.
[in]nextPointValue of function at x+h.
[in]nextNextPointValue of function at x+2h.
[in]spacingValue of h.
Returns
The absolute value of the quotient. If either the function or third derivative is smaller than sqrt(GMX_REAL_MIN), they will be set to that value.
void gmx::internal::throwUnlessDerivativeIsConsistentWithFunction ( const std::function< double(double)> &  function,
const std::function< double(double)> &  derivative,
const std::pair< real, real > &  range 
)

Ensure analytical derivative is the derivative of analytical function.

This routine evaluates the numerical derivative of the function for a few (1000) points in the interval and checks that the relative difference between numerical and analytical derivative is within the expected error for the numerical derivative approximation we use.

The main point of this routine is to make sure the user has not made a mistake or sign error when defining the functions.

Parameters
functionAnalytical function to differentiate
derivativeAnalytical derivative to compare with
rangeRange to test
Exceptions
Ifthe provided derivative does not seem to match the function.
Note
The function/derivative are always double-valued to avoid accuracy loss.
void gmx::internal::throwUnlessDerivativeIsConsistentWithFunction ( ArrayRef< const double >  function,
ArrayRef< const double >  derivative,
double  inputSpacing,
const std::pair< real, real > &  range 
)

Ensure vector of derivative values is the derivative of function vector.

This routine differentiates a vector of numerical values and checks that the relative difference to a provided vector of numerical derivatives is smaller than the expected error from the numerical differentiation.

The main point of this routine is to make sure the user has not made a mistake or sign error when defining the functions.

To avoid problems if the vectors change from zero to finite values at the start/end of the interval, we only check inside the range requested.

Parameters
functionNumerical function value vector to differentiate
derivativeNumerical derivative vector to compare with
inputSpacingDistance between input points
rangeRange to test
Exceptions
Ifthe provided derivative does not seem to match the function.
Note
The function/derivative vectors and spacing are always double-valued to avoid accuracy loss.
std::vector< double > gmx::internal::vectorSecondDerivative ( ArrayRef< const double >  f,
double  spacing 
)

Calculate second derivative of vector and return vector of same length.

5-point approximations are used, with endpoints using non-center interpolation.

Parameters
fVector (function) for which to calculate second derivative
spacingSpacing of input data.
Exceptions
Ifthe input vector has fewer than five data points.
Note
This function always uses double precision arguments since it is meant to be used on raw user input data for tables, where we want to avoid accuracy loss (since differentiation can be numerically fragile).