35 if (interpolatorPtr_.empty())
38 tableSamplesPtr_.reset(
new scalarField(values_.size()));
42 tableSamples[i] = values_[i].first();
51 return interpolatorPtr_();
61 <<
"Table for entry " << this->
name() <<
" is invalid (empty)" 65 label n = values_.size();
66 scalar prevValue = values_[0].first();
68 for (
label i = 1; i <
n; ++i)
70 const scalar currValue = values_[i].first();
73 if (currValue <= prevValue)
76 <<
"out-of-order value: " << currValue <<
" at index " << i
79 prevValue = currValue;
90 const bool under = x < values_.first().first();
91 const bool over = x > values_.last().first();
93 auto errorMessage = [&]()
95 return "value (" +
name(x) +
") " + (under ?
"under" :
"over") +
"flow";
100 switch (boundsHandling_)
102 case tableBase::boundsHandling::error:
108 case tableBase::boundsHandling::warn:
111 << errorMessage() <<
nl <<
endl;
114 case tableBase::boundsHandling::clamp:
118 case tableBase::boundsHandling::repeat:
120 const scalar t0 = values_.first().first();
121 const scalar t1 = values_.last().first();
122 const scalar dt = t1 - t0;
123 const label n = floor((x - t0)/dt);
140 const word& interpolationScheme,
145 boundsHandling_(boundsHandling),
146 interpolationScheme_(interpolationScheme),
161 dict.
found(
"outOfBounds")
162 ? tableBase::boundsHandlingNames_.read(dict.
lookup(
"outOfBounds"))
163 : tableBase::boundsHandling::clamp
169 "interpolationScheme",
170 linearInterpolationWeights::typeName
184 boundsHandling_(tbl.boundsHandling_),
185 interpolationScheme_(tbl.interpolationScheme_),
186 values_(tbl.values_),
187 tableSamplesPtr_(tbl.tableSamplesPtr_),
188 interpolatorPtr_(tbl.interpolatorPtr_),
189 reader_(tbl.reader_, false)
208 const scalar bx =
bound(x);
212 interpolator().valueWeights(bx, indices_, weights_);
215 y += weights_[i]*values_[indices_[i]].second();
229 const scalar bx1 =
bound(x1), bx2 =
bound(x2);
233 interpolator().integrationWeights(bx1, bx2, indices_, weights_);
236 sumY += weights_[i]*values_[indices_[i]].second();
239 if (boundsHandling_ == tableBase::boundsHandling::repeat)
241 const scalar t0 = values_.first().first();
242 const scalar t1 = values_.last().first();
243 const scalar dt = t1 - t0;
244 const label n = floor((x2 - t0)/dt) - floor((x1 - t0)/dt);
250 interpolator().integrationWeights(t0, t1, indices_, weights_);
254 sumY01 += weights_[i]*values_[indices_[i]].second();
273 fld[i] = values_[i].first();
289 fld[i] = values_[i].second();
303 tableBase::boundsHandlingNames_[tableBase::boundsHandling::clamp],
304 tableBase::boundsHandlingNames_[boundsHandling_]
310 "interpolationScheme",
311 linearInterpolationWeights::typeName,
315 reader_->write(os, values_);
Base class to read table data for tables.
bool found(const word &, bool recursive=false, bool patternMatch=true) const
Search dictionary for given keyword.
#define forAll(list, i)
Loop across all elements in list.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
errorManipArg< error, int > exit(error &err, const int errNo=1)
A list of keyword definitions, which are a keyword followed by any number of values (e...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
A 2-tuple for storing two objects of different types.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
T & ref() const
Return non-const reference or generate a fatal error.
virtual Type value(const scalar x) const
Return Table value as a function of scalar x.
void writeEntryIfDifferent(Ostream &os, const word &entryName, const EntryType &value1, const EntryType &value2)
Helper function to write the keyword and entry only if the.
Ostream & endl(Ostream &os)
Add newline and flush stream.
Table(const word &name, const tableBase::boundsHandling boundsHandling, const word &interpolationScheme, const List< Tuple2< scalar, Type >> &table)
Construct from components.
Abstract base class for interpolating in 1D.
Templated interpolated tabulated data Function1.
virtual void write(Ostream &os) const
Write data to dictionary stream.
gmvFile<< "tracers "<< particles.size()<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().x()<< ' ';}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().y()<< ' ';}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().z()<< ' ';}gmvFile<< nl;forAll(lagrangianScalarNames, i){ const word &name=lagrangianScalarNames[i];IOField< scalar > fld(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
autoPtr< BasicCompressibleMomentumTransportModel > New(const volScalarField &rho, const volVectorField &U, const surfaceScalarField &phi, const typename BasicCompressibleMomentumTransportModel::transportModel &transport)
A class for handling words, derived from string.
virtual ~Table()
Destructor.
virtual Type integral(const scalar x1, const scalar x2) const
Integrate between two scalars.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
volScalarField scalarField(fieldObject, mesh)
boundsHandling
Enumeration for handling out-of-bound values.
virtual tmp< Field< Type > > y() const
Return the dependent values.
word name(const complex &)
Return a string representation of a complex.
volScalarField & bound(volScalarField &, const dimensionedScalar &lowerBound)
Bound the given scalar field if it has gone unbounded.
T lookupOrDefault(const word &, const T &, bool recursive=false, bool patternMatch=true) const
Find and return a T,.
#define WarningInFunction
Report a warning using Foam::Warning.
A class for managing temporary objects.
virtual tmp< scalarField > x() const
Return the reference values.
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.