49 boundsHandling_(bounds),
63 reader_()(fileName_, *
this);
72 boundsHandling_(wordToBoundsHandling(dict.
lookup(
"outOfBounds"))),
73 fileName_(dict.
lookup(
"file")),
76 reader_()(fileName_, *
this);
88 boundsHandling_(interpTable.boundsHandling_),
89 fileName_(interpTable.fileName_)
100 const scalar lookupValue
106 scalar maxLimit =
data.
last().first();
108 if (lookupValue < minLimit)
110 switch (boundsHandling_)
112 case interpolation2DTable::ERROR:
115 <<
"value (" << lookupValue <<
") less than lower " 116 <<
"bound (" << minLimit <<
")" <<
nl 120 case interpolation2DTable::WARN:
123 <<
"value (" << lookupValue <<
") less than lower " 124 <<
"bound (" << minLimit <<
")" <<
nl 125 <<
" Continuing with the first entry" 130 case interpolation2DTable::CLAMP:
137 else if (lookupValue >= maxLimit)
139 switch (boundsHandling_)
141 case interpolation2DTable::ERROR:
144 <<
"value (" << lookupValue <<
") greater than upper " 145 <<
"bound (" << maxLimit <<
")" <<
nl 149 case interpolation2DTable::WARN:
152 <<
"value (" << lookupValue <<
") greater than upper " 153 <<
"bound (" << maxLimit <<
")" <<
nl 154 <<
" Continuing with the last entry" 159 case interpolation2DTable::CLAMP:
171 for (
label i = 0; i <
n; ++i)
173 if (lookupValue >=
data[i].first())
186 return data[lo].second();
191 (
data[hi].second() -
data[lo].second())
195 return data[lo].second() + m*(lookupValue -
data[lo].
first());
201 template<
class BinaryOp>
209 const table& t = *
this;
214 limitI = t.
size() - 1;
217 if (bop(valueX, t[limitI].first()))
219 switch (boundsHandling_)
221 case interpolation2DTable::ERROR:
224 <<
"value (" << valueX <<
") out of bounds" 228 case interpolation2DTable::WARN:
231 <<
"value (" << valueX <<
") out of bounds" 236 case interpolation2DTable::CLAMP:
243 <<
"Un-handled enumeration " << boundsHandling_
254 while ((i < nX) && (valueX > t[i].first()))
262 while ((i > 0) && (valueX < t[i].first()))
282 label nX = this->size();
284 const table& t = *
this;
289 <<
"cannot interpolate a zero-sized table - returning zero" <<
endl;
296 return interpolateValue(t.
first().second(), valueY);
308 return interpolateValue(t[x0i].second(), valueY);
312 Type
y0(interpolateValue(t[x0i].second(), valueY));
313 Type
y1(interpolateValue(t[x1i].second(), valueY));
316 scalar x0 = t[x0i].
first();
317 scalar x1 = t[x1i].
first();
318 Type mX = (y1 -
y0)/(x1 - x0);
321 return y0 + mX*(valueX - x0);
333 word enumName(
"warn");
337 case interpolation2DTable::ERROR:
342 case interpolation2DTable::WARN:
347 case interpolation2DTable::CLAMP:
365 if (bound ==
"error")
367 return interpolation2DTable::ERROR;
369 else if (bound ==
"warn")
371 return interpolation2DTable::WARN;
373 else if (bound ==
"clamp")
375 return interpolation2DTable::CLAMP;
380 <<
"bad outOfBounds specifier " << bound <<
" using 'warn'" <<
endl;
382 return interpolation2DTable::WARN;
395 boundsHandling_ =
bound;
404 const table& t = *
this;
406 scalar prevValue = t[0].
first();
410 const scalar currValue = t[i].
first();
413 if (currValue <= prevValue)
416 <<
"out-of-order value: " 417 << currValue <<
" at index " << i <<
nl 420 prevValue = currValue;
429 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)
T * last()
Return the last entry.
T & first()
Return the first element of the list.
word boundsHandlingToWord(const boundsHandling &bound) const
Return the out-of-bounds handling as a word.
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.
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.