3.2-git
DUNE for Multi-{Phase, Component, Scale, Physics, ...} flow and transport in porous media
Loading...
Searching...
No Matches
Dumux::Spline< Scalar, 1 > Class Template Reference

Do not allow splines with one sampling point. More...

#include <dumux/common/spline.hh>

Inheritance diagram for Dumux::Spline< Scalar, 1 >:
Inheritance graph

Description

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

Do not allow splines with one sampling point.

Public Member Functions

int numSamples () const
 Returns the number of sampling points.
void setXYArrays (int numberSamples, const ScalarArrayX &x, const ScalarArrayY &y, Scalar m0, Scalar m1)
 Set the sampling points and the boundary slopes of a full spline using C-style arrays.
void setXYContainers (const ScalarContainerX &x, const ScalarContainerY &y, Scalar m0, Scalar m1)
 Set the sampling points and the boundary slopes of a full spline using STL-compatible containers.
void setArrayOfPoints (int numberSamples, const PointArray &points, Scalar m0, Scalar m1)
 Set the sampling points and the boundary slopes of a full spline using a C-style array.
void setContainerOfPoints (const XYContainer &points, Scalar m0, Scalar m1)
 Set the sampling points and the boundary slopes of a full spline using a STL-compatible container of array-like objects.
void setContainerOfTuples (const XYContainer &points, Scalar m0, Scalar m1)
 Set the sampling points and the boundary slopes of a full spline using a STL-compatible container of tuple-like objects.
bool applies (Scalar x) const
 Return true if the given x is in range [x1, xn].
Scalar xMin () const
 Return the x value of the leftmost sampling point.
Scalar xMax () const
 Return the x value of the rightmost sampling point.
void printCSV (Scalar xi0, Scalar xi1, int k) const
 Prints k tuples of the format (x, y, dx/dy, isMonotonic) to stdout.
Scalar eval (Scalar x, bool extrapolate=false) const
 Evaluate the spline at a given position.
Scalar evalDerivative (Scalar x, bool extrapolate=false) const
 Evaluate the spline's derivative at a given position.
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.
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.
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).
template<class ScalarArrayX, class ScalarArrayY>
void setXYArrays (int numberSamples, const ScalarArrayX &x, const ScalarArrayY &y)
 Set the sampling points natural spline using C-style arrays.
template<class ScalarContainerX, class ScalarContainerY>
void setXYContainers (const ScalarContainerX &x, const ScalarContainerY &y)
 Set the sampling points of a natural spline using STL-compatible containers.
template<class PointArray>
void setArrayOfPoints (int numberSamples, const PointArray &points)
 Set the sampling points of a natural spline using a C-style array.
template<class XYContainer>
void setContainerOfPoints (const XYContainer &points)
 Set the sampling points of a natural spline using a STL-compatible container of array-like objects.
template<class XYContainer>
void setContainerOfTuples (const XYContainer &points)
 Set the sampling points of a natural spline using a STL-compatible container of tuple-like objects.

Protected Member Functions

void makeFullSpline_ (Scalar m0, Scalar m1)
 Create a full spline from the already set sampling points.
void makeNaturalSpline_ ()
 Create a natural spline from the already set sampling points.
Scalar x_ (int i) const
 Returns the x coordinate of the i-th sampling point.
Scalar y_ (int i) const
 Returns the y coordinate of the i-th sampling point.
Scalar moment_ (int i) const
 Returns the moment (i.e. second derivative) of the spline at the i-th sampling point.
void assignSamplingPoints_ (DestVector &destX, DestVector &destY, const SourceVector &srcX, const SourceVector &srcY, int numSamples)
 Set the sampling point vectors.
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.
void makePeriodicSystem_ (Matrix &M, Vector &d)
 Make the linear system of equations Mx = d which results in the moments of the periodic spline.
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.
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 [61].
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.
int segmentIdx_ (Scalar x) const
Scalar h_ (int i) const
 Returns x[i] - x[i - 1].
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.
void makePeriodicSystem_ (Matrix &M, Vector &d)
 Make the linear system of equations Mx = d which results in the moments of the periodic spline.
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.
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 [61].

Protected Attributes

Vector xPos_
Vector yPos_
BlockVector m_

Member Function Documentation

◆ a_()

Scalar Dumux::SplineCommon_< Scalar, FixedLengthSpline_< Scalar, nSamples > >::a_ ( int i) const
inlineprotected

◆ applies()

bool Dumux::SplineCommon_< Scalar, FixedLengthSpline_< Scalar, nSamples > >::applies ( Scalar x) const
inline

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

◆ assignFromArrayList_()

void Dumux::SplineCommon_< Scalar, FixedLengthSpline_< Scalar, nSamples > >::assignFromArrayList_ ( DestVector & destX,
DestVector & destY,
const ListIterator & srcBegin,
const ListIterator & srcEnd,
int numSamples )
inlineprotected

◆ assignFromTupleList_()

void Dumux::SplineCommon_< Scalar, FixedLengthSpline_< Scalar, nSamples > >::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_()

void Dumux::SplineCommon_< Scalar, FixedLengthSpline_< Scalar, nSamples > >::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_()

Scalar Dumux::SplineCommon_< Scalar, FixedLengthSpline_< Scalar, nSamples > >::b_ ( int i) const
inlineprotected

◆ c_()

Scalar Dumux::SplineCommon_< Scalar, FixedLengthSpline_< Scalar, nSamples > >::c_ ( int i) const
inlineprotected

◆ d_()

Scalar Dumux::SplineCommon_< Scalar, FixedLengthSpline_< Scalar, nSamples > >::d_ ( int i) const
inlineprotected

◆ eval()

Scalar Dumux::SplineCommon_< Scalar, FixedLengthSpline_< Scalar, nSamples > >::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_()

Scalar Dumux::SplineCommon_< Scalar, FixedLengthSpline_< Scalar, nSamples > >::eval_ ( Scalar x,
int i ) const
inlineprotected

◆ evalDerivative()

Scalar Dumux::SplineCommon_< Scalar, FixedLengthSpline_< Scalar, nSamples > >::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_()

Scalar Dumux::SplineCommon_< Scalar, FixedLengthSpline_< Scalar, nSamples > >::evalDerivative_ ( Scalar x,
int i ) const
inlineprotected

◆ h_()

Scalar Dumux::SplineCommon_< Scalar, FixedLengthSpline_< Scalar, nSamples > >::h_ ( int i) const
inlineprotected

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

◆ intersect()

Scalar Dumux::SplineCommon_< Scalar, FixedLengthSpline_< Scalar, nSamples > >::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()

Scalar Dumux::SplineCommon_< Scalar, FixedLengthSpline_< Scalar, nSamples > >::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_()

int Dumux::SplineCommon_< Scalar, FixedLengthSpline_< Scalar, nSamples > >::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.

◆ makeFullSpline_()

void Dumux::FixedLengthSpline_< Scalar, nSamples >::makeFullSpline_ ( Scalar m0,
Scalar m1 )
inlineprotected

Create a full spline from the already set sampling points.

Also creates temporary matrix and right hand side vector.

◆ makeFullSystem_() [1/2]

void Dumux::SplineCommon_< Scalar, FixedLengthSpline_< Scalar, nSamples > >::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.

◆ makeFullSystem_() [2/2]

void Dumux::SplineCommon_< ScalarT, FixedLengthSpline_< ScalarT, nSamples > >::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.

◆ makeNaturalSpline_()

void Dumux::FixedLengthSpline_< Scalar, nSamples >::makeNaturalSpline_ ( )
inlineprotected

Create a natural spline from the already set sampling points.

Also creates temporary matrix and right hand side vector.

◆ makeNaturalSystem_() [1/2]

void Dumux::SplineCommon_< Scalar, FixedLengthSpline_< Scalar, nSamples > >::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 [61].

◆ makeNaturalSystem_() [2/2]

void Dumux::SplineCommon_< ScalarT, FixedLengthSpline_< ScalarT, nSamples > >::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 [61].

◆ makePeriodicSystem_() [1/2]

void Dumux::SplineCommon_< Scalar, FixedLengthSpline_< Scalar, nSamples > >::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]

◆ makePeriodicSystem_() [2/2]

void Dumux::SplineCommon_< ScalarT, FixedLengthSpline_< ScalarT, nSamples > >::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_()

Scalar Dumux::FixedLengthSpline_< Scalar, nSamples >::moment_ ( int i) const
inlineprotected

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

◆ monotonic()

int Dumux::SplineCommon_< Scalar, FixedLengthSpline_< Scalar, nSamples > >::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_()

int Dumux::SplineCommon_< Scalar, FixedLengthSpline_< Scalar, nSamples > >::monotonic_ ( int i,
Scalar x0,
Scalar x1 ) const
inlineprotected

◆ numSamples()

int Dumux::FixedLengthSpline_< Scalar, nSamples >::numSamples ( ) const
inline

Returns the number of sampling points.

◆ numSamples_()

int Dumux::SplineCommon_< Scalar, FixedLengthSpline_< Scalar, nSamples > >::numSamples_ ( ) const
inlineprotected

Returns the number of sampling points.

◆ printCSV()

void Dumux::SplineCommon_< Scalar, FixedLengthSpline_< Scalar, nSamples > >::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_()

int Dumux::SplineCommon_< Scalar, FixedLengthSpline_< Scalar, nSamples > >::segmentIdx_ ( Scalar x) const
inlineprotected

◆ setArrayOfPoints() [1/2]

template<class ScalarT, int nSamples>
template<class PointArray>
void Dumux::FixedLengthSpline_< ScalarT, nSamples >::setArrayOfPoints ( int numberSamples,
const PointArray & points )
inlineinherited

Set the sampling points of a natural spline using a C-style array.

This method uses a single array of sampling points, which are seen as an array-like object which provides access to the X and Y coordinates. In this context 'array-like' means that an access to the members is provided via the [] operator. (e.g. C arrays, std::vector, std::array, etc.) The array containing the sampling points must be of size 'numberSamples' at least. Also, the number of sampling points must be larger than 1.

◆ setArrayOfPoints() [2/2]

void Dumux::FixedLengthSpline_< Scalar, nSamples >::setArrayOfPoints ( int numberSamples,
const PointArray & points,
Scalar m0,
Scalar m1 )
inline

Set the sampling points and the boundary slopes of a full spline using a C-style array.

This method uses a single array of sampling points, which are seen as an array-like object which provides access to the X and Y coordinates. In this context 'array-like' means that an access to the members is provided via the [] operator. (e.g. C arrays, std::vector, std::array, etc.) The array containing the sampling points must be of size 'numberSamples' at least. Also, the number of sampling points must be larger than 1.

◆ setContainerOfPoints() [1/2]

template<class ScalarT, int nSamples>
template<class XYContainer>
void Dumux::FixedLengthSpline_< ScalarT, nSamples >::setContainerOfPoints ( const XYContainer & points)
inlineinherited

Set the sampling points of a natural spline using a STL-compatible container of array-like objects.

This method uses a single STL-compatible container of sampling points, which are assumed to be array-like objects storing the X and Y coordinates. "STL-compatible" means that the container provides access to iterators using the begin(), end() methods and also provides a size() method. Also, the number of entries in the X and the Y containers must be equal and larger than 1.

◆ setContainerOfPoints() [2/2]

void Dumux::FixedLengthSpline_< Scalar, nSamples >::setContainerOfPoints ( const XYContainer & points,
Scalar m0,
Scalar m1 )
inline

Set the sampling points and the boundary slopes of a full spline using a STL-compatible container of array-like objects.

This method uses a single STL-compatible container of sampling points, which are assumed to be array-like objects storing the X and Y coordinates. "STL-compatible" means that the container provides access to iterators using the begin(), end() methods and also provides a size() method. Also, the number of entries in the X and the Y containers must be equal and larger than 1.

◆ setContainerOfTuples() [1/2]

template<class ScalarT, int nSamples>
template<class XYContainer>
void Dumux::FixedLengthSpline_< ScalarT, nSamples >::setContainerOfTuples ( const XYContainer & points)
inlineinherited

Set the sampling points of a natural spline using a STL-compatible container of tuple-like objects.

This method uses a single STL-compatible container of sampling points, which are assumed to be tuple-like objects storing the X and Y coordinates. "tuple-like" means that the objects provide access to the x values via std::get<0>(obj) and to the y value via std::get<1>(obj) (e.g. std::tuple or std::pair). "STL-compatible" means that the container provides access to iterators using the begin(), end() methods and also provides a size() method. Also, the number of entries in the X and the Y containers must be equal and larger than 1.

◆ setContainerOfTuples() [2/2]

void Dumux::FixedLengthSpline_< Scalar, nSamples >::setContainerOfTuples ( const XYContainer & points,
Scalar m0,
Scalar m1 )
inline

Set the sampling points and the boundary slopes of a full spline using a STL-compatible container of tuple-like objects.

This method uses a single STL-compatible container of sampling points, which are assumed to be tuple-like objects storing the X and Y coordinates. "tuple-like" means that the objects provide access to the x values via std::get<0>(obj) and to the y value via std::get<1>(obj) (e.g. std::tuple or std::pair). "STL-compatible" means that the container provides access to iterators using the begin(), end() methods and also provides a size() method. Also, the number of entries in the X and the Y containers must be equal and larger than 1.

◆ setXYArrays() [1/2]

template<class ScalarT, int nSamples>
template<class ScalarArrayX, class ScalarArrayY>
void Dumux::FixedLengthSpline_< ScalarT, nSamples >::setXYArrays ( int numberSamples,
const ScalarArrayX & x,
const ScalarArrayY & y )
inlineinherited

Set the sampling points natural spline using C-style arrays.

This method uses separate array-like objects for the values of the X and Y coordinates. In this context 'array-like' means that an access to the members is provided via the [] operator. (e.g. C arrays, std::vector, std::array, etc.) Each array must be of size 'numberSamples' at least. Also, the number of sampling points must be larger than 1.

◆ setXYArrays() [2/2]

void Dumux::FixedLengthSpline_< Scalar, nSamples >::setXYArrays ( int numberSamples,
const ScalarArrayX & x,
const ScalarArrayY & y,
Scalar m0,
Scalar m1 )
inline

Set the sampling points and the boundary slopes of a full spline using C-style arrays.

This method uses separate array-like objects for the values of the X and Y coordinates. In this context 'array-like' means that an access to the members is provided via the [] operator. (e.g. C arrays, std::vector, std::array, etc.) Each array must be of size 'numberSamples' at least. Also, the number of sampling points must be larger than 1.

◆ setXYContainers() [1/2]

template<class ScalarT, int nSamples>
template<class ScalarContainerX, class ScalarContainerY>
void Dumux::FixedLengthSpline_< ScalarT, nSamples >::setXYContainers ( const ScalarContainerX & x,
const ScalarContainerY & y )
inlineinherited

Set the sampling points of a natural spline using STL-compatible containers.

This method uses separate STL-compatible containers for the values of the sampling points' X and Y coordinates. "STL-compatible" means that the container provides access to iterators using the begin(), end() methods and also provides a size() method. Also, the number of entries in the X and the Y containers must be equal and larger than 1.

◆ setXYContainers() [2/2]

void Dumux::FixedLengthSpline_< Scalar, nSamples >::setXYContainers ( const ScalarContainerX & x,
const ScalarContainerY & y,
Scalar m0,
Scalar m1 )
inline

Set the sampling points and the boundary slopes of a full spline using STL-compatible containers.

This method uses separate STL-compatible containers for the values of the sampling points' X and Y coordinates. "STL-compatible" means that the container provides access to iterators using the begin(), end() methods and also provides a size() method. Also, the number of entries in the X and the Y containers must be equal and larger than 1.

◆ x_()

Scalar Dumux::FixedLengthSpline_< Scalar, nSamples >::x_ ( int i) const
inlineprotected

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

◆ xMax()

Scalar Dumux::SplineCommon_< Scalar, FixedLengthSpline_< Scalar, nSamples > >::xMax ( ) const
inline

Return the x value of the rightmost sampling point.

◆ xMin()

Scalar Dumux::SplineCommon_< Scalar, FixedLengthSpline_< Scalar, nSamples > >::xMin ( ) const
inline

Return the x value of the leftmost sampling point.

◆ y_()

Scalar Dumux::FixedLengthSpline_< Scalar, nSamples >::y_ ( int i) const
inlineprotected

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

Member Data Documentation

◆ m_

BlockVector Dumux::FixedLengthSpline_< Scalar, nSamples >::m_
protected

◆ xPos_

Vector Dumux::FixedLengthSpline_< Scalar, nSamples >::xPos_
protected

◆ yPos_

Vector Dumux::FixedLengthSpline_< Scalar, nSamples >::yPos_
protected

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