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

The common code for all 3rd order polynomial splines. More...

#include <dumux/common/splinecommon_.hh>

Inheritance diagram for Dumux::SplineCommon_< ScalarT, ImplementationT >:

Description

template<class ScalarT, class ImplementationT>
class Dumux::SplineCommon_< ScalarT, ImplementationT >

The common code for all 3rd order polynomial splines.

Public Member Functions

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

 SplineCommon_ ()=default
 
template<class DestVector , class SourceVector >
void assignSamplingPoints_ (DestVector &destX, DestVector &destY, const SourceVector &srcX, const SourceVector &srcY, int numSamples)
 Set the sampling point vectors. More...
 
template<class DestVector , class ListIterator >
void assignFromArrayList_ (DestVector &destX, DestVector &destY, const ListIterator &srcBegin, const ListIterator &srcEnd, int numSamples)
 
template<class DestVector , class ListIterator >
void assignFromTupleList_ (DestVector &destX, DestVector &destY, ListIterator srcBegin, ListIterator srcEnd, int numSamples)
 Set the sampling points. More...
 
template<class Vector , class Matrix >
void makePeriodicSystem_ (Matrix &M, Vector &d)
 Make the linear system of equations Mx = d which results in the moments of the periodic spline. More...
 
template<class Vector , class Matrix >
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...
 
template<class Vector , class Matrix >
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 x_ (int i) const
 Returns the y 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...
 
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...
 

Constructor & Destructor Documentation

◆ SplineCommon_()

template<class ScalarT , class ImplementationT >
Dumux::SplineCommon_< ScalarT, ImplementationT >::SplineCommon_ ( )
protecteddefault

Member Function Documentation

◆ a_()

template<class ScalarT , class ImplementationT >
Scalar Dumux::SplineCommon_< ScalarT, ImplementationT >::a_ ( int  i) const
inlineprotected

◆ applies()

template<class ScalarT , class ImplementationT >
bool Dumux::SplineCommon_< ScalarT, ImplementationT >::applies ( Scalar  x) const
inline

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

◆ assignFromArrayList_()

template<class ScalarT , class ImplementationT >
template<class DestVector , class ListIterator >
void Dumux::SplineCommon_< ScalarT, ImplementationT >::assignFromArrayList_ ( DestVector &  destX,
DestVector &  destY,
const ListIterator &  srcBegin,
const ListIterator &  srcEnd,
int  numSamples 
)
inlineprotected

◆ assignFromTupleList_()

template<class ScalarT , class ImplementationT >
template<class DestVector , class ListIterator >
void Dumux::SplineCommon_< ScalarT, ImplementationT >::assignFromTupleList_ ( DestVector &  destX,
DestVector &  destY,
ListIterator  srcBegin,
ListIterator  srcEnd,
int  numSamples 
)
inlineprotected

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_()

template<class ScalarT , class ImplementationT >
template<class DestVector , class SourceVector >
void Dumux::SplineCommon_< ScalarT, ImplementationT >::assignSamplingPoints_ ( DestVector &  destX,
DestVector &  destY,
const SourceVector &  srcX,
const SourceVector &  srcY,
int  numSamples 
)
inlineprotected

Set the sampling point vectors.

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

◆ b_()

template<class ScalarT , class ImplementationT >
Scalar Dumux::SplineCommon_< ScalarT, ImplementationT >::b_ ( int  i) const
inlineprotected

◆ c_()

template<class ScalarT , class ImplementationT >
Scalar Dumux::SplineCommon_< ScalarT, ImplementationT >::c_ ( int  i) const
inlineprotected

◆ d_()

template<class ScalarT , class ImplementationT >
Scalar Dumux::SplineCommon_< ScalarT, ImplementationT >::d_ ( int  i) const
inlineprotected

◆ eval()

template<class ScalarT , class ImplementationT >
Scalar Dumux::SplineCommon_< ScalarT, ImplementationT >::eval ( Scalar  x,
bool  extrapolate = false 
) const
inline

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_()

template<class ScalarT , class ImplementationT >
Scalar Dumux::SplineCommon_< ScalarT, ImplementationT >::eval_ ( Scalar  x,
int  i 
) const
inlineprotected

◆ evalDerivative()

template<class ScalarT , class ImplementationT >
Scalar Dumux::SplineCommon_< ScalarT, ImplementationT >::evalDerivative ( Scalar  x,
bool  extrapolate = false 
) const
inline

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_()

template<class ScalarT , class ImplementationT >
Scalar Dumux::SplineCommon_< ScalarT, ImplementationT >::evalDerivative_ ( Scalar  x,
int  i 
) const
inlineprotected

◆ h_()

template<class ScalarT , class ImplementationT >
Scalar Dumux::SplineCommon_< ScalarT, ImplementationT >::h_ ( int  i) const
inlineprotected

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

◆ intersect()

template<class ScalarT , class ImplementationT >
Scalar Dumux::SplineCommon_< ScalarT, ImplementationT >::intersect ( Scalar  a,
Scalar  b,
Scalar  c,
Scalar  d 
) const
inline

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()

template<class ScalarT , class ImplementationT >
Scalar Dumux::SplineCommon_< ScalarT, ImplementationT >::intersectInterval ( Scalar  x0,
Scalar  x1,
Scalar  a,
Scalar  b,
Scalar  c,
Scalar  d 
) const
inline

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_()

template<class ScalarT , class ImplementationT >
int Dumux::SplineCommon_< ScalarT, ImplementationT >::intersectSegment_ ( Scalar *  sol,
int  segIdx,
Scalar  a,
Scalar  b,
Scalar  c,
Scalar  d,
Scalar  x0 = -1e100,
Scalar  x1 = 1e100 
) const
inlineprotected

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

◆ makeFullSystem_()

template<class ScalarT , class ImplementationT >
template<class Vector , class Matrix >
void Dumux::SplineCommon_< ScalarT, ImplementationT >::makeFullSystem_ ( Matrix &  M,
Vector &  d,
Scalar  m0,
Scalar  m1 
)
inlineprotected

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

◆ makeNaturalSystem_()

template<class ScalarT , class ImplementationT >
template<class Vector , class Matrix >
void Dumux::SplineCommon_< ScalarT, ImplementationT >::makeNaturalSystem_ ( Matrix &  M,
Vector &  d 
)
inlineprotected

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_()

template<class ScalarT , class ImplementationT >
template<class Vector , class Matrix >
void Dumux::SplineCommon_< ScalarT, ImplementationT >::makePeriodicSystem_ ( Matrix &  M,
Vector &  d 
)
inlineprotected

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 ScalarT , class ImplementationT >
Scalar Dumux::SplineCommon_< ScalarT, ImplementationT >::moment_ ( int  i) const
inlineprotected

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

◆ monotonic() [1/2]

template<class ScalarT , class ImplementationT >
int Dumux::SplineCommon_< ScalarT, ImplementationT >::monotonic ( ) const
inline

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

◆ monotonic() [2/2]

template<class ScalarT , class ImplementationT >
int Dumux::SplineCommon_< ScalarT, ImplementationT >::monotonic ( Scalar  x0,
Scalar  x1 
) const
inline

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_()

template<class ScalarT , class ImplementationT >
int Dumux::SplineCommon_< ScalarT, ImplementationT >::monotonic_ ( int  i,
Scalar  x0,
Scalar  x1 
) const
inlineprotected

◆ numSamples_()

template<class ScalarT , class ImplementationT >
int Dumux::SplineCommon_< ScalarT, ImplementationT >::numSamples_ ( ) const
inlineprotected

Returns the number of sampling points.

◆ printCSV()

template<class ScalarT , class ImplementationT >
void Dumux::SplineCommon_< ScalarT, ImplementationT >::printCSV ( Scalar  xi0,
Scalar  xi1,
int  k 
) const
inline

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_()

template<class ScalarT , class ImplementationT >
int Dumux::SplineCommon_< ScalarT, ImplementationT >::segmentIdx_ ( Scalar  x) const
inlineprotected

◆ x_()

template<class ScalarT , class ImplementationT >
Scalar Dumux::SplineCommon_< ScalarT, ImplementationT >::x_ ( int  i) const
inlineprotected

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

◆ xMax()

template<class ScalarT , class ImplementationT >
Scalar Dumux::SplineCommon_< ScalarT, ImplementationT >::xMax ( ) const
inline

Return the x value of the rightmost sampling point.

◆ xMin()

template<class ScalarT , class ImplementationT >
Scalar Dumux::SplineCommon_< ScalarT, ImplementationT >::xMin ( ) const
inline

Return the x value of the leftmost sampling point.

◆ y_()

template<class ScalarT , class ImplementationT >
Scalar Dumux::SplineCommon_< ScalarT, ImplementationT >::y_ ( int  i) const
inlineprotected

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


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