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:
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,
146 boundsHandling_(boundsHandling),
147 interpolationScheme_(interpolationScheme),
149 reader_(reader,
false)
163 dict.
found(
"outOfBounds")
164 ? tableBase::boundsHandlingNames_.read(dict.
lookup(
"outOfBounds"))
165 : tableBase::boundsHandling::clamp
171 "interpolationScheme",
172 linearInterpolationWeights::typeName
186 boundsHandling_(tbl.boundsHandling_),
187 interpolationScheme_(tbl.interpolationScheme_),
188 values_(tbl.values_),
189 tableSamplesPtr_(tbl.tableSamplesPtr_),
190 interpolatorPtr_(tbl.interpolatorPtr_),
191 reader_(tbl.reader_, false)
210 const scalar bx =
bound(x);
214 interpolator().valueWeights(bx, indices_, weights_);
217 y += weights_[i]*values_[indices_[i]].second();
231 const scalar bx1 =
bound(x1), bx2 =
bound(x2);
235 interpolator().integrationWeights(bx1, bx2, indices_, weights_);
238 sumY += weights_[i]*values_[indices_[i]].second();
243 const scalar t0 = values_.first().first();
244 const scalar t1 = values_.last().first();
245 const scalar dt = t1 - t0;
246 const label n = floor((x2 - t0)/dt) - floor((x1 - t0)/dt);
252 interpolator().integrationWeights(t0, t1, indices_, weights_);
256 sumY01 += weights_[i]*values_[indices_[i]].second();
275 fld[i] = values_[i].first();
291 fld[i] = values_[i].second();
305 tableBase::boundsHandlingNames_[tableBase::boundsHandling::clamp],
306 tableBase::boundsHandlingNames_[boundsHandling_]
312 "interpolationScheme",
313 linearInterpolationWeights::typeName,
317 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.
FvWallInfoData< WallInfo, label > label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
autoPtr< CompressibleMomentumTransportModel > New(const volScalarField &rho, const volVectorField &U, const surfaceScalarField &phi, const viscosity &viscosity)
List< Type > repeat(const UList< Type > &a, const UList< Type > &b)
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.
T & first()
Return the first element of the list.
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))
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.
Table(const word &name, const tableBase::boundsHandling boundsHandling, const word &interpolationScheme, const autoPtr< TableReader< Type >> &reader, const List< Tuple2< scalar, Type >> &table)
Construct from components.
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.
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
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.