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 << fileName_ << token::END_STATEMENT <<
nl;
234 << boundsHandlingToWord(boundsHandling_) << token::END_STATEMENT <<
nl;
255 scalar lookupValue = value;
257 if (lookupValue < minLimit)
259 switch (boundsHandling_)
261 case interpolationTable::ERROR:
264 <<
"value (" << lookupValue <<
") underflow" <<
nl 268 case interpolationTable::WARN:
271 <<
"value (" << lookupValue <<
") underflow" <<
nl 272 <<
" Zero rate of change." 276 case interpolationTable::CLAMP:
281 case interpolationTable::REPEAT:
284 scalar span = maxLimit-minLimit;
285 lookupValue = fmod(lookupValue-minLimit, span) + minLimit;
290 else if (lookupValue >= maxLimit)
292 switch (boundsHandling_)
294 case interpolationTable::ERROR:
297 <<
"value (" << lookupValue <<
") overflow" <<
nl 301 case interpolationTable::WARN:
304 <<
"value (" << lookupValue <<
") overflow" <<
nl 305 <<
" 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)
401 switch (boundsHandling_)
403 case interpolationTable::ERROR:
406 <<
"index (" << ii <<
") underflow" <<
nl 410 case interpolationTable::WARN:
413 <<
"index (" << ii <<
") underflow" <<
nl 414 <<
" Continuing with the first entry" 418 case interpolationTable::CLAMP:
423 case interpolationTable::REPEAT:
435 switch (boundsHandling_)
437 case interpolationTable::ERROR:
440 <<
"index (" << ii <<
") overflow" <<
nl 444 case interpolationTable::WARN:
447 <<
"index (" << ii <<
") overflow" <<
nl 448 <<
" Continuing with the last entry" 452 case interpolationTable::CLAMP:
457 case interpolationTable::REPEAT:
484 scalar lookupValue = value;
486 if (lookupValue < minLimit)
488 switch (boundsHandling_)
490 case interpolationTable::ERROR:
493 <<
"value (" << lookupValue <<
") underflow" <<
nl 497 case interpolationTable::WARN:
500 <<
"value (" << lookupValue <<
") underflow" <<
nl 501 <<
" Continuing with the first entry" 505 case interpolationTable::CLAMP:
510 case interpolationTable::REPEAT:
513 scalar span = maxLimit-minLimit;
514 lookupValue = fmod(lookupValue-minLimit, span) + minLimit;
519 else if (lookupValue >= maxLimit)
521 switch (boundsHandling_)
523 case interpolationTable::ERROR:
526 <<
"value (" << lookupValue <<
") overflow" <<
nl 530 case interpolationTable::WARN:
533 <<
"value (" << lookupValue <<
") overflow" <<
nl 534 <<
" Continuing with the last entry" 538 case interpolationTable::CLAMP:
543 case interpolationTable::REPEAT:
546 scalar span = maxLimit-minLimit;
547 lookupValue = fmod(lookupValue-minLimit, span) + minLimit;
557 for (
label i = 0; i <
n; ++i)
591 *(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...
Ostream & writeKeyword(const keyType &)
Write the keyword followed by an appropriate indentation.
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 occurences of environment variables.
boundsHandling wordToBoundsHandling(const word &bound) const
Return the out-of-bounds handling as an enumeration.