24#ifndef DUMUX_VARIABLE_LENGTH_SPLINE_HH
25#define DUMUX_VARIABLE_LENGTH_SPLINE_HH
27#include <dune/common/fvector.hh>
28#include <dune/common/fmatrix.hh>
29#include <dune/istl/bvector.hh>
30#include <dune/istl/btdmatrix.hh>
41template<
class ScalarT>
44 VariableLengthSpline_<ScalarT> >
48 using Scalar = ScalarT;
49 using Vector = Dune::BlockVector<Dune::FieldVector<Scalar, 1> >;
50 using BTDMatrix = Dune::BTDMatrix<Dune::FieldMatrix<Scalar, 1, 1> >;
57 {
return xPos_.size(); }
79 template <
class ScalarArrayX,
class ScalarArrayY>
81 const ScalarArrayX &x,
82 const ScalarArrayY &y,
88 for (
int i = 0; i < nSamples; ++i) {
106 template <
class ScalarContainerX,
class ScalarContainerY>
108 const ScalarContainerY &y,
109 Scalar m0, Scalar m1)
111 assert(x.size() == y.size());
112 assert(x.size() > 1);
115 std::copy(x.begin(), x.end(),
xPos_.begin());
116 std::copy(y.begin(), y.end(),
yPos_.begin());
132 template <
class Po
intArray>
134 const PointArray &points,
140 assert(nSamples > 1);
143 for (
int i = 0; i < nSamples; ++i) {
144 xPos_[i] = points[i][0];
145 yPos_[i] = points[i][1];
162 template <
class XYContainer>
169 assert(points.size() > 1);
172 typename XYContainer::const_iterator it = points.begin();
173 typename XYContainer::const_iterator endIt = points.end();
174 for (
int i = 0; it != endIt; ++i, ++it) {
198 template <
class XYContainer>
205 typename XYContainer::const_iterator it = points.begin();
206 typename XYContainer::const_iterator endIt = points.end();
207 for (
int i = 0; it != endIt; ++i, ++it) {
208 xPos_[i] = std::get<0>(*it);
209 yPos_[i] = std::get<1>(*it);
233 template <
class ScalarArrayX,
class ScalarArrayY>
235 const ScalarArrayX &x,
236 const ScalarArrayY &y)
238 assert(nSamples > 1);
241 for (
int i = 0; i < nSamples; ++i) {
260 template <
class ScalarContainerX,
class ScalarContainerY>
262 const ScalarContainerY &y)
264 assert(x.size() == y.size());
265 assert(x.size() > 1);
268 std::copy(x.begin(), x.end(),
xPos_.begin());
269 std::copy(y.begin(), y.end(),
yPos_.begin());
285 template <
class Po
intArray>
287 const PointArray &points)
291 assert(nSamples > 1);
294 for (
int i = 0; i < nSamples; ++i) {
295 xPos_[i] = points[i][0];
296 yPos_[i] = points[i][1];
312 template <
class XYContainer>
317 assert(points.size() > 1);
320 typename XYContainer::const_iterator it = points.begin();
321 typename XYContainer::const_iterator endIt = points.end();
322 for (
int i = 0; it != endIt; ++ i, ++it) {
345 template <
class XYContainer>
350 typename XYContainer::const_iterator it = points.begin();
351 typename XYContainer::const_iterator endIt = points.end();
352 for (
int i = 0; it != endIt; ++i, ++it) {
353 xPos_[i] = std::get<0>(*it);
354 yPos_[i] = std::get<1>(*it);
367 xPos_.resize(nSamples);
368 yPos_.resize(nSamples);
409 Scalar
x_(
int i)
const
415 Scalar
y_(
int i)
const
The common code for all 3rd order polynomial splines.
The common code for all 3rd order polynomial splines.
Definition: splinecommon_.hh:44
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.
Definition: splinecommon_.hh:427
void makeNaturalSystem_(Matrix &M, Vector &d)
Make the linear system of equations Mx = d which results in the moments of the natural spline....
Definition: splinecommon_.hh:452
The common code for all 3rd order polynomial splines with where the number of sampling points only kn...
Definition: variablelengthspline_.hh:45
Scalar y_(int i) const
Returns the y coordinate of the i-th sampling point.
Definition: variablelengthspline_.hh:415
void setContainerOfPoints(const XYContainer &points)
Set the sampling points of a natural spline using a STL-compatible container of array-like objects.
Definition: variablelengthspline_.hh:313
int numSamples() const
Returns the number of sampling points.
Definition: variablelengthspline_.hh:56
void setArrayOfPoints(int nSamples, const PointArray &points, Scalar m0, Scalar m1)
Set the sampling points and the boundary slopes of a full spline using a C-style array.
Definition: variablelengthspline_.hh:133
Scalar x_(int i) const
Returns the x coordinate of the i-th sampling point.
Definition: variablelengthspline_.hh:409
Vector yPos_
Definition: variablelengthspline_.hh:426
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 ...
Definition: variablelengthspline_.hh:199
void makeFullSpline_(Scalar m0, Scalar m1)
Create a natural spline from the already set sampling points.
Definition: variablelengthspline_.hh:377
void makeNaturalSpline_()
Create a natural spline from the already set sampling points.
Definition: variablelengthspline_.hh:394
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 ...
Definition: variablelengthspline_.hh:163
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.
Definition: variablelengthspline_.hh:107
void setXYContainers(const ScalarContainerX &x, const ScalarContainerY &y)
Set the sampling points of a natural spline using STL-compatible containers.
Definition: variablelengthspline_.hh:261
void setContainerOfTuples(const XYContainer &points)
Set the sampling points of a natural spline using a STL-compatible container of tuple-like objects.
Definition: variablelengthspline_.hh:346
void setXYArrays(int nSamples, 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.
Definition: variablelengthspline_.hh:80
void setNumSamples_(int nSamples)
Resizes the internal vectors to store the sample points.
Definition: variablelengthspline_.hh:365
Vector xPos_
Definition: variablelengthspline_.hh:425
void setXYArrays(int nSamples, const ScalarArrayX &x, const ScalarArrayY &y)
Set the sampling points natural spline using C-style arrays.
Definition: variablelengthspline_.hh:234
void setArrayOfPoints(int nSamples, const PointArray &points)
Set the sampling points of a natural spline using a C-style array.
Definition: variablelengthspline_.hh:286
Vector m_
Definition: variablelengthspline_.hh:427
Scalar moment_(int i) const
Returns the moment (i.e. second derivative) of the spline at the i-th sampling point.
Definition: variablelengthspline_.hh:422