53 const bool checkEqualDistance
61 const scalar interval = samples_[1]-samples[0];
62 for (label i = 2; i < samples_.size(); i++)
64 scalar d = samples_[i]-samples[i-1];
66 if (mag(d-interval) > SMALL)
69 <<
"Spline interpolation only valid for constant intervals."
71 <<
"Interval 0-1 : " << interval << nl
72 <<
"Interval " << i-1 <<
'-' << i <<
" : "
89 bool indexChanged =
false;
92 if (samples_.size() <= 2)
94 return linearInterpolationWeights(samples_).valueWeights
106 && index_ < samples_.size()
108 samples_[index_] <= t
109 && (index_ == samples_.size()-1 || t <= samples_[index_+1])
133 else if (index_ == samples_.size()-1)
138 indices[0] = samples_.size()-1;
149 scalar
mu = (t - samples_[lo])/(samples_[hi] - samples_[lo]);
151 scalar
w0 = 0.5*(
mu*(-1+
mu*(2-
mu)));
152 scalar
w1 = 0.5*(2+
mu*(
mu*(-5 +
mu*(3))));
153 scalar
w2 = 0.5*(
mu*(1 +
mu*(4 +
mu*(-3))));
158 if (hi < samples_.size()-1)
185 weights[1] =
w1 -
w3;
186 weights[2] =
w2 + 2*
w3;
192 if (hi < samples_.size()-1)
201 weights[0] =
w1 + 2*
w0;
202 weights[1] =
w2 -
w0;
213 weights[0] =
w1 + 2*
w0 -
w3;
214 weights[1] =
w2 -
w0 + 2*
w3;
Various functions to operate on Lists.
Macros for easy insertion into run-time selection tables.
#define addToRunTimeSelectionTable(baseType, thisType, argNames)
Add to construction table with typeName as the key.
void setSize(label n)
Alias for resize().
void size(const label n)
Older name for setAddressableSize.
Abstract base class for interpolating in 1D.
interpolationWeights(const interpolationWeights &)=delete
No copy construct.
const scalarField & samples_
virtual bool valueWeights(const scalar t, labelList &indices, scalarField &weights) const
Calculate weights and indices to calculate t from samples.
Catmull-Rom spline interpolation.
splineInterpolationWeights(const scalarField &samples, const bool checkEqualDistance=true)
Construct from components. By default make sure samples are.
virtual bool valueWeights(const scalar t, labelList &indices, scalarField &weights) const
Calculate weights and indices to calculate t from samples.
A class for handling words, derived from Foam::string.
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
List< label > labelList
A List of labels.
label findLower(const ListType &input, const T &val, const label start, const ComparePredicate &comp)
Binary search to find the index of the last element in a sorted list that is less than value.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
scalarField samples(nIntervals, Zero)