3.4
DUNE for Multi-{Phase, Component, Scale, Physics, ...} flow and transport in porous media
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
Dumux::Spline< Scalar, 2 > Class Template Reference

Spline for two sampling points. More...

#include <dumux/common/spline.hh>

Inheritance diagram for Dumux::Spline< Scalar, 2 >:

Description

template<class Scalar>
class Dumux::Spline< Scalar, 2 >

Spline for two sampling points.

For this type of spline there is no natural spline.

Public Member Functions

 Spline ()
 
template<class ScalarArrayX , class ScalarArrayY >
 Spline (const ScalarArrayX &x, const ScalarArrayY &y, Scalar m0, Scalar m1)
 Convenience constructor for a full spline. More...
 
template<class PointArray >
 Spline (const PointArray &points, Scalar m0, Scalar m1)
 Convenience constructor for a full spline. More...
 
 Spline (Scalar x0, Scalar x1, Scalar y0, Scalar y1, Scalar m0, Scalar m1)
 Convenience constructor for a full spline. More...
 
int numSamples () const
 Returns the number of sampling points. More...
 
void set (Scalar x0, Scalar x1, Scalar y0, Scalar y1, Scalar m0, Scalar m1)
 Set the sampling points and the boundary slopes of the spline. More...
 
template<class ScalarContainer >
void setXYArrays (int nSamples, const ScalarContainer &x, const ScalarContainer &y, Scalar m0, Scalar m1)
 Set the sampling points and the boundary slopes of the spline. More...
 
template<class ScalarContainerX , class ScalarContainerY >
void setXYContainers (const ScalarContainerX &x, const ScalarContainerY &y, Scalar m0, Scalar m1)
 Set the sampling points and the boundary slopes of the spline. More...
 
template<class PointArray >
void setArrayOfPoints (int nSamples, const PointArray &points, Scalar m0, Scalar m1)
 Set the sampling points and the boundary slopes of the spline. More...
 
template<class PointContainer >
void setContainerOfPoints (const PointContainer &points, Scalar m0, Scalar m1)
 Set the sampling points and the boundary slopes from an STL-like container of points. More...
 
template<class TupleContainer >
void setContainerOfTuples (const TupleContainer &tuples, Scalar m0, Scalar m1)
 Set the sampling points and the boundary slopes from an STL-like container of tuples. More...
 
bool applies (Scalar x) const
 Return true if the given x is in range [x1, xn]. More...
 
Scalar xMin () const
 Return the x value of the leftmost sampling point. More...
 
Scalar xMax () const
 Return the x value of the rightmost sampling point. More...
 
void printCSV (Scalar xi0, Scalar xi1, int k) const
 Prints k tuples of the format (x, y, dx/dy, isMonotonic) to stdout. More...
 
Scalar eval (Scalar x, bool extrapolate=false) const
 Evaluate the spline at a given position. More...
 
Scalar evalDerivative (Scalar x, bool extrapolate=false) const
 Evaluate the spline's derivative at a given position. More...
 
Scalar intersect (Scalar a, Scalar b, Scalar c, Scalar d) const
 Find the intersections of the spline with a cubic polynomial in the whole intervall, throws Dune::MathError exception if there is more or less than one solution. More...
 
Scalar intersectInterval (Scalar x0, Scalar x1, Scalar a, Scalar b, Scalar c, Scalar d) const
 Find the intersections of the spline with a cubic polynomial in a sub-intervall of the spline, throws Dune::MathError exception if there is more or less than one solution. More...
 
int monotonic (Scalar x0, Scalar x1) const
 Returns 1 if the spline is monotonically increasing, -1 if the spline is mononously decreasing and 0 if the spline is not monotonous in the interval (x0, x1). More...
 
int monotonic () const
 Same as monotonic(x0, x1), but with the entire range of the spline as interval. More...
 

Protected Member Functions

void assignXY_ (Scalar x0, Scalar x1, Scalar y0, Scalar y1)
 
Scalar x_ (int i) const
 Returns the x coordinate of the i-th sampling point. More...
 
Scalar y_ (int i) const
 Returns the y coordinate of the i-th sampling point. More...
 
Scalar moment_ (int i) const
 Returns the moment (i.e. second derivative) of the spline at the i-th sampling point. More...
 
void assignSamplingPoints_ (DestVector &destX, DestVector &destY, const SourceVector &srcX, const SourceVector &srcY, int numSamples)
 Set the sampling point vectors. More...
 
void assignFromArrayList_ (DestVector &destX, DestVector &destY, const ListIterator &srcBegin, const ListIterator &srcEnd, int numSamples)
 
void assignFromTupleList_ (DestVector &destX, DestVector &destY, ListIterator srcBegin, ListIterator srcEnd, int numSamples)
 Set the sampling points. More...
 
void makePeriodicSystem_ (Matrix &M, Vector &d)
 Make the linear system of equations Mx = d which results in the moments of the periodic spline. More...
 
void makeFullSystem_ (Matrix &M, Vector &d, Scalar m0, Scalar m1)
 Make the linear system of equations Mx = d which results in the moments of the full spline. More...
 
void makeNaturalSystem_ (Matrix &M, Vector &d)
 Make the linear system of equations Mx = d which results in the moments of the natural spline. Stoer 2005: Numerische Mathematik 1, p. 111 [64]. More...
 
Scalar eval_ (Scalar x, int i) const
 
Scalar evalDerivative_ (Scalar x, int i) const
 
int monotonic_ (int i, Scalar x0, Scalar x1) const
 
int intersectSegment_ (Scalar *sol, int segIdx, Scalar a, Scalar b, Scalar c, Scalar d, Scalar x0=-1e100, Scalar x1=1e100) const
 Find all the intersections of a segment of the spline with a cubic polynomial within a specified interval. More...
 
int segmentIdx_ (Scalar x) const
 
Scalar h_ (int i) const
 Returns x[i] - x[i - 1]. More...
 
Scalar a_ (int i) const
 
Scalar b_ (int i) const
 
Scalar c_ (int i) const
 
Scalar d_ (int i) const
 
int numSamples_ () const
 Returns the number of sampling points. More...
 

Protected Attributes

Vector xPos_
 
Vector yPos_
 
Vector m_
 

Constructor & Destructor Documentation

◆ Spline() [1/4]

template<class Scalar >
Dumux::Spline< Scalar, 2 >::Spline ( )
inline

◆ Spline() [2/4]

template<class Scalar >
template<class ScalarArrayX , class ScalarArrayY >
Dumux::Spline< Scalar, 2 >::Spline ( const ScalarArrayX &  x,
const ScalarArrayY &  y,
Scalar  m0,
Scalar  m1 
)
inline

Convenience constructor for a full spline.

Parameters
xAn array containing the \(x\) values of the spline's sampling points
yAn array containing the \(y\) values of the spline's sampling points
m0The slope of the spline at \(x_0\)
m1The slope of the spline at \(x_n\)

◆ Spline() [3/4]

template<class Scalar >
template<class PointArray >
Dumux::Spline< Scalar, 2 >::Spline ( const PointArray &  points,
Scalar  m0,
Scalar  m1 
)
inline

Convenience constructor for a full spline.

Parameters
pointsAn array of \((x,y)\) tuples of the spline's sampling points
m0The slope of the spline at \(x_0\)
m1The slope of the spline at \(x_n\)

◆ Spline() [4/4]

template<class Scalar >
Dumux::Spline< Scalar, 2 >::Spline ( Scalar  x0,
Scalar  x1,
Scalar  y0,
Scalar  y1,
Scalar  m0,
Scalar  m1 
)
inline

Convenience constructor for a full spline.

Parameters
x0The \(x\) value of the first sampling point
x1The \(x\) value of the second sampling point
y0The \(y\) value of the first sampling point
y1The \(y\) value of the second sampling point
m0The slope of the spline at \(x_0\)
m1The slope of the spline at \(x_n\)

Member Function Documentation

◆ a_()

Scalar Dumux::SplineCommon_< Scalar , Spline< Scalar, 2 > >::a_ ( int  i) const
inlineprotectedinherited

◆ applies()

bool Dumux::SplineCommon_< Scalar , Spline< Scalar, 2 > >::applies ( Scalar  x) const
inlineinherited

Return true if the given x is in range [x1, xn].

◆ assignFromArrayList_()

void Dumux::SplineCommon_< Scalar , Spline< Scalar, 2 > >::assignFromArrayList_ ( DestVector &  destX,
DestVector &  destY,
const ListIterator &  srcBegin,
const ListIterator &  srcEnd,
int  numSamples 
)
inlineprotectedinherited

◆ assignFromTupleList_()

void Dumux::SplineCommon_< Scalar , Spline< Scalar, 2 > >::assignFromTupleList_ ( DestVector &  destX,
DestVector &  destY,
ListIterator  srcBegin,
ListIterator  srcEnd,
int  numSamples 
)
inlineprotectedinherited

Set the sampling points.

Here we assume that the elements of the source vector have an [] operator where v[0] is the x value and v[1] is the y value if the sampling point.

◆ assignSamplingPoints_()

void Dumux::SplineCommon_< Scalar , Spline< Scalar, 2 > >::assignSamplingPoints_ ( DestVector &  destX,
DestVector &  destY,
const SourceVector &  srcX,
const SourceVector &  srcY,
int  numSamples 
)
inlineprotectedinherited

Set the sampling point vectors.

This takes care that the order of the x-values is ascending, although the input must be ordered already!

◆ assignXY_()

template<class Scalar >
void Dumux::Spline< Scalar, 2 >::assignXY_ ( Scalar  x0,
Scalar  x1,
Scalar  y0,
Scalar  y1 
)
inlineprotected

◆ b_()

Scalar Dumux::SplineCommon_< Scalar , Spline< Scalar, 2 > >::b_ ( int  i) const
inlineprotectedinherited

◆ c_()

Scalar Dumux::SplineCommon_< Scalar , Spline< Scalar, 2 > >::c_ ( int  i) const
inlineprotectedinherited

◆ d_()

Scalar Dumux::SplineCommon_< Scalar , Spline< Scalar, 2 > >::d_ ( int  i) const
inlineprotectedinherited

◆ eval()

Scalar Dumux::SplineCommon_< Scalar , Spline< Scalar, 2 > >::eval ( Scalar  x,
bool  extrapolate = false 
) const
inlineinherited

Evaluate the spline at a given position.

Parameters
xThe value on the abscissa where the spline ought to be evaluated
extrapolateIf this parameter is set to true, the spline will be extended beyond its range by straight lines, if false calling extrapolate for \( x \not [x_{min}, x_{max}]\) will cause a failed assertation.

◆ eval_()

Scalar Dumux::SplineCommon_< Scalar , Spline< Scalar, 2 > >::eval_ ( Scalar  x,
int  i 
) const
inlineprotectedinherited

◆ evalDerivative()

Scalar Dumux::SplineCommon_< Scalar , Spline< Scalar, 2 > >::evalDerivative ( Scalar  x,
bool  extrapolate = false 
) const
inlineinherited

Evaluate the spline's derivative at a given position.

Parameters
xThe value on the abscissa where the spline's derivative ought to be evaluated
extrapolateIf this parameter is set to true, the spline will be extended beyond its range by straight lines, if false calling extrapolate for \( x \not [x_{min}, x_{max}]\) will cause a failed assertation.

◆ evalDerivative_()

Scalar Dumux::SplineCommon_< Scalar , Spline< Scalar, 2 > >::evalDerivative_ ( Scalar  x,
int  i 
) const
inlineprotectedinherited

◆ h_()

Scalar Dumux::SplineCommon_< Scalar , Spline< Scalar, 2 > >::h_ ( int  i) const
inlineprotectedinherited

Returns x[i] - x[i - 1].

◆ intersect()

Scalar Dumux::SplineCommon_< Scalar , Spline< Scalar, 2 > >::intersect ( Scalar  a,
Scalar  b,
Scalar  c,
Scalar  d 
) const
inlineinherited

Find the intersections of the spline with a cubic polynomial in the whole intervall, throws Dune::MathError exception if there is more or less than one solution.

◆ intersectInterval()

Scalar Dumux::SplineCommon_< Scalar , Spline< Scalar, 2 > >::intersectInterval ( Scalar  x0,
Scalar  x1,
Scalar  a,
Scalar  b,
Scalar  c,
Scalar  d 
) const
inlineinherited

Find the intersections of the spline with a cubic polynomial in a sub-intervall of the spline, throws Dune::MathError exception if there is more or less than one solution.

◆ intersectSegment_()

int Dumux::SplineCommon_< Scalar , Spline< Scalar, 2 > >::intersectSegment_ ( Scalar *  sol,
int  segIdx,
Scalar  a,
Scalar  b,
Scalar  c,
Scalar  d,
Scalar  x0 = -1e100,
Scalar  x1 = 1e100 
) const
inlineprotectedinherited

Find all the intersections of a segment of the spline with a cubic polynomial within a specified interval.

◆ makeFullSystem_()

void Dumux::SplineCommon_< Scalar , Spline< Scalar, 2 > >::makeFullSystem_ ( Matrix &  M,
Vector &  d,
Scalar  m0,
Scalar  m1 
)
inlineprotectedinherited

Make the linear system of equations Mx = d which results in the moments of the full spline.

◆ makeNaturalSystem_()

void Dumux::SplineCommon_< Scalar , Spline< Scalar, 2 > >::makeNaturalSystem_ ( Matrix &  M,
Vector &  d 
)
inlineprotectedinherited

Make the linear system of equations Mx = d which results in the moments of the natural spline. Stoer 2005: Numerische Mathematik 1, p. 111 [64].

◆ makePeriodicSystem_()

void Dumux::SplineCommon_< Scalar , Spline< Scalar, 2 > >::makePeriodicSystem_ ( Matrix &  M,
Vector &  d 
)
inlineprotectedinherited

Make the linear system of equations Mx = d which results in the moments of the periodic spline.

When solving Mx = d, it should be noted that x[0] is trash and needs to be set to x[n-1]

◆ moment_()

template<class Scalar >
Scalar Dumux::Spline< Scalar, 2 >::moment_ ( int  i) const
inlineprotected

Returns the moment (i.e. second derivative) of the spline at the i-th sampling point.

◆ monotonic() [1/2]

int Dumux::SplineCommon_< Scalar , Spline< Scalar, 2 > >::monotonic ( ) const
inlineinherited

Same as monotonic(x0, x1), but with the entire range of the spline as interval.

◆ monotonic() [2/2]

int Dumux::SplineCommon_< Scalar , Spline< Scalar, 2 > >::monotonic ( Scalar  x0,
Scalar  x1 
) const
inlineinherited

Returns 1 if the spline is monotonically increasing, -1 if the spline is mononously decreasing and 0 if the spline is not monotonous in the interval (x0, x1).

In the corner case where the whole spline is flat, it returns 2.

◆ monotonic_()

int Dumux::SplineCommon_< Scalar , Spline< Scalar, 2 > >::monotonic_ ( int  i,
Scalar  x0,
Scalar  x1 
) const
inlineprotectedinherited

◆ numSamples()

template<class Scalar >
int Dumux::Spline< Scalar, 2 >::numSamples ( ) const
inline

Returns the number of sampling points.

◆ numSamples_()

int Dumux::SplineCommon_< Scalar , Spline< Scalar, 2 > >::numSamples_ ( ) const
inlineprotectedinherited

Returns the number of sampling points.

◆ printCSV()

void Dumux::SplineCommon_< Scalar , Spline< Scalar, 2 > >::printCSV ( Scalar  xi0,
Scalar  xi1,
int  k 
) const
inlineinherited

Prints k tuples of the format (x, y, dx/dy, isMonotonic) to stdout.

If the spline does not apply for parts of [x0, x1] it is extrapolated using a straight line. The result can be inspected using the following commands:

--------— snip --------— ./yourProgramm > spline.csv gnuplot

gnuplot> plot "spline.csv" using 1:2 w l ti "Curve", \ "spline.csv" using 1:3 w l ti "Derivative", \ "spline.csv" using 1:4 w p ti "Monotonic" --------— snap --------—

◆ segmentIdx_()

int Dumux::SplineCommon_< Scalar , Spline< Scalar, 2 > >::segmentIdx_ ( Scalar  x) const
inlineprotectedinherited

◆ set()

template<class Scalar >
void Dumux::Spline< Scalar, 2 >::set ( Scalar  x0,
Scalar  x1,
Scalar  y0,
Scalar  y1,
Scalar  m0,
Scalar  m1 
)
inline

Set the sampling points and the boundary slopes of the spline.

Parameters
x0The \(x\) value of the first sampling point
x1The \(x\) value of the second sampling point
y0The \(y\) value of the first sampling point
y1The \(y\) value of the second sampling point
m0The slope of the spline at \(x_0\)
m1The slope of the spline at \(x_1\)

◆ setArrayOfPoints()

template<class Scalar >
template<class PointArray >
void Dumux::Spline< Scalar, 2 >::setArrayOfPoints ( int  nSamples,
const PointArray &  points,
Scalar  m0,
Scalar  m1 
)
inline

Set the sampling points and the boundary slopes of the spline.

Parameters
nSamplesThe number of sampling points (must be >= 2)
pointsAn array of \((x,y)\) tuples of the spline's sampling points
m0The slope of the spline at \(x_0\)
m1The slope of the spline at \(x_1\)

◆ setContainerOfPoints()

template<class Scalar >
template<class PointContainer >
void Dumux::Spline< Scalar, 2 >::setContainerOfPoints ( const PointContainer &  points,
Scalar  m0,
Scalar  m1 
)
inline

Set the sampling points and the boundary slopes from an STL-like container of points.

Parameters
pointsAn array of \((x,y)\) tuples of the spline's sampling points
m0The slope of the spline at \(x_0\)
m1The slope of the spline at \(x_1\)

◆ setContainerOfTuples()

template<class Scalar >
template<class TupleContainer >
void Dumux::Spline< Scalar, 2 >::setContainerOfTuples ( const TupleContainer &  tuples,
Scalar  m0,
Scalar  m1 
)
inline

Set the sampling points and the boundary slopes from an STL-like container of tuples.

Parameters
tuplesAn array of \((x,y)\) tuples of the spline's sampling points
m0The slope of the spline at \(x_0\)
m1The slope of the spline at \(x_1\)

◆ setXYArrays()

template<class Scalar >
template<class ScalarContainer >
void Dumux::Spline< Scalar, 2 >::setXYArrays ( int  nSamples,
const ScalarContainer &  x,
const ScalarContainer &  y,
Scalar  m0,
Scalar  m1 
)
inline

Set the sampling points and the boundary slopes of the spline.

Parameters
nSamplesThe number of sampling points (must be >= 2)
xAn array containing the \(x\) values of the sampling points
yAn array containing the \(y\) values of the sampling points
m0The slope of the spline at \(x_0\)
m1The slope of the spline at \(x_1\)

◆ setXYContainers()

template<class Scalar >
template<class ScalarContainerX , class ScalarContainerY >
void Dumux::Spline< Scalar, 2 >::setXYContainers ( const ScalarContainerX &  x,
const ScalarContainerY &  y,
Scalar  m0,
Scalar  m1 
)
inline

Set the sampling points and the boundary slopes of the spline.

Parameters
xAn array containing the \(x\) values of the sampling points
yAn array containing the \(y\) values of the sampling points
m0The slope of the spline at \(x_0\)
m1The slope of the spline at \(x_1\)

◆ x_()

template<class Scalar >
Scalar Dumux::Spline< Scalar, 2 >::x_ ( int  i) const
inlineprotected

Returns the x coordinate of the i-th sampling point.

◆ xMax()

Scalar Dumux::SplineCommon_< Scalar , Spline< Scalar, 2 > >::xMax ( ) const
inlineinherited

Return the x value of the rightmost sampling point.

◆ xMin()

Scalar Dumux::SplineCommon_< Scalar , Spline< Scalar, 2 > >::xMin ( ) const
inlineinherited

Return the x value of the leftmost sampling point.

◆ y_()

template<class Scalar >
Scalar Dumux::Spline< Scalar, 2 >::y_ ( int  i) const
inlineprotected

Returns the y coordinate of the i-th sampling point.

Member Data Documentation

◆ m_

template<class Scalar >
Vector Dumux::Spline< Scalar, 2 >::m_
protected

◆ xPos_

template<class Scalar >
Vector Dumux::Spline< Scalar, 2 >::xPos_
protected

◆ yPos_

template<class Scalar >
Vector Dumux::Spline< Scalar, 2 >::yPos_
protected

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