34void Foam::interpolation2DTable<Type>::readTable()
36 fileName fName(fileName_);
40 reader_()(fName, *
this);
45 <<
"table read from " << fName <<
" is empty" <<
nl
60 bounding_(
bounds::normalBounding::WARN),
61 fileName_(
"fileNameIsUndefined"),
74 List<value_type>(values),
85 bounding_(
bounds::normalBounding::WARN),
99 bounds::normalBoundingNames.getOrDefault
103 bounds::normalBounding::WARN,
121 bounding_(tbl.bounding_),
122 fileName_(tbl.fileName_),
123 reader_(tbl.reader_.
clone())
130Type Foam::interpolation2DTable<Type>::interpolateValue
146template<
class BinaryOp>
147Foam::label Foam::interpolation2DTable<Type>::Xi
154 const List<value_type>& t = *
this;
162 if (bop(valueX, t[limitI].first()))
169 <<
"value (" << valueX <<
") out of bounds" <<
nl
176 <<
"value (" << valueX <<
") out of bounds" <<
nl;
182 case bounds::normalBounding::CLAMP:
190 <<
"Unhandled bounding type " << int(bounding_)
191 <<
abort(FatalError);
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_);
317 os.writeEntry(
"outOfBounds", bounds::normalBoundingNames[bounding_]);
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
autoPtr< List< Tuple2< scalar, List< Tuple2< scalar, Type > > > > > clone() const
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
A 2-tuple for storing two objects of dissimilar types. The container is similar in purpose to std::pa...
Tuple2< scalar, List< Tuple2< scalar, scalar > > > & first()
bool get(const label i) const
Return bool value at specified position, always false for out-of-range access.
void size(const label n)
Older name for setAddressableSize.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
A class for handling file names.
2D table interpolation. The data must be in ascending order in both dimensions x and y.
Tuple2< scalar, List< Tuple2< scalar, Type > > > value_type
The element data type.
void check() const
Check that list is monotonically increasing.
interpolation2DTable()
Default construct.
void write(Ostream &os) const
Write.
static Type interpolateValue(const List< Tuple2< scalar, Type > > &list, scalar lookupValue, bounds::repeatableBounding=bounds::repeatableBounding::CLAMP)
Return an interpolated value in List.
Reads an interpolation table from a file - OpenFOAM-format.
Base class to read table data for the interpolationTable.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
OBJstream os(runTime.globalPath()/outputName)
#define WarningInFunction
Report a warning using Foam::Warning.
Namespace for bounding specifications. At the moment, mostly for tables.
repeatableBounding
Enumeration for handling out-of-bound values that are repeatable.
const Foam::Enum< normalBounding > normalBoundingNames
Strings corresponding to the normalBounding.
normalBounding
Enumeration for handling out-of-bound values.
@ WARN
Issue warning and clamp value (this is a good default).
@ ERROR
Exit with a FatalError.
@ CLAMP
Clamp value to the start/end value.
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.
dimensionedScalar y0(const dimensionedScalar &ds)
void reverse(UList< T > &list, const label n)
Reverse the first n elements of the list.
dimensionedScalar y1(const dimensionedScalar &ds)
errorManip< error > abort(error &err)
void rhs(fvMatrix< typename Expr::value_type > &m, const Expr &expression)
static constexpr const zero Zero
Global zero (0).
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
errorManipArg< error, int > exit(error &err, const int errNo=1)
constexpr char nl
The newline '\n' character (0x0a).