60 if (s < -SMALL || s > 1+SMALL)
63 <<
"Value " << t <<
" outside range " <<
samples_[i]
70 return Pair<scalar>(d*0.5*(1-
s), d*0.5*(1+
s));
95 bool indexChanged =
false;
101 && index_ < samples_.size()
103 samples_[index_] <= t
104 && (index_ == samples_.size()-1 || t <= samples_[index_+1])
126 else if (index_ == samples_.size()-1)
131 indices[0] = samples_.
size()-1;
141 indices[1] = index_+1;
143 scalar t0 = samples_[indices[0]];
144 scalar t1 = samples_[indices[1]];
145 scalar deltaT = t1-t0;
147 weights[0] = (t1-t)/deltaT;
148 weights[1] = 1.0-weights[0];
155bool Foam::linearInterpolationWeights::integrationWeights
163 if (t2 < t1 - ROOTVSMALL)
166 <<
"Integration should be in positive direction."
167 <<
" t1:" << t1 <<
" t2:" << t2
176 if (t2 <= t1 + ROOTVSMALL)
180 bool anyChanged = (indices.
size() != 1 || indices[0] != i1);
185 weights[0] = scalar(0);
191 const label i2 =
findLower(samples_, t2);
194 if (i1 == -1 || i2 == samples_.size()-1)
197 <<
"Integrating outside table " << samples_[0] <<
".."
198 << samples_.last() <<
" not implemented."
202 const label nIndices = i2-i1+2;
206 bool anyChanged =
false;
208 if (nIndices != indices.
size())
219 if (indices[i] != index)
233 for (label i = i1+1; i <= i2; i++)
235 const scalar d = samples_[i+1]-samples_[i];
237 weights[i-i1] += 0.5*d;
238 indices[i+1-i1] = i+1;
239 weights[i+1-i1] += 0.5*d;
247 weights[0] += i1Tot1.
first();
248 weights[1] += i1Tot1.
second();
255 indices[i2-i1+1] = i2+1;
256 weights[i2-i1] += -wghts.
first();
257 weights[i2-i1+1] += -wghts.
second();
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.
T & first() noexcept
The first element of the list, position [0].
void setSize(const label n)
Alias for resize()
An ordered pair of two objects of type <T> with first() and second() elements.
const T & second() const noexcept
Return second element, which is also the last element.
void size(const label n)
Older name for setAddressableSize.
Abstract base class for interpolating in 1D.
const scalarField & samples_
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.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
gmvFile<< "tracers "<< particles.size()<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().x()<< " ";}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().y()<< " ";}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().z()<< " ";}gmvFile<< nl;forAll(lagrangianScalarNames, i){ word name=lagrangianScalarNames[i];IOField< scalar > s(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
label findLower(const ListType &input, const T &val, const label start, const ComparePredicate &comp)
errorManipArg< error, int > exit(error &err, const int errNo=1)
#define forAll(list, i)
Loop across all elements in list.
scalarField samples(nIntervals, Zero)