This class interpolates a function of three values (f(x,y,z)). More...
#include <TrilinearInterpolation.h>
Public Member Functions | |
TrilinearInterpolation (const std::vector< Real > &x, const std::vector< Real > &y, const std::vector< Real > &z, const std::vector< Real > &data) | |
Constructor initializes data for interpolation. More... | |
virtual | ~TrilinearInterpolation ()=default |
Real | sample (Real x, Real y, Real z) const |
Interpolates for the desired (x,y,z) coordinate and returns the value based on the function values vector. More... | |
Protected Member Functions | |
void | getCornerIndices (const std::vector< Real > &v, Real x, int &lower, int &upper, Real &d) const |
Finds the indices of the cube that point (x,y,z) is in. More... | |
Real | getCornerValues (int x, int y, int z) const |
Searches the function value vector for the value at a given corner coordinate from the getCornerIndices function. More... | |
Protected Attributes | |
std::vector< Real > | _x_axis |
vector of x-values More... | |
std::vector< Real > | _y_axis |
vector of y-values More... | |
std::vector< Real > | _z_axis |
vector of z-values More... | |
std::vector< Real > | _fxyz |
vector of function values, f(x,y,z) More... | |
This class interpolates a function of three values (f(x,y,z)).
It takes 4 vectors for x, y, z, and function values, f(x,y,z). The vector of function values should be done in the following manner: Function values of constant x and y are written, corresponding with values in vector, z. Function values for the constant x, next y-value, corresponding with values in vector, z. After last y-value, function values for the next x, first y-value, corresponding with values in vector, z.
An example: f(1,4,7) = 10, f(1,4,8) = 11, f(1,4,9) = 12 f(1,5,7) = 13, f(1,5,8) = 14, f(1,5,9) = 15 f(1,6,7) = 16, f(1,6,8) = 17, f(1,6,9) = 18 f(2,4,7) = 20, f(2,4,8) = 21, f(2,4,9) = 22 f(2,5,7) = 23, f(2,5,8) = 24, f(2,5,9) = 25 f(2,6,7) = 26, f(2,6,8) = 27, f(2,6,9) = 28 f(3,4,7) = 30, f(3,4,8) = 31, f(3,4,9) = 32 f(3,5,7) = 33, f(3,5,8) = 34, f(3,5,9) = 35 f(3,6,7) = 36, f(3,6,8) = 37, f(3,6,9) = 38
x = {1, 2, 3}; y = {4, 5, 6}; z = {7, 8, 9}; fxyz = { // fxyz for x = 1 10, 11, 12, 13, 14, 15, 16, 17, 18, // fxyz for x = 2 20, 21, 22, 23, 24, 25, 26, 27, 28, // fxyz for x = 3 30, 31, 32, 33, 34, 35, 36, 37, 38 };
Definition at line 56 of file TrilinearInterpolation.h.
TrilinearInterpolation::TrilinearInterpolation | ( | const std::vector< Real > & | x, |
const std::vector< Real > & | y, | ||
const std::vector< Real > & | z, | ||
const std::vector< Real > & | data | ||
) |
Constructor initializes data for interpolation.
x | vector for x-coordinates |
y | vector for y-coordinates |
z | vector for z-coordinates |
data | vector for function values formatted in the same manner as the example |
Definition at line 13 of file TrilinearInterpolation.C.
|
virtualdefault |
|
protected |
Finds the indices of the cube that point (x,y,z) is in.
[in] | v | vector to find lower and upper limits for the cube |
[in] | x | desired coordinate |
[out] | lower | lower limit for cube |
[out] | upper | upper limit for cube |
[out] | d | ratio of (x - lower) / (upper - lower) |
Definition at line 38 of file TrilinearInterpolation.C.
Referenced by sample().
Searches the function value vector for the value at a given corner coordinate from the getCornerIndices function.
x | index for x-coordinate of corner |
y | index for y-coordinate of corner |
z | index for z-coordinate of corner |
Definition at line 74 of file TrilinearInterpolation.C.
Referenced by sample().
Interpolates for the desired (x,y,z) coordinate and returns the value based on the function values vector.
x | desired x-coordinate |
y | desired y-coordinate |
z | desired z-coordinate |
Definition at line 83 of file TrilinearInterpolation.C.
|
protected |
vector of function values, f(x,y,z)
Definition at line 94 of file TrilinearInterpolation.h.
Referenced by getCornerValues().
|
protected |
vector of x-values
Definition at line 85 of file TrilinearInterpolation.h.
Referenced by sample(), and TrilinearInterpolation().
|
protected |
vector of y-values
Definition at line 88 of file TrilinearInterpolation.h.
Referenced by getCornerValues(), sample(), and TrilinearInterpolation().
|
protected |
vector of z-values
Definition at line 91 of file TrilinearInterpolation.h.
Referenced by getCornerValues(), sample(), and TrilinearInterpolation().