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" 152 case interpolation2DTable::CLAMP:
159 else if (lookupValue >= maxLimit)
161 switch (boundsHandling_)
163 case interpolation2DTable::ERROR:
166 <<
"value (" << lookupValue <<
") greater than upper " 167 <<
"bound (" << maxLimit <<
")" <<
nl 171 case interpolation2DTable::WARN:
174 <<
"value (" << lookupValue <<
") greater than upper " 175 <<
"bound (" << maxLimit <<
")" <<
nl 176 <<
" Continuing with the last entry" 180 case interpolation2DTable::CLAMP:
192 for (
label i = 0; i <
n; ++i)
194 if (lookupValue >=
data[i].first())
207 return data[lo].second();
212 (
data[hi].second() -
data[lo].second())
216 return data[lo].second() + m*(lookupValue -
data[lo].
first());
222 template<
class BinaryOp>
230 const table& t = *
this;
235 limitI = t.
size() - 1;
238 if (bop(valueX, t[limitI].first()))
240 switch (boundsHandling_)
242 case interpolation2DTable::ERROR:
245 <<
"value (" << valueX <<
") out of bounds" 249 case interpolation2DTable::WARN:
252 <<
"value (" << valueX <<
") out of bounds" 256 case interpolation2DTable::CLAMP:
263 <<
"Un-handled enumeration " << boundsHandling_
274 while ((i < nX) && (valueX > t[i].first()))
282 while ((i > 0) && (valueX < t[i].first()))
302 label nX = this->size();
304 const table& t = *
this;
309 <<
"cannot interpolate a zero-sized table - returning zero" <<
endl;
316 return interpolateValue(t.
first().second(), valueY);
328 return interpolateValue(t[x0i].second(), valueY);
332 Type
y0(interpolateValue(t[x0i].second(), valueY));
333 Type
y1(interpolateValue(t[x1i].second(), valueY));
336 scalar x0 = t[x0i].
first();
337 scalar x1 = t[x1i].
first();
338 Type mX = (y1 -
y0)/(x1 - x0);
341 return y0 + mX*(valueX - x0);
353 word enumName(
"warn");
357 case interpolation2DTable::ERROR:
362 case interpolation2DTable::WARN:
367 case interpolation2DTable::CLAMP:
385 if (bound ==
"error")
387 return interpolation2DTable::ERROR;
389 else if (bound ==
"warn")
391 return interpolation2DTable::WARN;
393 else if (bound ==
"clamp")
395 return interpolation2DTable::CLAMP;
400 <<
"bad outOfBounds specifier " << bound <<
" using 'warn'" <<
endl;
402 return interpolation2DTable::WARN;
415 boundsHandling_ =
bound;
424 const table& t = *
this;
426 scalar prevValue = t[0].
first();
430 const scalar currValue = t[i].
first();
433 if (currValue <= prevValue)
436 <<
"out-of-order value: " 437 << currValue <<
" at index " << i <<
nl 440 prevValue = currValue;
449 << fileName_ << token::END_STATEMENT <<
nl;
451 << boundsHandlingToWord(boundsHandling_) << token::END_STATEMENT <<
nl;
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 data, solver performance and other reduced data.
Ostream & writeKeyword(const keyType &)
Write the keyword followed by an appropriate indentation.
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 occurences 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.