Grid Interpolation
Public Member Functions | Private Member Functions | Private Attributes | List of all members
GRID_INTERP::interp< dim > Class Template Reference

Main interpolation class. More...

#include <gridInterp.h>

Collaboration diagram for GRID_INTERP::interp< dim >:
Collaboration graph
[legend]

Public Member Functions

 interp ()
 
double interpolate (double x, double y=0, double z=0) const
 This is the method to call to do the interpolation. More...
 
void setAxis (int idim, std::vector< double > &x_in)
 Set the Axis object. More...
 
void setAxis (int idim, double origin_in, double dx_in, int n)
 Set the Axis object when the ticks are evenly spaced. More...
 
void setMethod (METHOD method_in)
 sets the method More...
 
void getDataFromFile (std::string filename)
 Get the Data From File object. More...
 
void setValues (int l, int r, int c, double v_in)
 Set the values of the iterpolation. More...
 
void setElevation (int l, int r, int c, double v_in)
 
void reset ()
 Resets the class to the empty state. More...
 

Private Member Functions

double interp1D (double x) const
 The interpolate method will call this when dim is 1. More...
 
double interp2D (double x, double y) const
 The interpolate method will call this when dim is 2. More...
 
double interp3D (double x, double y, double z) const
 The interpolate method will call this when dim is 3. More...
 

Private Attributes

std::vector< axisa
 A vector of axis objects. More...
 
GridValues v
 The container for the values that are used in the interpolation. More...
 
GridValues elev
 In 3D this holds the layer elevation information. More...
 
METHOD method = METHOD::INVALID_METHOD
 This holds the interpolation method. More...
 
double translateX = 0.0
 
double translateY = 0.0
 
double rotate = 0.0
 
double cosTH
 
double sinTH
 
bool bPreTransform = false
 

Detailed Description

template<int dim>
class GRID_INTERP::interp< dim >

Main interpolation class.

This is a templated class where the dimention is the template parameter

Template Parameters
dimis the dimension of the interpolation

Constructor & Destructor Documentation

◆ interp()

template<int dim>
GRID_INTERP::interp< dim >::interp ( )

Member Function Documentation

◆ getDataFromFile()

template<int dim>
void GRID_INTERP::interp< dim >::getDataFromFile ( std::string  filename)

Get the Data From File object.

The data must be in the following format
1st line:
METHOD NX NY NZ
where method is one of the GRID_INTERP::METHOD methods
Nx, NY, NZ are the number of x coordinates (columns), y coordinates (rows) and z coordinates (layers).
In case of 1 or 2D only NX or NX and NY are needed.

2nd line:
axisFileX axisFileY axisFileZ
This is a list of files that define the options for the X Y and Z axis.
The data format for these files is defined in GRID_INTERP::axis::dataFromFile
Next lines:
For 1D repeat NX lines the values.
For 2D repeat NY lines where each line containts NX values
For 3D repeat NZ times the NY x NX data.

Note that the number of values must be consistent with the number of axis values depending the selected MODE.

Parameters
filename

◆ interp1D()

template<int dim>
double GRID_INTERP::interp< dim >::interp1D ( double  x) const
private

The interpolate method will call this when dim is 1.

◆ interp2D()

template<int dim>
double GRID_INTERP::interp< dim >::interp2D ( double  x,
double  y 
) const
private

The interpolate method will call this when dim is 2.

◆ interp3D()

template<int dim>
double GRID_INTERP::interp< dim >::interp3D ( double  x,
double  y,
double  z 
) const
private

The interpolate method will call this when dim is 3.

◆ interpolate()

template<int dim>
double GRID_INTERP::interp< dim >::interpolate ( double  x,
double  y = 0,
double  z = 0 
) const

This is the method to call to do the interpolation.

Parameters
xis the x coordinate
yis the y coordinate. It is used only in 2D or 3D
zis the z coordinate. It is used only in 3D
Returns
double

◆ reset()

template<int dim>
void GRID_INTERP::interp< dim >::reset ( )

Resets the class to the empty state.

◆ setAxis() [1/2]

template<int dim>
void GRID_INTERP::interp< dim >::setAxis ( int  idim,
std::vector< double > &  x_in 
)

Set the Axis object.

This method is used when the ticks are not evenly spaced

Parameters
idimis the index of the dimension. For the x, y and z axis this is 0, 1 and 2 repsectively
x_inthe vector with the coordinates of the ticks

◆ setAxis() [2/2]

template<int dim>
void GRID_INTERP::interp< dim >::setAxis ( int  idim,
double  origin_in,
double  dx_in,
int  n 
)

Set the Axis object when the ticks are evenly spaced.

Parameters
idimis the dimension index of the axis to set
origin_inis the starting point of the idim axis
dx_inis the space between the ticks
nthe number of ticks in the idim axis

◆ setElevation()

template<int dim>
void GRID_INTERP::interp< dim >::setElevation ( int  l,
int  r,
int  c,
double  v_in 
)

Similarly to the method interp::setValues this sets the layer elevation when the interpolation is 3D and GRID_INTERP::TYPE::LAYER. The same rules also apply.

◆ setMethod()

template<int dim>
void GRID_INTERP::interp< dim >::setMethod ( METHOD  method_in)

sets the method

Sets the interpolation Method of the interp class

Parameters
method_inis the interpolation method

◆ setValues()

template<int dim>
void GRID_INTERP::interp< dim >::setValues ( int  l,
int  r,
int  c,
double  v_in 
)

Set the values of the iterpolation.

When setting these values using either the interp::getDataFromFile or this method, l, r, c correspond to the index of the x y z direction. Typically, in grid data the layer or row 1 is the top layer or the first row in a martix respectivelly. However the data in the code are using the cartesian coordinate system where the origin is the l = 0, r = 0, c = 0. The top layer correspond to the last index of the z axis.

Parameters
llayer or the index in the z coordinate
rrow or the index in the y coordinate
ccolumn or the index in the x coordinate
v_inThe value that correspons to (c,r,l)

Member Data Documentation

◆ a

template<int dim>
std::vector<axis> GRID_INTERP::interp< dim >::a
private

A vector of axis objects.

◆ bPreTransform

template<int dim>
bool GRID_INTERP::interp< dim >::bPreTransform = false
private

◆ cosTH

template<int dim>
double GRID_INTERP::interp< dim >::cosTH
private

◆ elev

template<int dim>
GridValues GRID_INTERP::interp< dim >::elev
private

In 3D this holds the layer elevation information.

◆ method

template<int dim>
METHOD GRID_INTERP::interp< dim >::method = METHOD::INVALID_METHOD
private

This holds the interpolation method.

◆ rotate

template<int dim>
double GRID_INTERP::interp< dim >::rotate = 0.0
private

◆ sinTH

template<int dim>
double GRID_INTERP::interp< dim >::sinTH
private

◆ translateX

template<int dim>
double GRID_INTERP::interp< dim >::translateX = 0.0
private

A utility method which is used in MODE::CELL and METHOD::LINEAR Finds the correct cells to interpolate the value for the given input

◆ translateY

template<int dim>
double GRID_INTERP::interp< dim >::translateY = 0.0
private

◆ v

template<int dim>
GridValues GRID_INTERP::interp< dim >::v
private

The container for the values that are used in the interpolation.


The documentation for this class was generated from the following file: