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,
147 interpolationScheme_(interpolationScheme),
149 reader_(reader, false)
171 "interpolationScheme",
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_);
#define forAll(list, i)
Loop across all elements in list.
Templated interpolated tabulated data Function1.
virtual tmp< scalarField > x() const
Return the reference values.
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.
virtual void write(Ostream &os) const
Write data to dictionary stream.
virtual tmp< Field< Type > > y() const
Return the dependent values.
virtual Type value(const scalar x) const
Return Table value as a function of scalar x.
virtual ~Table()
Destructor.
boundsHandling
Enumeration for handling out-of-bound values.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Base class to read table data for tables.
A 2-tuple for storing two objects of different types.
T & first()
Return the first element of the list.
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
A list of keyword definitions, which are a keyword followed by any number of values (e....
Abstract base class for interpolating in 1D.
A class for managing temporary objects.
T & ref() const
Return non-const reference or generate a fatal error.
A class for handling words, derived from string.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
volScalarField scalarField(fieldObject, mesh)
gmvFile<< "tracers "<< particles.size()<< nl;{ pointField positions(particles.size());label particlei=0;forAllConstIter(Cloud< passiveParticle >, particles, iter) { positions[particlei++]=iter().position(mesh);} for(i=0;i< pTraits< point >::nComponents;i++) { forAll(positions, particlei) { gmvFile<< component(positions[particlei], i)<< ' ';} gmvFile<< nl;}}forAll(lagrangianScalarNames, i){ const word &name=lagrangianScalarNames[i];IOField< scalar > fld(IOobject(name, runTime.name(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
#define WarningInFunction
Report a warning using Foam::Warning.
autoPtr< CompressibleMomentumTransportModel > New(const volScalarField &rho, const volVectorField &U, const surfaceScalarField &phi, const viscosity &viscosity)
errorManipArg< error, int > exit(error &err, const int errNo=1)
bool read(const char *, int32_t &)
void writeEntryIfDifferent(Ostream &os, const word &entryName, const EntryType &value1, const EntryType &value2)
Helper function to write the keyword and entry only if the.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Ostream & endl(Ostream &os)
Add newline and flush stream.
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh >> &tdf1, const word &name, const dimensionSet &dimensions)
bool bound(volScalarField &, const dimensionedScalar &min)
Bound the given scalar field where it is below the specified min value.
List< Type > repeat(const UList< Type > &a, const UList< Type > &b)
word name(const complex &)
Return a string representation of a complex.