24#ifndef DUMUX_SPLINE_HH
25#define DUMUX_SPLINE_HH
27#include "fixedlengthspline_.hh"
28#include "variablelengthspline_.hh"
29#include "splinecommon_.hh"
53template<
class Scalar,
int numSamples = 2>
54class Spline :
public FixedLengthSpline_<Scalar, numSamples>
71 template <
class ScalarArray>
74 { this->setXYArrays(numSamples, x, y); }
81 template <
class Po
intArray>
83 { this->setArrayOfPoints(numSamples, points); }
93 template <
class ScalarArray>
98 { this->setXYArrays(numSamples, x, y, m0, m1); }
107 template <
class Po
intArray>
111 { this->setArrayOfPoints(numSamples, points, m0, m1); }
135template<
class Scalar>
136class Spline<Scalar, -1> :
public VariableLengthSpline_<Scalar>
154 template <
class ScalarArrayX,
class ScalarArrayY>
156 const ScalarArrayX &x,
157 const ScalarArrayY &y)
158 { this->setXYArrays(nSamples, x, y); }
166 template <
class Po
intArray>
168 const PointArray &points)
169 { this->setArrayOfPoints(nSamples, points); }
177 template <
class ScalarContainer>
179 const ScalarContainer &y)
180 { this->setXYContainers(x, y); }
187 template <
class Po
intContainer>
189 { this->setContainerOfPoints(points); }
200 template <
class ScalarArray>
202 const ScalarArray &x,
203 const ScalarArray &y,
206 { this->setXYArrays(nSamples, x, y, m0, m1); }
216 template <
class Po
intArray>
218 const PointArray &points,
221 { this->setArrayOfPoints(nSamples, points, m0, m1); }
231 template <
class ScalarContainerX,
class ScalarContainerY>
233 const ScalarContainerY &y,
236 { this->setXYContainers(x, y, m0, m1); }
245 template <
class Po
intContainer>
249 { this->setContainerOfPoints(points, m0, m1); }
255template<
class Scalar>
258{
private:
Spline() { }; };
263template<
class Scalar>
274template<
class Scalar>
275class Spline<Scalar, 2> :
public SplineCommon_<Scalar, Spline<Scalar, 2> >
277 friend class SplineCommon_<Scalar,
Spline<Scalar, 2> >;
278 using Vector = Dune::FieldVector<Scalar, 2>;
279 using Matrix = Dune::FieldMatrix<Scalar, 2, 2>;
293 template <
class ScalarArrayX,
class ScalarArrayY>
295 const ScalarArrayY &y,
296 Scalar m0, Scalar m1)
297 { setXYArrays(2, x, y, m0, m1); }
306 template <
class Po
intArray>
310 { this->setArrayOfPoints(2, points, m0, m1); }
323 Scalar y0, Scalar y1,
324 Scalar m0, Scalar m1)
348 void set(Scalar x0, Scalar x1,
349 Scalar y0, Scalar y1,
350 Scalar m0, Scalar m1)
352 Matrix M(numSamples());
354 assignXY_(x0, x1, y0, y1);
355 this->makeFullSystem_(M, d, m0, m1);
371 template <
class ScalarContainer>
373 const ScalarContainer &x,
374 const ScalarContainer &y,
375 Scalar m0, Scalar m1)
377 assert(nSamples == 2);
378 set(x[0], x[1], y[0], y[1], m0, m1);
390 template <
class ScalarContainerX,
class ScalarContainerY>
392 const ScalarContainerY &y,
393 Scalar m0, Scalar m1)
395 assert(x.size() == y.size());
396 assert(x.size() == 2);
398 Matrix M(numSamples());
401 typename ScalarContainerX::const_iterator xIt0 = x.begin();
402 typename ScalarContainerX::const_iterator xIt1 = xIt0;
404 typename ScalarContainerY::const_iterator yIt0 = y.begin();
405 typename ScalarContainerY::const_iterator yIt1 = yIt0;
407 set(*xIt0, *xIt1, *yIt0, *yIt1);
419 template <
class Po
intArray>
421 const PointArray &points,
425 assert(nSamples == 2);
442 template <
class Po
intContainer>
447 assert(points.size() == 2);
451 typename PointContainer::const_iterator it0 = points.begin();
452 typename PointContainer::const_iterator it1 = it0;
470 template <
class TupleContainer>
475 assert(tuples.size() == 2);
477 typename TupleContainer::const_iterator it0 = tuples.begin();
478 typename TupleContainer::const_iterator it1 = it0;
481 set(std::get<0>(*it0),
490 Scalar y0, Scalar y1)
509 Scalar
x_(
int i)
const
515 Scalar
y_(
int i)
const
A 3rd order polynomial spline.
Definition: spline.hh:55
Spline()
Default constructor for a spline.
Definition: spline.hh:62
Spline(const PointArray &points, Scalar m0, Scalar m1)
Convenience constructor for a full spline.
Definition: spline.hh:108
Spline(const PointArray &points)
Convenience constructor for a full spline.
Definition: spline.hh:82
Spline(const ScalarArray &x, const ScalarArray &y)
Convenience constructor for a full spline.
Definition: spline.hh:72
Spline(const ScalarArray &x, const ScalarArray &y, Scalar m0, Scalar m1)
Convenience constructor for a full spline.
Definition: spline.hh:94
Spline(const ScalarContainer &x, const ScalarContainer &y)
Convenience constructor for a natural spline.
Definition: spline.hh:178
Spline()
Default constructor for a spline.
Definition: spline.hh:144
Spline(int nSamples, const ScalarArray &x, const ScalarArray &y, Scalar m0, Scalar m1)
Convenience constructor for a full spline.
Definition: spline.hh:201
Spline(const PointContainer &points, Scalar m0, Scalar m1)
Convenience constructor for a full spline.
Definition: spline.hh:246
Spline(int nSamples, const PointArray &points)
Convenience constructor for a natural spline.
Definition: spline.hh:167
Spline(const PointContainer &points)
Convenience constructor for a natural spline.
Definition: spline.hh:188
Spline(int nSamples, const PointArray &points, Scalar m0, Scalar m1)
Convenience constructor for a full spline.
Definition: spline.hh:217
Spline(int nSamples, const ScalarArrayX &x, const ScalarArrayY &y)
Convenience constructor for a natural spline.
Definition: spline.hh:155
Spline(const ScalarContainerX &x, const ScalarContainerY &y, Scalar m0, Scalar m1)
Convenience constructor for a full spline.
Definition: spline.hh:232
int numSamples() const
Returns the number of sampling points.
Definition: spline.hh:334
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.
Definition: spline.hh:348
Scalar y_(int i) const
Returns the y coordinate of the i-th sampling point.
Definition: spline.hh:515
void setContainerOfPoints(const PointContainer &points, Scalar m0, Scalar m1)
Set the sampling points and the boundary slopes from an STL-like container of points.
Definition: spline.hh:443
Vector m_
Definition: spline.hh:527
Spline(Scalar x0, Scalar x1, Scalar y0, Scalar y1, Scalar m0, Scalar m1)
Convenience constructor for a full spline.
Definition: spline.hh:322
Spline(const PointArray &points, Scalar m0, Scalar m1)
Convenience constructor for a full spline.
Definition: spline.hh:307
void setXYContainers(const ScalarContainerX &x, const ScalarContainerY &y, Scalar m0, Scalar m1)
Set the sampling points and the boundary slopes of the spline.
Definition: spline.hh:391
Vector yPos_
Definition: spline.hh:526
void setContainerOfTuples(const TupleContainer &tuples, Scalar m0, Scalar m1)
Set the sampling points and the boundary slopes from an STL-like container of tuples.
Definition: spline.hh:471
Spline(const ScalarArrayX &x, const ScalarArrayY &y, Scalar m0, Scalar m1)
Convenience constructor for a full spline.
Definition: spline.hh:294
void assignXY_(Scalar x0, Scalar x1, Scalar y0, Scalar y1)
Definition: spline.hh:489
Scalar moment_(int i) const
Returns the moment (i.e. second derivative) of the spline at the i-th sampling point.
Definition: spline.hh:522
Spline()
Definition: spline.hh:282
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.
Definition: spline.hh:372
Scalar x_(int i) const
Returns the x coordinate of the i-th sampling point.
Definition: spline.hh:509
void setArrayOfPoints(int nSamples, const PointArray &points, Scalar m0, Scalar m1)
Set the sampling points and the boundary slopes of the spline.
Definition: spline.hh:420
Vector xPos_
Definition: spline.hh:525