20 #ifndef GEOS_FUNCTIONS_MULTIVARIABLETABLEFUNCTIONKERNELS_HPP_
21 #define GEOS_FUNCTIONS_MULTIVARIABLETABLEFUNCTIONKERNELS_HPP_
43 template<
integer NUM_DIMS,
integer NUM_OPS >
91 template<
typename IN_ARRAY,
typename OUT_ARRAY >
95 OUT_ARRAY && values )
const
101 for(
int i = 0; i <
numDims; ++i )
106 axisLows[i], axisMults[i] );
124 template<
typename IN_ARRAY,
typename OUT_ARRAY,
typename OUT_2D_ARRAY >
129 OUT_2D_ARRAY && derivatives )
const
135 for(
int i = 0; i <
numDims; ++i )
140 axisLows[i], axisMults[i] );
146 &axisLows[0], &axisMults[0],
194 integer axisIntervalIndex =
integer((axisCoordinate - axisMin) * axisStepInv );
199 if( axisIntervalIndex < 0 )
201 axisIntervalIndex = 0;
202 if( axisCoordinate < axisMin )
204 printf(
"Interpolation warning: axis coordinate is out of limits (%lf; %lf) with value %lf, extrapolation is applied\n", axisMin, axisMax, axisCoordinate );
207 else if( axisIntervalIndex > (axisPoints - 2))
209 axisIntervalIndex = axisPoints - 2;
210 if( axisCoordinate > axisMax )
212 printf(
"Interpolation warning: axis coordinate is out of limits (%lf; %lf) with value %lf, extrapolation is applied\n", axisMin, axisMax, axisCoordinate );
216 axisLow = axisIntervalIndex * axisStep + axisMin;
217 axisMult = (axisCoordinate - axisLow) * axisStepInv;
218 return axisIntervalIndex;
231 template<
typename IN_ARRAY,
typename OUT_ARRAY >
236 real64 const *
const hypercubeData,
237 real64 const *
const axisLows,
238 real64 const *
const axisStepInvs,
239 OUT_ARRAY && values )
const
249 workspace[i][j] = hypercubeData[i *
numOps + j];
256 for(
integer j = 0; j < pwr; ++j )
261 workspace[j][op] += (axisCoordinates[i] - axisLows[i]) * (workspace[j + pwr][op] - workspace[j][op]) * axisStepInvs[i];
268 values[op] = workspace[0][op];
285 template<
typename IN_ARRAY,
typename OUT_ARRAY,
typename OUT_2D_ARRAY >
290 real64 const *
const hypercubeData,
291 real64 const *
const axisLows,
292 real64 const *
const axisMults,
293 real64 const *
const axisStepInvs,
295 OUT_2D_ARRAY && derivatives )
const
305 workspace[i][j] = hypercubeData[i *
numOps + j];
312 for(
integer j = 0; j < pwr; ++j )
317 workspace[2 *
numVerts - (
numVerts >> i) + j][op] = (workspace[j + pwr][op] - workspace[j][op]) * axisStepInvs[i];
321 for(
integer k = 0; k < i; k++ )
334 workspace[j][op] = workspace[j][op] + (axisCoordinates[i] - axisLows[i]) * workspace[2 *
numVerts - (
numVerts >> i) + j][op];
341 values[op] = workspace[0][op];
#define GEOS_HOST_DEVICE
Marks a host-device function.
GEOS_HOST_DEVICE void compute(IN_ARRAY const &coordinates, OUT_ARRAY &&values) const
interpolate all operators at a given point
arrayView1d< real64 const > m_axisMinimums
Array [numDims] of axis minimum values.
arrayView1d< real64 const > m_coordinates
Coordinates in numDims-dimensional space where interpolation is requested.
arrayView1d< real64 > m_derivatives
/// Interpolated derivatives
arrayView1d< globalIndex const > m_axisHypercubeMults
Array [numDims] of hypercube index mult factors for each axis.
arrayView1d< real64 const > m_axisStepInvs
Array [numDims] of inversions of axis interval lengths (axes are discretized uniformly)
arrayView1d< real64 > m_values
Interpolated values.
arrayView1d< real64 const > m_hypercubeData
Main table data stored per hypercube: all values required for interpolation withing give hypercube ar...
MultivariableTableFunctionStaticKernel(arrayView1d< real64 const > const &axisMinimums, arrayView1d< real64 const > const &axisMaximums, arrayView1d< integer const > const &axisPoints, arrayView1d< real64 const > const &axisSteps, arrayView1d< real64 const > const &axisStepInvs, arrayView1d< globalIndex const > const &axisHypercubeMults, arrayView1d< real64 const > const &hypercubeData)
Construct a new Multivariable Table Function Static Kernel object.
GEOS_HOST_DEVICE void interpolatePointWithDerivatives(IN_ARRAY const &axisCoordinates, real64 const *const hypercubeData, real64 const *const axisLows, real64 const *const axisMults, real64 const *const axisStepInvs, OUT_ARRAY &&values, OUT_2D_ARRAY &&derivatives) const
interpolate all operators values and derivatives at a given point The algoritm is based on http://dx....
GEOS_HOST_DEVICE real64 const * getHypercubeData(globalIndex const hypercubeIndex) const
Get pointer to hypercube data.
static constexpr integer numOps
Compile time value for the number of operators (interpolated functions, outputs)
static constexpr integer numVerts
Compile time value for the number of hypercube vertices.
GEOS_HOST_DEVICE void interpolatePoint(IN_ARRAY const &axisCoordinates, real64 const *const hypercubeData, real64 const *const axisLows, real64 const *const axisStepInvs, OUT_ARRAY &&values) const
interpolate all operators values at a given point The algoritm is based on http://dx....
GEOS_HOST_DEVICE integer getAxisIntervalIndexLowMult(real64 const axisCoordinate, real64 const axisMin, real64 const axisMax, real64 const axisStep, real64 const axisStepInv, integer const axisPoints, real64 &axisLow, real64 &axisMult) const
Get the interval index, low and mult values for a given axis coordinate.
arrayView1d< integer const > m_axisPoints
Array [numDims] of axis discretization points.
arrayView1d< real64 const > m_axisMaximums
Array [numDims] of axis maximum values.
GEOS_HOST_DEVICE void compute(IN_ARRAY const &coordinates, OUT_ARRAY &&values, OUT_2D_ARRAY &&derivatives) const
interpolate all operators and compute their derivatives at a given point
arrayView1d< real64 const > m_axisSteps
Array [numDims] of axis interval lengths (axes are discretized uniformly)
static constexpr integer numDims
Compile time value for the number of table dimensions (inputs)
ArrayView< T, 1 > arrayView1d
Alias for 1D array view.
GEOS_GLOBALINDEX_TYPE globalIndex
Global index type (for indexing objects across MPI partitions).
double real64
64-bit floating point type.
std::int32_t integer
Signed integer type.