36 fileName fName(fileName_);
41 reader_()(fName, *
this);
46 <<
"table read from " << fName <<
" is empty" <<
nl 62 fileName_(
"fileNameIsUndefined"),
76 boundsHandling_(bounds),
98 boundsHandling_(wordToBoundsHandling(dict.
lookup(
"outOfBounds"))),
99 fileName_(dict.
lookup(
"file")),
113 boundsHandling_(interpTable.boundsHandling_),
114 fileName_(interpTable.fileName_),
115 reader_(interpTable.reader_)
128 word enumName(
"warn");
132 case interpolationTable::ERROR:
137 case interpolationTable::WARN:
142 case interpolationTable::CLAMP:
147 case interpolationTable::REPEAT:
165 if (bound ==
"error")
167 return interpolationTable::ERROR;
169 else if (bound ==
"warn")
171 return interpolationTable::WARN;
173 else if (bound ==
"clamp")
175 return interpolationTable::CLAMP;
177 else if (bound ==
"repeat")
179 return interpolationTable::REPEAT;
184 <<
"bad outOfBounds specifier " << bound <<
" using 'warn'" <<
endl;
186 return interpolationTable::WARN;
199 boundsHandling_ =
bound;
212 const scalar currValue =
216 if (currValue <= prevValue)
219 <<
"out-of-order value: " 220 << currValue <<
" at index " << i <<
nl 223 prevValue = currValue;
232 writeEntry(os,
"outOfBounds", boundsHandlingToWord(boundsHandling_));
253 scalar lookupValue = value;
255 if (lookupValue < minLimit)
257 switch (boundsHandling_)
259 case interpolationTable::ERROR:
262 <<
"value (" << lookupValue <<
") underflow" <<
nl 266 case interpolationTable::WARN:
269 <<
"value (" << lookupValue <<
") underflow" <<
nl 270 <<
" Zero rate of change." 275 case interpolationTable::CLAMP:
280 case interpolationTable::REPEAT:
283 scalar span = maxLimit-minLimit;
284 lookupValue = fmod(lookupValue-minLimit, span) + minLimit;
289 else if (lookupValue >= maxLimit)
291 switch (boundsHandling_)
293 case interpolationTable::ERROR:
296 <<
"value (" << lookupValue <<
") overflow" <<
nl 300 case interpolationTable::WARN:
303 <<
"value (" << lookupValue <<
") overflow" <<
nl 304 <<
" Zero rate of change." 309 case interpolationTable::CLAMP:
314 case interpolationTable::REPEAT:
317 scalar span = maxLimit-minLimit;
318 lookupValue = fmod(lookupValue-minLimit, span) + minLimit;
328 for (
label i = 0; i <
n; ++i)
389 void Foam::interpolationTable<Type>::operator=
395 boundsHandling_ = interpTable.boundsHandling_;
396 fileName_ = interpTable.fileName_;
397 reader_ = interpTable.reader_;
414 switch (boundsHandling_)
416 case interpolationTable::ERROR:
419 <<
"index (" << ii <<
") underflow" <<
nl 423 case interpolationTable::WARN:
426 <<
"index (" << ii <<
") underflow" <<
nl 427 <<
" Continuing with the first entry" 432 case interpolationTable::CLAMP:
437 case interpolationTable::REPEAT:
449 switch (boundsHandling_)
451 case interpolationTable::ERROR:
454 <<
"index (" << ii <<
") overflow" <<
nl 458 case interpolationTable::WARN:
461 <<
"index (" << ii <<
") overflow" <<
nl 462 <<
" Continuing with the last entry" 467 case interpolationTable::CLAMP:
472 case interpolationTable::REPEAT:
499 scalar lookupValue = value;
501 if (lookupValue < minLimit)
503 switch (boundsHandling_)
505 case interpolationTable::ERROR:
508 <<
"value (" << lookupValue <<
") underflow" <<
nl 512 case interpolationTable::WARN:
515 <<
"value (" << lookupValue <<
") underflow" <<
nl 516 <<
" Continuing with the first entry" 521 case interpolationTable::CLAMP:
526 case interpolationTable::REPEAT:
529 scalar span = maxLimit-minLimit;
530 lookupValue = fmod(lookupValue-minLimit, span) + minLimit;
535 else if (lookupValue >= maxLimit)
537 switch (boundsHandling_)
539 case interpolationTable::ERROR:
542 <<
"value (" << lookupValue <<
") overflow" <<
nl 546 case interpolationTable::WARN:
549 <<
"value (" << lookupValue <<
") overflow" <<
nl 550 <<
" Continuing with the last entry" 555 case interpolationTable::CLAMP:
560 case interpolationTable::REPEAT:
563 scalar span = maxLimit-minLimit;
564 lookupValue = fmod(lookupValue-minLimit, span) + minLimit;
574 for (
label i = 0; i <
n; ++i)
608 *(lookupValue / minLimit)
word boundsHandlingToWord(const boundsHandling &bound) const
Return the out-of-bounds handling as a word.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
A class for handling file names.
errorManipArg< error, int > exit(error &err, const int errNo=1)
const Tuple2< scalar, Type > & operator[](const label) const
Return an element of constant Tuple2<scalar, Type>
interpolationTable()
Construct null.
A list of keyword definitions, which are a keyword followed by any number of values (e...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
A 2-tuple for storing two objects of different types.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Type rateOfChange(const scalar) const
Return the rate of change at the interpolation location.
Ostream & endl(Ostream &os)
Add newline and flush stream.
Reads an interpolation table from a file - OpenFOAM-format.
Base class to read table data for the interpolationTable.
boundsHandling outOfBounds(const boundsHandling &bound)
Set the out-of-bounds handling from enum, return previous setting.
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh >> &tdf1, const word &name, const dimensionSet &dimensions)
stressControl lookup("compactNormalStress") >> compactNormalStress
A class for handling words, derived from string.
void check() const
Check that list is monotonically increasing.
An interpolation/look-up table of scalar vs <Type> values. The reference scalar values must be monoto...
Type operator()(const scalar) const
Return an interpolated value.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
void writeEntry(Ostream &os, const HashTable< T, Key, Hash > &ht)
void write(Ostream &os) const
Write.
boundsHandling
Enumeration for handling out-of-bound values.
volScalarField & bound(volScalarField &, const dimensionedScalar &lowerBound)
Bound the given scalar field if it has gone unbounded.
#define WarningInFunction
Report a warning using Foam::Warning.
string & expand(const bool allowEmpty=false)
Expand initial tildes and all occurrences of environment variables.
boundsHandling wordToBoundsHandling(const word &bound) const
Return the out-of-bounds handling as an enumeration.