34 fileName fName(fileName_);
38 reader_()(fName, *
this);
44 "Foam::interpolation2DTable<Type>::readTable()" 45 ) <<
"table read from " << fName <<
" is empty" <<
nl 61 fileName_(
"fileNameIsUndefined"),
75 boundsHandling_(bounds),
98 fileName_(dict.
lookup(
"fileName")),
112 boundsHandling_(interpTable.boundsHandling_),
113 fileName_(interpTable.fileName_),
114 reader_(interpTable.reader_)
125 const scalar lookupValue
131 scalar maxLimit =
data.
last().first();
133 if (lookupValue < minLimit)
135 switch (boundsHandling_)
141 "Foam::interpolation2DTable<Type>::interpolateValue" 143 "List<Tuple2<scalar, Type> >&, " 146 ) <<
"value (" << lookupValue <<
") less than lower " 147 <<
"bound (" << minLimit <<
")" <<
nl 155 "Foam::interpolation2DTable<Type>::interpolateValue" 157 "List<Tuple2<scalar, Type> >&, " 160 ) <<
"value (" << lookupValue <<
") less than lower " 161 <<
"bound (" << minLimit <<
")" <<
nl 162 <<
" Continuing with the first entry" 173 else if (lookupValue >= maxLimit)
175 switch (boundsHandling_)
181 "Foam::interpolation2DTable<Type>::interpolateValue" 183 "List<Tuple2<scalar, Type> >&, " 186 ) <<
"value (" << lookupValue <<
") greater than upper " 187 <<
"bound (" << maxLimit <<
")" <<
nl 195 "Foam::interpolation2DTable<Type>::interpolateValue" 197 "List<Tuple2<scalar, Type> >&, " 200 ) <<
"value (" << lookupValue <<
") greater than upper " 201 <<
"bound (" << maxLimit <<
")" <<
nl 202 <<
" Continuing with the last entry" 218 for (
label i = 0; i <
n; ++i)
233 return data[lo].second();
238 (
data[hi].second() -
data[lo].second())
242 return data[lo].second() + m*(lookupValue -
data[lo].
first());
248 template<
class BinaryOp>
256 const table& t = *
this;
261 limitI = t.
size() - 1;
264 if (bop(valueX, t[limitI].
first()))
266 switch (boundsHandling_)
272 "Foam::label Foam::interpolation2DTable<Type>::Xi" 278 ) <<
"value (" << valueX <<
") out of bounds" 286 "Foam::label Foam::interpolation2DTable<Type>::Xi" 291 ) <<
"value (" << valueX <<
") out of bounds" 303 "Foam::label Foam::interpolation2DTable<Type>::Xi" 310 <<
"Un-handled enumeration " << boundsHandling_
321 while ((i < nX) && (valueX > t[i].
first()))
329 while ((i > 0) && (valueX < t[i].
first()))
351 const table& t = *
this;
357 "Type Foam::interpolation2DTable<Type>::operator()" 363 <<
"cannot interpolate a zero-sized table - returning zero" <<
endl;
370 return interpolateValue(t.
first().second(), valueY);
382 return interpolateValue(t[x0i].second(), valueY);
386 Type
y0(interpolateValue(t[x0i].second(), valueY));
387 Type
y1(interpolateValue(t[x1i].second(), valueY));
390 scalar x0 = t[x0i].
first();
391 scalar x1 = t[x1i].
first();
392 Type mX = (y1 -
y0)/(x1 - x0);
395 return y0 + mX*(valueX - x0);
407 word enumName(
"warn");
439 if (bound ==
"error")
443 else if (bound ==
"warn")
447 else if (bound ==
"clamp")
455 "Foam::interpolation2DTable<Type>::wordToBoundsHandling" 459 ) <<
"bad outOfBounds specifier " << bound <<
" using 'warn'" <<
endl;
474 boundsHandling_ =
bound;
483 const table& t = *
this;
485 scalar prevValue = t[0].
first();
489 const scalar currValue = t[i].
first();
492 if (currValue <= prevValue)
496 "Foam::interpolation2DTable<Type>::checkOrder() const" 497 ) <<
"out-of-order value: " 498 << currValue <<
" at index " << i <<
nl 501 prevValue = currValue;
T * last()
Return the last entry.
A 2-tuple for storing two objects of different types.
interpolation2DTable()
Construct null.
T * first()
Return the first entry.
string & expand(const bool allowEmpty=false)
Expand initial tildes and all occurences of environment variables.
dimensionedScalar y1(const dimensionedScalar &ds)
word boundsHandlingToWord(const boundsHandling &bound) const
Return the out-of-bounds handling as a word.
boundsHandling
Enumeration for handling out-of-bound values.
volScalarField & bound(volScalarField &, const dimensionedScalar &lowerBound)
Bound the given scalar field if it has gone unbounded.
A class for handling words, derived from string.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
void size(const label)
Override size to be inconsistent with allocated storage.
errorManipArg< error, int > exit(error &err, const int errNo=1)
Database for solution data, solver performance and other reduced data.
Reads an interpolation table from a file - OpenFOAM-format.
friend Ostream & operator(Ostream &, const UList< T > &)
dimensionedScalar y0(const dimensionedScalar &ds)
A list of keyword definitions, which are a keyword followed by any number of values (e...
label size() const
Return number of elements in list.
T & first()
Return the first element of the list.
autoPtr< BasicCompressibleTurbulenceModel > New(const volScalarField &rho, const volVectorField &U, const surfaceScalarField &phi, const typename BasicCompressibleTurbulenceModel::transportModel &transport, const word &propertiesName)
void checkOrder() const
Check that list is monotonically increasing.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
boundsHandling outOfBounds(const boundsHandling &bound)
Set the out-of-bounds handling from enum, return previous setting.
2D table interpolation. The data must be in ascending order in both dimensions x and y...
Ostream & endl(Ostream &os)
Add newline and flush stream.
stressControl lookup("compactNormalStress") >> compactNormalStress
#define WarningIn(functionName)
Report a warning using Foam::Warning.
Base class to read table data for the interpolationTable.
errorManip< error > abort(error &err)
Ostream & writeKeyword(const keyType &)
Write the keyword followed by an appropriate indentation.
#define FatalErrorIn(functionName)
Report an error message using Foam::FatalError.
Traits class for primitives.
boundsHandling wordToBoundsHandling(const word &bound) const
Return the out-of-bounds handling as an enumeration.
A class for handling file names.
label size() const
Return the number of elements in the UList.
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.