34 fileName fName(fileName_);
38 reader_()(fName, *
this);
43 <<
"table read from " << fName <<
" is empty" <<
nl 59 fileName_(
"fileNameIsUndefined"),
73 boundsHandling_(bounds),
95 boundsHandling_(wordToBoundsHandling(dict.
lookup(
"outOfBounds"))),
96 fileName_(dict.
lookup(
"file")),
110 boundsHandling_(interpTable.boundsHandling_),
111 fileName_(interpTable.fileName_),
112 reader_(interpTable.reader_)
123 const scalar lookupValue
129 scalar maxLimit =
data.
last().first();
131 if (lookupValue < minLimit)
133 switch (boundsHandling_)
135 case interpolation2DTable::ERROR:
138 <<
"value (" << lookupValue <<
") less than lower " 139 <<
"bound (" << minLimit <<
")" <<
nl 143 case interpolation2DTable::WARN:
146 <<
"value (" << lookupValue <<
") less than lower " 147 <<
"bound (" << minLimit <<
")" <<
nl 148 <<
" Continuing with the first entry" 153 case interpolation2DTable::CLAMP:
160 else if (lookupValue >= maxLimit)
162 switch (boundsHandling_)
164 case interpolation2DTable::ERROR:
167 <<
"value (" << lookupValue <<
") greater than upper " 168 <<
"bound (" << maxLimit <<
")" <<
nl 172 case interpolation2DTable::WARN:
175 <<
"value (" << lookupValue <<
") greater than upper " 176 <<
"bound (" << maxLimit <<
")" <<
nl 177 <<
" Continuing with the last entry" 182 case interpolation2DTable::CLAMP:
194 for (
label i = 0; i <
n; ++i)
196 if (lookupValue >=
data[i].first())
209 return data[lo].second();
214 (
data[hi].second() -
data[lo].second())
218 return data[lo].second() + m*(lookupValue -
data[lo].
first());
224 template<
class BinaryOp>
232 const table& t = *
this;
237 limitI = t.
size() - 1;
240 if (bop(valueX, t[limitI].first()))
242 switch (boundsHandling_)
244 case interpolation2DTable::ERROR:
247 <<
"value (" << valueX <<
") out of bounds" 251 case interpolation2DTable::WARN:
254 <<
"value (" << valueX <<
") out of bounds" 259 case interpolation2DTable::CLAMP:
266 <<
"Un-handled enumeration " << boundsHandling_
277 while ((i < nX) && (valueX > t[i].first()))
285 while ((i > 0) && (valueX < t[i].first()))
305 label nX = this->size();
307 const table& t = *
this;
312 <<
"cannot interpolate a zero-sized table - returning zero" <<
endl;
319 return interpolateValue(t.
first().second(), valueY);
331 return interpolateValue(t[x0i].second(), valueY);
335 Type
y0(interpolateValue(t[x0i].second(), valueY));
336 Type
y1(interpolateValue(t[x1i].second(), valueY));
339 scalar x0 = t[x0i].
first();
340 scalar x1 = t[x1i].
first();
341 Type mX = (y1 -
y0)/(x1 - x0);
344 return y0 + mX*(valueX - x0);
356 word enumName(
"warn");
360 case interpolation2DTable::ERROR:
365 case interpolation2DTable::WARN:
370 case interpolation2DTable::CLAMP:
388 if (bound ==
"error")
390 return interpolation2DTable::ERROR;
392 else if (bound ==
"warn")
394 return interpolation2DTable::WARN;
396 else if (bound ==
"clamp")
398 return interpolation2DTable::CLAMP;
403 <<
"bad outOfBounds specifier " << bound <<
" using 'warn'" <<
endl;
405 return interpolation2DTable::WARN;
418 boundsHandling_ =
bound;
427 const table& t = *
this;
429 scalar prevValue = t[0].
first();
433 const scalar currValue = t[i].
first();
436 if (currValue <= prevValue)
439 <<
"out-of-order value: " 440 << currValue <<
" at index " << i <<
nl 443 prevValue = currValue;
452 writeEntry(os,
"outOfBounds", boundsHandlingToWord(boundsHandling_));
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)
friend Ostream & operator(Ostream &, const UList< T > &)
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...
void size(const label)
Override size to be inconsistent with allocated storage.
Ostream & endl(Ostream &os)
Add newline and flush stream.
2D table interpolation. The data must be in ascending order in both dimensions x and y...
dimensionedScalar y0(const dimensionedScalar &ds)
Reads an interpolation table from a file - OpenFOAM-format.
T * last()
Return the last entry.
T & first()
Return the first element of the list.
Base class to read table data for the interpolationTable.
word boundsHandlingToWord(const boundsHandling &bound) const
Return the out-of-bounds handling as a word.
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh >> &tdf1, const word &name, const dimensionSet &dimensions)
stressControl lookup("compactNormalStress") >> compactNormalStress
interpolation2DTable()
Construct null.
A class for handling words, derived from string.
errorManip< error > abort(error &err)
dimensionedScalar y1(const dimensionedScalar &ds)
An Ostream is an abstract base class for all output systems (streams, files, token lists...
void reverse(UList< T > &, const label n)
void write(Ostream &os) const
Write.
Database for solution and other reduced data.
void writeEntry(Ostream &os, const HashTable< T, Key, Hash > &ht)
boundsHandling outOfBounds(const boundsHandling &bound)
Set the out-of-bounds handling from enum, return previous setting.
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.
void checkOrder() const
Check that list is monotonically increasing.
boundsHandling wordToBoundsHandling(const word &bound) const
Return the out-of-bounds handling as an enumeration.
boundsHandling
Enumeration for handling out-of-bound values.
T * first()
Return the first entry.