Go to the documentation of this file.
39 if (!interpolatorPtr_)
42 tableSamplesPtr_.reset(
new scalarField(table_.size()));
43 auto&
samples = *tableSamplesPtr_;
55 return *interpolatorPtr_;
75 bounds::repeatableBounding::CLAMP,
81 dict.getOrDefault<
word>(
"interpolationScheme",
"linear")
84 tableSamplesPtr_(
nullptr),
85 interpolatorPtr_(
nullptr)
93 bounding_(tbl.bounding_),
94 interpolationScheme_(tbl.interpolationScheme_),
96 tableSamplesPtr_(nullptr),
97 interpolatorPtr_(nullptr)
116 <<
"Table for entry " << this->
name() <<
" is invalid (empty)"
123 for (
const auto& item : table_)
125 const scalar& currValue = item.first();
128 if (i && currValue <= prevValue)
131 <<
"out-of-order value: "
132 << currValue <<
" at index " << i <<
nl
135 prevValue = currValue;
148 const scalar minLimit = table_.first().first();
149 const scalar maxLimit = table_.last().first();
158 <<
"value (" <<
x <<
") less than lower "
159 <<
"bound (" << minLimit <<
")" <<
nl
166 <<
"value (" <<
x <<
") less than lower "
167 <<
"bound (" << minLimit <<
")" <<
nl
168 <<
" Continuing with the first entry" <<
endl;
184 const scalar span = maxLimit - minLimit;
185 xDash = fmod(
x - minLimit, span) + minLimit;
206 const scalar minLimit = table_.first().first();
207 const scalar maxLimit = table_.last().first();
216 <<
"value (" <<
x <<
") greater than upper "
217 <<
"bound (" << maxLimit <<
")" <<
nl
224 <<
"value (" <<
x <<
") greater than upper "
225 <<
"bound (" << maxLimit <<
")" <<
nl
226 <<
" Continuing with the last entry" <<
endl;
242 const scalar span = maxLimit - minLimit;
243 xDash = fmod(
x - minLimit, span) + minLimit;
260 for (
auto& item : table_)
265 tableSamplesPtr_.clear();
266 interpolatorPtr_.clear();
275 if (checkMinBounds(
x, xDash))
277 return table_.first().second();
280 if (checkMaxBounds(xDash, xDash))
282 return table_.last().second();
286 interpolator().valueWeights(xDash, currentIndices_, currentWeights_);
288 Type t = currentWeights_[0]*table_[currentIndices_[0]].second();
289 for (label i = 1; i < currentIndices_.size(); i++)
291 t += currentWeights_[i]*table_[currentIndices_[i]].second();
306 interpolator().integrationWeights(x1, x2, currentIndices_, currentWeights_);
308 Type
sum = currentWeights_[0]*table_[currentIndices_[0]].second();
309 for (label i = 1; i < currentIndices_.size(); i++)
311 sum += currentWeights_[i]*table_[currentIndices_[i]].second();
322 auto&
fld = tfld.ref();
326 fld[i] = table_[i].first();
337 auto&
fld = tfld.ref();
341 fld[i] = table_[i].second();
362 "interpolationScheme",
Ostream & writeEntryIfDifferent(const word &key, const T &value1, const T &value2)
Write a keyword/value entry only when the two values differ.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
bool checkMaxBounds(const scalar x, scalar &xDash) const
Check maximum table bounds.
A class for handling words, derived from Foam::string.
const interpolationWeights & interpolator() const
Return (demand driven) interpolator.
A class for managing temporary objects.
static constexpr const zero Zero
Global zero (0)
virtual scalar userTimeToTime(const scalar theta) const
Convert the user-time (e.g. CA deg) to real-time (s).
Ostream & endl(Ostream &os)
Add newline and flush stream.
Treat as a repeating list.
virtual Type integrate(const scalar x1, const scalar x2) const
Integrate between two (scalar) values.
Top level data entry class for use in dictionaries. Provides a mechanism to specify a variable as a c...
virtual Type value(const scalar x) const
Return Table value.
virtual void convertTimeBase(const Time &t)
Convert time.
#define forAll(list, i)
Loop across all elements in list.
word name(const complex &c)
Return string representation of complex.
virtual tmp< scalarField > x() const
Return the reference values.
void check() const
Check the table for size and consistency.
virtual void writeData(Ostream &os) const
Write in dictionary format.
scalarField samples(nIntervals, Zero)
gmvFile<< "tracers "<< particles.size()<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().x()<< ' ';}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().y()<< ' ';}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().z()<< ' ';}gmvFile<< nl;for(const word &name :lagrangianScalarNames){ IOField< scalar > fld(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
Clamp value to the start/end value.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Abstract base class for interpolating in 1D.
virtual ~TableBase()
Destructor.
Ostream & indent(Ostream &os)
Indent stream.
Issue warning and clamp value (this is a good default)
errorManipArg< error, int > exit(error &err, const int errNo=1)
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh >> &tdf1, const word &name, const dimensionSet &dimensions)
Global function forwards to reuseTmpDimensionedField::New.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
virtual void writeData(Ostream &os) const
Write all table data in dictionary format.
static tmp< T > New(Args &&... args)
Construct tmp of T with forwarding arguments.
dimensioned< Type > sum(const DimensionedField< Type, GeoMesh > &df)
virtual void writeEntries(Ostream &os) const
Write keywords only in dictionary format.
Ostream & writeEntry(const keyType &key, const T &value)
Write a keyword/value entry.
TableBase(const word &name, const dictionary &dict)
Construct from dictionary - note table is not populated.
const Foam::Enum< repeatableBounding > repeatableBoundingNames
Strings corresponding to the repeatableBounding.
Base class for table with bounds handling, interpolation and integration.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
virtual tmp< Field< Type > > y() const
Return the dependent values.
bool checkMinBounds(const scalar x, scalar &xDash) const
Check minimum table bounds.
#define WarningInFunction
Report a warning using Foam::Warning.