12#ifndef DUMUX_SPLINE_HH
13#define DUMUX_SPLINE_HH
15#include "fixedlengthspline_.hh"
16#include "variablelengthspline_.hh"
17#include "splinecommon_.hh"
41template<
class Scalar,
int numSamples = 2>
42class Spline :
public FixedLengthSpline_<Scalar, numSamples>
59 template <
class ScalarArray>
62 { this->setXYArrays(numSamples, x, y); }
69 template <
class Po
intArray>
71 { this->setArrayOfPoints(numSamples, points); }
81 template <
class ScalarArray>
86 { this->setXYArrays(numSamples, x, y, m0, m1); }
95 template <
class Po
intArray>
99 { this->setArrayOfPoints(numSamples, points, m0, m1); }
123template<
class Scalar>
124class Spline<Scalar, -1> :
public VariableLengthSpline_<Scalar>
142 template <
class ScalarArrayX,
class ScalarArrayY>
144 const ScalarArrayX &x,
145 const ScalarArrayY &y)
146 { this->setXYArrays(nSamples, x, y); }
154 template <
class Po
intArray>
156 const PointArray &points)
157 { this->setArrayOfPoints(nSamples, points); }
165 template <
class ScalarContainer>
167 const ScalarContainer &y)
168 { this->setXYContainers(x, y); }
175 template <
class Po
intContainer>
177 { this->setContainerOfPoints(points); }
188 template <
class ScalarArray>
190 const ScalarArray &x,
191 const ScalarArray &y,
194 { this->setXYArrays(nSamples, x, y, m0, m1); }
204 template <
class Po
intArray>
206 const PointArray &points,
209 { this->setArrayOfPoints(nSamples, points, m0, m1); }
219 template <
class ScalarContainerX,
class ScalarContainerY>
221 const ScalarContainerY &y,
224 { this->setXYContainers(x, y, m0, m1); }
233 template <
class Po
intContainer>
237 { this->setContainerOfPoints(points, m0, m1); }
243template<
class Scalar>
246{
private:
Spline() { }; };
251template<
class Scalar>
262template<
class Scalar>
263class Spline<Scalar, 2> :
public SplineCommon_<Scalar, Spline<Scalar, 2> >
265 friend class SplineCommon_<Scalar,
Spline<Scalar, 2> >;
266 using Vector = Dune::FieldVector<Scalar, 2>;
267 using Matrix = Dune::FieldMatrix<Scalar, 2, 2>;
281 template <
class ScalarArrayX,
class ScalarArrayY>
283 const ScalarArrayY &y,
284 Scalar m0, Scalar m1)
285 { setXYArrays(2, x, y, m0, m1); }
294 template <
class Po
intArray>
298 { this->setArrayOfPoints(2, points, m0, m1); }
311 Scalar y0, Scalar y1,
312 Scalar m0, Scalar m1)
336 void set(Scalar x0, Scalar x1,
337 Scalar y0, Scalar y1,
338 Scalar m0, Scalar m1)
340 Matrix M(numSamples());
342 assignXY_(x0, x1, y0, y1);
343 this->makeFullSystem_(M, d, m0, m1);
359 template <
class ScalarContainer>
361 const ScalarContainer &x,
362 const ScalarContainer &y,
363 Scalar m0, Scalar m1)
365 assert(nSamples == 2);
366 set(x[0], x[1], y[0], y[1], m0, m1);
378 template <
class ScalarContainerX,
class ScalarContainerY>
380 const ScalarContainerY &y,
381 Scalar m0, Scalar m1)
383 assert(x.size() == y.size());
384 assert(x.size() == 2);
386 Matrix M(numSamples());
389 typename ScalarContainerX::const_iterator xIt0 = x.begin();
390 typename ScalarContainerX::const_iterator xIt1 = xIt0;
392 typename ScalarContainerY::const_iterator yIt0 = y.begin();
393 typename ScalarContainerY::const_iterator yIt1 = yIt0;
395 set(*xIt0, *xIt1, *yIt0, *yIt1);
407 template <
class Po
intArray>
409 const PointArray &points,
413 assert(nSamples == 2);
430 template <
class Po
intContainer>
435 assert(points.size() == 2);
439 typename PointContainer::const_iterator it0 = points.begin();
440 typename PointContainer::const_iterator it1 = it0;
458 template <
class TupleContainer>
463 assert(tuples.size() == 2);
465 typename TupleContainer::const_iterator it0 = tuples.begin();
466 typename TupleContainer::const_iterator it1 = it0;
469 set(std::get<0>(*it0),
478 Scalar y0, Scalar y1)
497 Scalar
x_(
int i)
const
503 Scalar
y_(
int i)
const
Spline(const ScalarContainer &x, const ScalarContainer &y)
Convenience constructor for a natural spline.
Definition: spline.hh:166
Spline()
Default constructor for a spline.
Definition: spline.hh:132
Spline(int nSamples, const ScalarArray &x, const ScalarArray &y, Scalar m0, Scalar m1)
Convenience constructor for a full spline.
Definition: spline.hh:189
Spline(const PointContainer &points, Scalar m0, Scalar m1)
Convenience constructor for a full spline.
Definition: spline.hh:234
Spline(int nSamples, const PointArray &points)
Convenience constructor for a natural spline.
Definition: spline.hh:155
Spline(const PointContainer &points)
Convenience constructor for a natural spline.
Definition: spline.hh:176
Spline(int nSamples, const PointArray &points, Scalar m0, Scalar m1)
Convenience constructor for a full spline.
Definition: spline.hh:205
Spline(int nSamples, const ScalarArrayX &x, const ScalarArrayY &y)
Convenience constructor for a natural spline.
Definition: spline.hh:143
Spline(const ScalarContainerX &x, const ScalarContainerY &y, Scalar m0, Scalar m1)
Convenience constructor for a full spline.
Definition: spline.hh:220
int numSamples() const
Returns the number of sampling points.
Definition: spline.hh:322
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:336
Scalar y_(int i) const
Returns the y coordinate of the i-th sampling point.
Definition: spline.hh:503
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:431
Vector m_
Definition: spline.hh:515
Spline(Scalar x0, Scalar x1, Scalar y0, Scalar y1, Scalar m0, Scalar m1)
Convenience constructor for a full spline.
Definition: spline.hh:310
Spline(const PointArray &points, Scalar m0, Scalar m1)
Convenience constructor for a full spline.
Definition: spline.hh:295
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:379
Vector yPos_
Definition: spline.hh:514
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:459
Spline(const ScalarArrayX &x, const ScalarArrayY &y, Scalar m0, Scalar m1)
Convenience constructor for a full spline.
Definition: spline.hh:282
void assignXY_(Scalar x0, Scalar x1, Scalar y0, Scalar y1)
Definition: spline.hh:477
Scalar moment_(int i) const
Returns the moment (i.e. second derivative) of the spline at the i-th sampling point.
Definition: spline.hh:510
Spline()
Definition: spline.hh:270
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:360
Scalar x_(int i) const
Returns the x coordinate of the i-th sampling point.
Definition: spline.hh:497
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:408
Vector xPos_
Definition: spline.hh:513
A 3rd order polynomial spline.
Definition: spline.hh:43
Spline()
Default constructor for a spline.
Definition: spline.hh:50
Spline(const PointArray &points, Scalar m0, Scalar m1)
Convenience constructor for a full spline.
Definition: spline.hh:96
Spline(const PointArray &points)
Convenience constructor for a full spline.
Definition: spline.hh:70
Spline(const ScalarArray &x, const ScalarArray &y)
Convenience constructor for a full spline.
Definition: spline.hh:60
Spline(const ScalarArray &x, const ScalarArray &y, Scalar m0, Scalar m1)
Convenience constructor for a full spline.
Definition: spline.hh:82