36 fileName fName(fileName_);
40 reader_()(fName, *
this);
45 <<
"table read from " << fName <<
" is empty" <<
nl 61 fileName_(
"fileNameIsUndefined"),
120 List<value_type>(tbl),
121 bounding_(tbl.bounding_),
122 fileName_(tbl.fileName_),
123 reader_(tbl.reader_.clone())
132 const List<Tuple2<scalar, Type>>& list,
136 return interpolationTable<Type>::interpolateValue
146 template<
class BinaryOp>
159 limitI = t.
size() - 1;
162 if (bop(valueX, t[limitI].first()))
166 case bounds::normalBounding::ERROR:
169 <<
"value (" << valueX <<
") out of bounds" <<
nl 173 case bounds::normalBounding::WARN:
176 <<
"value (" << valueX <<
") out of bounds" <<
nl;
182 case bounds::normalBounding::CLAMP:
190 <<
"Unhandled bounding type " << int(bounding_)
199 const label nX = t.
size();
201 while ((i < nX) && (valueX > t[i].first()))
209 while ((i > 0) && (valueX < t[i].first()))
232 static_cast<List<value_type>&
>(*this) = rhs;
233 bounding_ = rhs.bounding_;
234 fileName_ = rhs.fileName_;
235 reader_.reset(rhs.reader_.clone());
249 const label nX = t.
size();
254 <<
"Cannot interpolate zero-sized table - returning zero" <<
nl;
261 return interpolateValue(t.
first().second(), valueY);
266 const label lo = Xi(lessOp<scalar>(), valueX,
false);
267 const label hi = Xi(greaterOp<scalar>(), valueX,
true);
271 return interpolateValue(t[lo].second(), valueY);
277 const Type
y0(interpolateValue(t[lo].second(), valueY));
278 const Type
y1(interpolateValue(t[hi].second(), valueY));
280 const scalar& x0 = t[lo].
first();
283 return (
y0 + (
y1 -
y0)*(valueX - x0)/(x1 - x0));
295 for (
const auto& item : list)
297 const scalar& currValue = item.first();
300 if (i && currValue <= prevValue)
303 <<
"out-of-order value: " 304 << currValue <<
" at index " << i <<
nl 307 prevValue = currValue;
316 os.writeEntry(
"file", fileName_);
List< ReturnType > get(const UPtrList< T > &list, const AccessOp &aop)
List of values generated by applying the access operation to each list item.
void size(const label n)
Older name for setAddressableSize.
A class for handling file names.
errorManipArg< error, int > exit(error &err, const int errNo=1)
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
A list of keyword definitions, which are a keyword followed by a number of values (eg...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
A 2-tuple for storing two objects of dissimilar types. The container is similar in purpose to std::pa...
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
constexpr char nl
The newline '\n' character (0x0a)
T & first()
Access first element of the list, position [0].
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh >> &tf1, const word &name, const dimensionSet &dimensions, const bool initCopy=false)
Global function forwards to reuseTmpDimensionedField::New.
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.
repeatableBounding
Enumeration for handling out-of-bound values that are repeatable.
Base class to read table data for the interpolationTable.
void check() const
Check that list is monotonically increasing.
normalBounding
Enumeration for handling out-of-bound values.
List< T > values(const HashTable< T, Key, Hash > &tbl, const bool doSort=false)
List of values from HashTable, optionally sorted.
interpolation2DTable()
Default construct.
void reverse(UList< T > &list, const label n)
Reverse the first n elements of the list.
errorManip< error > abort(error &err)
dimensionedScalar y1(const dimensionedScalar &ds)
void write(Ostream &os) const
Write.
OBJstream os(runTime.globalPath()/outputName)
static void check(const int retVal, const char *what)
const Foam::Enum< normalBounding > normalBoundingNames
Strings corresponding to the normalBounding.
#define WarningInFunction
Report a warning using Foam::Warning.
string & expand(const bool allowEmpty=false)
Inplace expand initial tags, tildes, and all occurrences of environment variables as per stringOps::e...
static constexpr const zero Zero
Global zero (0)