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),
148 reader_(reader, false),
172 "interpolationScheme",
207 reader_(new TableReaders::Embedded<Type>()),
218 boundsHandling_(tbl.boundsHandling_),
219 interpolationScheme_(tbl.interpolationScheme_),
220 reader_(tbl.reader_, false),
221 values_(tbl.values_),
222 tableSamplesPtr_(tbl.tableSamplesPtr_),
223 interpolatorPtr_(tbl.interpolatorPtr_)
246 interpolator().valueWeights(bx, indices_, weights_);
249 y += weights_[i]*values_[indices_[i]].second();
263 const scalar bx1 =
bound(x1);
264 const scalar bx2 =
bound(x2);
268 interpolator().integrationWeights(bx1, bx2, indices_, weights_);
271 sumY += weights_[i]*values_[indices_[i]].second();
276 const scalar t0 = values_.first().first();
277 const scalar t1 = values_.last().first();
278 const label n = floor(((x2 - x1) - (bx2 - bx1))/(t1 - t0) + 0.5);
284 interpolator().integrationWeights(t0, t1, indices_, weights_);
288 sumY01 += weights_[i]*values_[indices_[i]].second();
308 fld[i] = values_[i].first();
324 fld[i] = values_[i].second();
349 "interpolationScheme",
350 linearInterpolationWeights::typeName,
354 reader_->write(os,
units, 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 unitConversions &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.
virtual ~Table()
Destructor.
static const NamedEnum< boundsHandling, 4 > 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,...
Macros for creating standard TableReader-s.
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.
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(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.
word name(const bool)
Return a word representation of a bool.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
const HashTable< unitConversion > & units()
Get the table of unit conversions.
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)