Go to the documentation of this file.
38 reader_()(fName, *
this);
43 <<
"table read from " << fName <<
" is empty" <<
nl
59 fileName_(
"fileNameIsUndefined"),
73 boundsHandling_(bounds),
95 boundsHandling_(wordToBoundsHandling(
dict.
lookup(
"outOfBounds"))),
123 const scalar lookupValue
128 scalar minLimit =
data.first().first();
129 scalar maxLimit =
data.last().first();
131 if (lookupValue < minLimit)
133 switch (boundsHandling_)
138 <<
"value (" << lookupValue <<
") less than lower "
139 <<
"bound (" << minLimit <<
")" <<
nl
146 <<
"value (" << lookupValue <<
") less than lower "
147 <<
"bound (" << minLimit <<
")" <<
nl
148 <<
" Continuing with the first entry"
154 return data.first().second();
159 else if (lookupValue >= maxLimit)
161 switch (boundsHandling_)
166 <<
"value (" << lookupValue <<
") greater than upper "
167 <<
"bound (" << maxLimit <<
")" <<
nl
174 <<
"value (" << lookupValue <<
") greater than upper "
175 <<
"bound (" << maxLimit <<
")" <<
nl
176 <<
" Continuing with the last entry"
182 return data.last().second();
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())
213 /(
data[hi].first() -
data[lo].first());
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_)
245 <<
"value (" << valueX <<
") out of bounds"
252 <<
"value (" << valueX <<
") out of bounds"
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");
385 if (
bound ==
"error")
389 else if (
bound ==
"warn")
393 else if (
bound ==
"clamp")
400 <<
"bad outOfBounds specifier " <<
bound <<
" using 'warn'" <<
endl;
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;
Reads an interpolation table from a file - OpenFOAM-format.
boundsHandling wordToBoundsHandling(const word &bound) const
Return the out-of-bounds handling as an enumeration.
A class for handling words, derived from string.
autoPtr< BasicCompressibleTurbulenceModel > New(const volScalarField &rho, const volVectorField &U, const surfaceScalarField &phi, const typename BasicCompressibleTurbulenceModel::transportModel &transport, const word &propertiesName)
boundsHandling
Enumeration for handling out-of-bound values.
A class for handling file names.
dimensionedScalar y1(const dimensionedScalar &ds)
autoPtr< tableReader< Type > > reader_
The actual reader.
volScalarField & bound(volScalarField &, const dimensionedScalar &lowerBound)
Bound the given scalar field if it has gone unbounded.
interpolation2DTable()
Construct null.
Type interpolateValue(const List< Tuple2< scalar, Type > > &data, const scalar) const
Return interpolated value in List.
Base class to read table data for the interpolationTable.
Ostream & endl(Ostream &os)
Add newline and flush stream.
fileName fileName_
File name.
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.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
label Xi(const BinaryOp &bop, const scalar valueX, const bool reverse) const
Return an X index from the matrix.
dimensionedScalar y0(const dimensionedScalar &ds)
void checkOrder() const
Check that list is monotonically increasing.
A list of keyword definitions, which are a keyword followed by any number of values (e....
void readTable()
Read the table of data from file.
errorManip< error > abort(error &err)
errorManipArg< error, int > exit(error &err, const int errNo=1)
word boundsHandlingToWord(const boundsHandling &bound) const
Return the out-of-bounds handling as a word.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Traits class for primitives.
string & expand(const bool allowEmpty=false)
Expand initial tildes and all occurences of environment variables.
Ostream & writeKeyword(const keyType &)
Write the keyword followed by an appropriate indentation.
void size(const label)
Override size to be inconsistent with allocated storage.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
A 2-tuple for storing two objects of different types.
boundsHandling boundsHandling_
Enumeration for handling out-of-bound values.
#define WarningInFunction
Report a warning using Foam::Warning.
Database for solution data, solver performance and other reduced data.
void write(Ostream &os) const
Write.
stressControl lookup("compactNormalStress") >> compactNormalStress
void reverse(UList< T > &, const label n)