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." 277 case interpolationTable::CLAMP:
282 case interpolationTable::REPEAT:
285 scalar span = maxLimit-minLimit;
286 lookupValue = fmod(lookupValue-minLimit, span) + minLimit;
291 else if (lookupValue >= maxLimit)
293 switch (boundsHandling_)
295 case interpolationTable::ERROR:
298 <<
"value (" << lookupValue <<
") overflow" <<
nl 302 case interpolationTable::WARN:
305 <<
"value (" << lookupValue <<
") overflow" <<
nl 306 <<
" Zero rate of change." 311 case interpolationTable::CLAMP:
316 case interpolationTable::REPEAT:
319 scalar span = maxLimit-minLimit;
320 lookupValue = fmod(lookupValue-minLimit, span) + minLimit;
330 for (
label i = 0; i <
n; ++i)
403 switch (boundsHandling_)
405 case interpolationTable::ERROR:
408 <<
"index (" << ii <<
") underflow" <<
nl 412 case interpolationTable::WARN:
415 <<
"index (" << ii <<
") underflow" <<
nl 416 <<
" Continuing with the first entry" 421 case interpolationTable::CLAMP:
426 case interpolationTable::REPEAT:
438 switch (boundsHandling_)
440 case interpolationTable::ERROR:
443 <<
"index (" << ii <<
") overflow" <<
nl 447 case interpolationTable::WARN:
450 <<
"index (" << ii <<
") overflow" <<
nl 451 <<
" Continuing with the last entry" 456 case interpolationTable::CLAMP:
461 case interpolationTable::REPEAT:
488 scalar lookupValue = value;
490 if (lookupValue < minLimit)
492 switch (boundsHandling_)
494 case interpolationTable::ERROR:
497 <<
"value (" << lookupValue <<
") underflow" <<
nl 501 case interpolationTable::WARN:
504 <<
"value (" << lookupValue <<
") underflow" <<
nl 505 <<
" Continuing with the first entry" 510 case interpolationTable::CLAMP:
515 case interpolationTable::REPEAT:
518 scalar span = maxLimit-minLimit;
519 lookupValue = fmod(lookupValue-minLimit, span) + minLimit;
524 else if (lookupValue >= maxLimit)
526 switch (boundsHandling_)
528 case interpolationTable::ERROR:
531 <<
"value (" << lookupValue <<
") overflow" <<
nl 535 case interpolationTable::WARN:
538 <<
"value (" << lookupValue <<
") overflow" <<
nl 539 <<
" Continuing with the last entry" 544 case interpolationTable::CLAMP:
549 case interpolationTable::REPEAT:
552 scalar span = maxLimit-minLimit;
553 lookupValue = fmod(lookupValue-minLimit, span) + minLimit;
563 for (
label i = 0; i <
n; ++i)
597 *(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 occurrences of environment variables.
boundsHandling wordToBoundsHandling(const word &bound) const
Return the out-of-bounds handling as an enumeration.