Grid Interpolation
Public Member Functions | Private Member Functions | Private Attributes | List of all members
GRID_INTERP::axis Class Reference

The axis class is a container for axis tick values. More...

#include <gridInterp.h>

Public Member Functions

 axis ()
 The constructor does absolutely nothing. More...
 
void setAxis (double origin, double dx, int N)
 Set the Axis tick values when the space between the ticks is constant. More...
 
void setAxis (std::vector< double > &x_in)
 Set the Axis tick values with the input vector. This is used to set variable space grid data. More...
 
void findIIT (double x_in, int &i1, int &i2, double &t) const
 Finds the lower and upper ids that enclose the input value #x_in. Also returns the parametric value that correspons to #x_in. More...
 
void dataFromFile (std::string filename)
 Reads the axis data from file. More...
 
void reset ()
 Delets all data and resest the axis object to its original state. More...
 
double operator() (int i) const
 accessor for the i element of the axis More...
 
int last () const
 

Private Member Functions

void findCell (int &i, int &ii, const double x) const
 

Private Attributes

std::vector< double > x
 is the vector that containts the tick values More...
 
int N = 0
 is the index of the last element More...
 
double origin = 0.0
 this is the origin of the grid. When the object is populated with variable data this is not used More...
 
double dx = 0.0
 The distance between the ticks. This is used only for constant grid values. More...
 
bool bConst = false
 This flag is set to true or false according to which setAxis method is used. More...
 

Detailed Description

The axis class is a container for axis tick values.

The tick values can have variable space or constant. If the space between the tick values is constant it is advantageous to use the setAxis(double origin, double dx, int N) method for constant ticks.

An axis object is used to describe the location of the values during interpolation therefore the number of ticks must be consistent with the grid values.

Constructor & Destructor Documentation

◆ axis()

GRID_INTERP::axis::axis ( )
inline

The constructor does absolutely nothing.

Member Function Documentation

◆ dataFromFile()

void GRID_INTERP::axis::dataFromFile ( std::string  filename)

Reads the axis data from file.

The data are organized in the following format:

1st line:
DATA_FORMAT N
where DATA_FORMAT is either CONST or VAR. N is the number of ticks of the axis

2nd line:
If the DATA_FORMAT is CONST the second line consists of 2 numbers
origin dx

If the DATA_FORMAT is VAR then repeat N lines where each line contains the values of the ticks.

Parameters
filenameThis is what you think it is.

◆ findCell()

void GRID_INTERP::axis::findCell ( int &  i,
int &  ii,
const double  x 
) const
private

Finds cell searches the segment that containts the x.
If the ticks are variable the method keeps dividing into half and repeating it self until it find the space where the difference between i and ii is one.
If the space between the ticks is constant then the method finds the correct space using i = (x - origin)/dx

◆ findIIT()

void GRID_INTERP::axis::findIIT ( double  x_in,
int &  i1,
int &  i2,
double &  t 
) const

Finds the lower and upper ids that enclose the input value #x_in. Also returns the parametric value that correspons to #x_in.

Parameters
x_inis the query point
i1if the point x_in is between x[i] and x[j] then i1 is i If the x_in is less than x[0] then both i1 and i2 are set 0. if the x_in is greater than x[N] then both i1 and i2 are set to N
i2if the point x_in is between x[i] and x[j] then i1 is j. If the x_in is less than x[0] then both i1 and i2 are set 0. if the x_in is greater than x[N] then both i1 and i2 are set to N
tis the parametric value so that x_in = x[i1]*(1-t) + x[i2]*t

◆ last()

int GRID_INTERP::axis::last ( ) const

returns the index that access the last element of the tick values If ax is an axis object then ax(ax.last()) is equal to ax.x[ax.x.size()-1]

◆ operator()()

double GRID_INTERP::axis::operator() ( int  i) const

accessor for the i element of the axis

◆ reset()

void GRID_INTERP::axis::reset ( )

Delets all data and resest the axis object to its original state.

◆ setAxis() [1/2]

void GRID_INTERP::axis::setAxis ( double  origin,
double  dx,
int  N 
)

Set the Axis tick values when the space between the ticks is constant.

Parameters
originis the starting value
dxis the space between the ticks
Nis the number of tick values to generate.

◆ setAxis() [2/2]

void GRID_INTERP::axis::setAxis ( std::vector< double > &  x_in)

Set the Axis tick values with the input vector. This is used to set variable space grid data.

Parameters
x_in

Member Data Documentation

◆ bConst

bool GRID_INTERP::axis::bConst = false
private

This flag is set to true or false according to which setAxis method is used.

◆ dx

double GRID_INTERP::axis::dx = 0.0
private

The distance between the ticks. This is used only for constant grid values.

◆ N

int GRID_INTERP::axis::N = 0
private

is the index of the last element

◆ origin

double GRID_INTERP::axis::origin = 0.0
private

this is the origin of the grid. When the object is populated with variable data this is not used

◆ x

std::vector<double> GRID_INTERP::axis::x
private

is the vector that containts the tick values


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