Opm::UniformXTabulated2DFunction< Scalar > Class Template Reference

Implements a scalar function that depends on two variables and which is sampled uniformly in the X direction, but non-uniformly on the Y axis-. More...

#include <UniformXTabulated2DFunction.hpp>

Public Types

enum  InterpolationPolicy { LeftExtreme , RightExtreme , Vertical }
 Indicates how interpolation will be performed. More...
 
typedef std::tuple< Scalar, Scalar, Scalar > SamplePoint
 

Public Member Functions

 UniformXTabulated2DFunction (const InterpolationPolicy interpolationGuide=Vertical)
 
 UniformXTabulated2DFunction (const std::vector< Scalar > &xPos, const std::vector< Scalar > &yPos, const std::vector< std::vector< SamplePoint > > &samples, InterpolationPolicy interpolationGuide)
 
Scalar xMin () const
 Returns the minimum of the X coordinate of the sampling points. More...
 
Scalar xMax () const
 Returns the maximum of the X coordinate of the sampling points. More...
 
Scalar xAt (size_t i) const
 Returns the value of the X coordinate of the sampling points. More...
 
Scalar yAt (size_t i, size_t j) const
 Returns the value of the Y coordinate of a sampling point. More...
 
Scalar valueAt (size_t i, size_t j) const
 Returns the value of a sampling point. More...
 
size_t numX () const
 Returns the number of sampling points in X direction. More...
 
Scalar yMin (unsigned i) const
 Returns the minimum of the Y coordinate of the sampling points for a given column. More...
 
Scalar yMax (unsigned i) const
 Returns the maximum of the Y coordinate of the sampling points for a given column. More...
 
size_t numY (unsigned i) const
 Returns the number of sampling points in Y direction a given column. More...
 
Scalar iToX (unsigned i) const
 Return the position on the x-axis of the i-th interval. More...
 
const std::vector< std::vector< SamplePoint > > & samples () const
 
const std::vector< Scalar > & xPos () const
 
const std::vector< Scalar > & yPos () const
 
InterpolationPolicy interpolationGuide () const
 
Scalar jToY (unsigned i, unsigned j) const
 Return the position on the y-axis of the j-th interval. More...
 
template<class Evaluation >
unsigned xSegmentIndex (const Evaluation &x, bool extrapolate=false) const
 Return the interval index of a given position on the x-axis. More...
 
template<class Evaluation >
Evaluation xToAlpha (const Evaluation &x, unsigned segmentIdx) const
 Return the relative position of an x value in an intervall. More...
 
template<class Evaluation >
unsigned ySegmentIndex (const Evaluation &y, unsigned xSampleIdx, bool extrapolate=false) const
 Return the interval index of a given position on the y-axis. More...
 
template<class Evaluation >
Evaluation yToBeta (const Evaluation &y, unsigned xSampleIdx, unsigned ySegmentIdx) const
 Return the relative position of an y value in an interval. More...
 
template<class Evaluation >
bool applies (const Evaluation &x, const Evaluation &y) const
 Returns true iff a coordinate lies in the tabulated range. More...
 
template<class Evaluation >
Evaluation eval (const Evaluation &x, const Evaluation &y, bool extrapolate=false) const
 Evaluate the function at a given (x,y) position. More...
 
size_t appendXPos (Scalar nextX)
 Set the x-position of a vertical line. More...
 
size_t appendSamplePoint (size_t i, Scalar y, Scalar value)
 Append a sample point. More...
 
void print (std::ostream &os=std::cout) const
 Print the table for debugging purposes. More...
 
bool operator== (const UniformXTabulated2DFunction< Scalar > &data) const
 

Detailed Description

template<class Scalar>
class Opm::UniformXTabulated2DFunction< Scalar >

Implements a scalar function that depends on two variables and which is sampled uniformly in the X direction, but non-uniformly on the Y axis-.

"Uniform on the X-axis" means that all Y sampling points must be located along a line for this value. This class can be used when the sampling points are calculated at run time.

Member Typedef Documentation

◆ SamplePoint

template<class Scalar >
typedef std::tuple<Scalar, Scalar, Scalar> Opm::UniformXTabulated2DFunction< Scalar >::SamplePoint

Member Enumeration Documentation

◆ InterpolationPolicy

Indicates how interpolation will be performed.

Normal interpolation is done by interpolating vertically between lines of sample points, whereas LeftExtreme or RightExtreme implies guided interpolation, where interpolation is done parallel to a guide line. With LeftExtreme the lowest Y values will be used for the guide, and the guide line slope extends unchanged to infinity. With RightExtreme, the highest Y values are used, and the slope decreases linearly down to 0 (normal interpolation) for y <= 0.

Enumerator
LeftExtreme 
RightExtreme 
Vertical 

Constructor & Destructor Documentation

◆ UniformXTabulated2DFunction() [1/2]

template<class Scalar >
Opm::UniformXTabulated2DFunction< Scalar >::UniformXTabulated2DFunction ( const InterpolationPolicy  interpolationGuide = Vertical)
inlineexplicit

◆ UniformXTabulated2DFunction() [2/2]

template<class Scalar >
Opm::UniformXTabulated2DFunction< Scalar >::UniformXTabulated2DFunction ( const std::vector< Scalar > &  xPos,
const std::vector< Scalar > &  yPos,
const std::vector< std::vector< SamplePoint > > &  samples,
InterpolationPolicy  interpolationGuide 
)
inline

Member Function Documentation

◆ appendSamplePoint()

template<class Scalar >
size_t Opm::UniformXTabulated2DFunction< Scalar >::appendSamplePoint ( size_t  i,
Scalar  y,
Scalar  value 
)
inline

Append a sample point.

Returns the i index of the new point within its line.

References Opm::UniformXTabulated2DFunction< Scalar >::iToX(), and Opm::UniformXTabulated2DFunction< Scalar >::numX().

◆ appendXPos()

template<class Scalar >
size_t Opm::UniformXTabulated2DFunction< Scalar >::appendXPos ( Scalar  nextX)
inline

Set the x-position of a vertical line.

Returns the i index of that line.

◆ applies()

template<class Scalar >
template<class Evaluation >
bool Opm::UniformXTabulated2DFunction< Scalar >::applies ( const Evaluation &  x,
const Evaluation &  y 
) const
inline

◆ eval()

template<class Scalar >
template<class Evaluation >
Evaluation Opm::UniformXTabulated2DFunction< Scalar >::eval ( const Evaluation &  x,
const Evaluation &  y,
bool  extrapolate = false 
) const
inline

◆ interpolationGuide()

template<class Scalar >
InterpolationPolicy Opm::UniformXTabulated2DFunction< Scalar >::interpolationGuide ( ) const
inline

◆ iToX()

template<class Scalar >
Scalar Opm::UniformXTabulated2DFunction< Scalar >::iToX ( unsigned  i) const
inline

Return the position on the x-axis of the i-th interval.

References Opm::UniformXTabulated2DFunction< Scalar >::numX().

Referenced by Opm::UniformXTabulated2DFunction< Scalar >::appendSamplePoint().

◆ jToY()

template<class Scalar >
Scalar Opm::UniformXTabulated2DFunction< Scalar >::jToY ( unsigned  i,
unsigned  j 
) const
inline

Return the position on the y-axis of the j-th interval.

References Opm::UniformXTabulated2DFunction< Scalar >::numX().

◆ numX()

◆ numY()

template<class Scalar >
size_t Opm::UniformXTabulated2DFunction< Scalar >::numY ( unsigned  i) const
inline

Returns the number of sampling points in Y direction a given column.

Referenced by Opm::UniformXTabulated2DFunction< Scalar >::print(), and Opm::UniformXTabulated2DFunction< Scalar >::yToBeta().

◆ operator==()

◆ print()

template<class Scalar >
void Opm::UniformXTabulated2DFunction< Scalar >::print ( std::ostream &  os = std::cout) const
inline

◆ samples()

template<class Scalar >
const std::vector< std::vector< SamplePoint > > & Opm::UniformXTabulated2DFunction< Scalar >::samples ( ) const
inline

◆ valueAt()

template<class Scalar >
Scalar Opm::UniformXTabulated2DFunction< Scalar >::valueAt ( size_t  i,
size_t  j 
) const
inline

Returns the value of a sampling point.

Referenced by Opm::UniformXTabulated2DFunction< Scalar >::eval().

◆ xAt()

template<class Scalar >
Scalar Opm::UniformXTabulated2DFunction< Scalar >::xAt ( size_t  i) const
inline

Returns the value of the X coordinate of the sampling points.

◆ xMax()

template<class Scalar >
Scalar Opm::UniformXTabulated2DFunction< Scalar >::xMax ( ) const
inline

◆ xMin()

template<class Scalar >
Scalar Opm::UniformXTabulated2DFunction< Scalar >::xMin ( ) const
inline

◆ xPos()

template<class Scalar >
const std::vector< Scalar > & Opm::UniformXTabulated2DFunction< Scalar >::xPos ( ) const
inline

◆ xSegmentIndex()

template<class Scalar >
template<class Evaluation >
unsigned Opm::UniformXTabulated2DFunction< Scalar >::xSegmentIndex ( const Evaluation &  x,
bool  extrapolate = false 
) const
inline

◆ xToAlpha()

template<class Scalar >
template<class Evaluation >
Evaluation Opm::UniformXTabulated2DFunction< Scalar >::xToAlpha ( const Evaluation &  x,
unsigned  segmentIdx 
) const
inline

Return the relative position of an x value in an intervall.

The returned value can be larger than 1 or smaller than zero if it is outside of the range of the segment. In particular this happens for the extrapolation case.

Referenced by Opm::UniformXTabulated2DFunction< Scalar >::applies(), and Opm::UniformXTabulated2DFunction< Scalar >::eval().

◆ yAt()

template<class Scalar >
Scalar Opm::UniformXTabulated2DFunction< Scalar >::yAt ( size_t  i,
size_t  j 
) const
inline

Returns the value of the Y coordinate of a sampling point.

◆ yMax()

template<class Scalar >
Scalar Opm::UniformXTabulated2DFunction< Scalar >::yMax ( unsigned  i) const
inline

Returns the maximum of the Y coordinate of the sampling points for a given column.

Referenced by Opm::UniformXTabulated2DFunction< Scalar >::print(), and Opm::UniformXTabulated2DFunction< Scalar >::ySegmentIndex().

◆ yMin()

template<class Scalar >
Scalar Opm::UniformXTabulated2DFunction< Scalar >::yMin ( unsigned  i) const
inline

Returns the minimum of the Y coordinate of the sampling points for a given column.

Referenced by Opm::UniformXTabulated2DFunction< Scalar >::print(), and Opm::UniformXTabulated2DFunction< Scalar >::ySegmentIndex().

◆ yPos()

template<class Scalar >
const std::vector< Scalar > & Opm::UniformXTabulated2DFunction< Scalar >::yPos ( ) const
inline

◆ ySegmentIndex()

template<class Scalar >
template<class Evaluation >
unsigned Opm::UniformXTabulated2DFunction< Scalar >::ySegmentIndex ( const Evaluation &  y,
unsigned  xSampleIdx,
bool  extrapolate = false 
) const
inline

◆ yToBeta()

template<class Scalar >
template<class Evaluation >
Evaluation Opm::UniformXTabulated2DFunction< Scalar >::yToBeta ( const Evaluation &  y,
unsigned  xSampleIdx,
unsigned  ySegmentIdx 
) const
inline

Return the relative position of an y value in an interval.

The returned value can be larger than 1 or smaller than zero if it is outside of the range of the segment. In particular this happens for the extrapolation case.

References Opm::UniformXTabulated2DFunction< Scalar >::numX(), and Opm::UniformXTabulated2DFunction< Scalar >::numY().

Referenced by Opm::UniformXTabulated2DFunction< Scalar >::eval().


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