Go to the documentation of this file.
39 if (!interpolatorPtr_)
42 tableSamplesPtr_.reset(
new scalarField(table_.size()));
43 auto&
samples = *tableSamplesPtr_;
55 return *interpolatorPtr_;
76 bounds::repeatableBounding::CLAMP,
82 dict.getOrDefault<
word>(
"interpolationScheme",
"linear")
85 tableSamplesPtr_(
nullptr),
86 interpolatorPtr_(
nullptr)
95 bounding_(tbl.bounding_),
96 interpolationScheme_(tbl.interpolationScheme_),
98 tableSamplesPtr_(tbl.tableSamplesPtr_.clone()),
99 interpolatorPtr_(tbl.interpolatorPtr_)
118 <<
"Table for entry " << this->name_ <<
" is invalid (empty)"
125 for (
const auto& item : table_)
127 const scalar& currValue = item.first();
130 if (i && currValue <= prevValue)
133 <<
"out-of-order value: "
134 << currValue <<
" at index " << i <<
nl
137 prevValue = currValue;
150 const scalar minLimit = table_.first().first();
151 const scalar maxLimit = table_.last().first();
160 <<
"value (" <<
x <<
") less than lower "
161 <<
"bound (" << minLimit <<
")" <<
nl
168 <<
"value (" <<
x <<
") less than lower "
169 <<
"bound (" << minLimit <<
")" <<
nl
170 <<
" Continuing with the first entry" <<
endl;
186 const scalar span = maxLimit - minLimit;
187 xDash = fmod(
x - minLimit, span) + minLimit;
208 const scalar minLimit = table_.first().first();
209 const scalar maxLimit = table_.last().first();
218 <<
"value (" <<
x <<
") greater than upper "
219 <<
"bound (" << maxLimit <<
")" <<
nl
226 <<
"value (" <<
x <<
") greater than upper "
227 <<
"bound (" << maxLimit <<
")" <<
nl
228 <<
" Continuing with the last entry" <<
endl;
244 const scalar span = maxLimit - minLimit;
245 xDash = fmod(
x - minLimit, span) + minLimit;
262 for (
auto& item : table_)
267 tableSamplesPtr_.clear();
268 interpolatorPtr_.clear();
277 if (checkMinBounds(
x, xDash))
279 return table_.first().second();
282 if (checkMaxBounds(xDash, xDash))
284 return table_.last().second();
288 interpolator().valueWeights(xDash, currentIndices_, currentWeights_);
290 Type t = currentWeights_[0]*table_[currentIndices_[0]].second();
291 for (label i = 1; i < currentIndices_.size(); i++)
293 t += currentWeights_[i]*table_[currentIndices_[i]].second();
308 interpolator().integrationWeights(x1, x2, currentIndices_, currentWeights_);
310 Type
sum = currentWeights_[0]*table_[currentIndices_[0]].second();
311 for (label i = 1; i < currentIndices_.size(); i++)
313 sum += currentWeights_[i]*table_[currentIndices_[i]].second();
324 auto&
fld = tfld.ref();
328 fld[i] = table_[i].first();
339 auto&
fld = tfld.ref();
343 fld[i] = table_[i].second();
364 "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.