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;
87 const bool under =
x < values_.first().first();
88 const bool over =
x > values_.last().first();
90 auto errorMessage = [&]()
92 return "value (" +
name(
x) +
") " + (under ?
"under" :
"over") +
"flow";
97 switch (boundsHandling_)
99 case tableBase::boundsHandling::error:
105 case tableBase::boundsHandling::warn:
108 << errorMessage() <<
nl <<
endl;
127 const word& interpolationScheme,
134 interpolationScheme_(interpolationScheme),
135 reader_(reader, false),
151 tableBase::boundsHandlingNames.lookupOrDefault
162 "interpolationScheme",
197 reader_(new TableReaders::Embedded<scalar, Type>()),
198 values_(TableReaders::Embedded<scalar, Type>().
read(units, is))
208 boundsHandling_(tbl.boundsHandling_),
209 interpolationScheme_(tbl.interpolationScheme_),
210 reader_(tbl.reader_, false),
211 values_(tbl.values_),
212 tableSamplesPtr_(tbl.tableSamplesPtr_),
213 interpolatorPtr_(tbl.interpolatorPtr_)
236 const scalar x0 = values_.first().first();
237 const scalar x1 = values_.last().first();
241 switch (boundsHandling_)
251 if (x <= x0 || x >= x1)
260 const scalar
n = floor((
x - x0)/(x1 - x0));
271 interpolator().valueWeights(
x, indices_, weights_);
274 y += weights_[i]*values_[indices_[i]].second();
288 scalar xA(xAarg), xB(xBarg);
293 const scalar x0 = values_.first().first();
294 const scalar x1 = values_.last().first();
298 switch (boundsHandling_)
308 xA =
min(
max(xA, x0), x1);
309 xB =
min(
max(xB, x0), x1);
316 const scalar nA = floor((xA - x0)/(x1 - x0));
317 const scalar nB = floor((xB - x0)/(x1 - x0));
320 interpolator().integrationWeights(x0, x1, indices_, weights_);
323 sumY += (nB - nA)*weights_[i]*values_[indices_[i]].
second();
337 interpolator().integrationWeights(xA, xB, indices_, weights_);
340 sumY += weights_[i]*values_[indices_[i]].second();
356 fld[i] = values_[i].first();
372 fld[i] = values_[i].second();
397 "interpolationScheme",
402 reader_->write(os, units, values_);
#define forAll(list, i)
Loop across all elements in list.
Templated interpolated tabulated data Function1.
virtual Type integral(const scalar xA, const scalar xB) const
Integrate between two scalars.
virtual tmp< scalarField > x() const
Return the reference values.
virtual void write(Ostream &os, const unitSets &units) 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.
Table(const word &name, const tableBase::boundsHandling boundsHandling, const word &interpolationScheme, const autoPtr< TableReader< scalar, Type >> &reader, const List< Tuple2< scalar, Type >> &table)
Construct from components.
virtual ~Table()
Destructor.
static const NamedEnum< boundsHandling, 5 > boundsHandlingNames
Enumeration names for handling out-of-bound values.
boundsHandling
Enumeration for handling out-of-bound values.
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
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.
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
A list of keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
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.
Template function which returns the un-mangled name of a given type. Useful for types which do not ha...
Unit conversion structure. Contains the associated dimensions and the multiplier with which to conver...
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(lagrangian::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(), lagrangian::cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
#define WarningInFunction
Report a warning using Foam::Warning.
const HashTable< dimensionSet > table
Table of dimensions.
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.
String typeName(const std::type_info &info)
Return the un-mangled name given the standard type info.
labelList second(const UList< labelPair > &p)
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
dimensioned< Type > min(const DimensionedField< Type, GeoMesh, PrimitiveField > &df)
word name(const LagrangianState state)
Return a string representation of a Lagrangian state enumeration.
tmp< DimensionedField< TypeR, GeoMesh, Field > > New(const tmp< DimensionedField< TypeR, GeoMesh, Field >> &tdf1, const word &name, const dimensionSet &dimensions)
dimensioned< Type > max(const DimensionedField< Type, GeoMesh, PrimitiveField > &df)
Struct containing two unitSets for use in converting both the argument and the value of a Function1.