39 fileName fName(fileName_);
44 reader_()(fName, *
this);
49 <<
"table read from " << fName <<
" is empty" <<
nl
64 bounding_(bounds::repeatableBounding::WARN),
65 fileName_(
"fileNameIsUndefined"),
89 bounding_(bounds::repeatableBounding::WARN),
103 bounds::repeatableBoundingNames.getOrDefault
107 bounds::repeatableBounding::WARN,
125 bounding_(tbl.bounding_),
126 fileName_(tbl.fileName_),
127 reader_(tbl.reader_.clone())
141 for (
const auto& item : list)
143 const scalar& currValue = item.first();
146 if (i && currValue <= prevValue)
149 <<
"out-of-order value: "
150 << currValue <<
" at index " << i <<
nl
153 prevValue = currValue;
176 const label
n = list.
size();
184 const scalar minLimit = list.
first().first();
185 const scalar maxLimit = list.
last().first();
187 if (lookupValue < minLimit)
194 <<
"value (" << lookupValue <<
") less than lower "
195 <<
"bound (" << minLimit <<
")\n"
202 <<
"value (" << lookupValue <<
") less than lower "
203 <<
"bound (" << minLimit <<
")\n"
204 <<
" Zero rate of change." <<
endl;
218 scalar span = maxLimit-minLimit;
219 lookupValue = fmod(lookupValue - minLimit, span) + minLimit;
224 else if (lookupValue >= maxLimit)
231 <<
"value (" << lookupValue <<
") greater than upper "
232 <<
"bound (" << maxLimit <<
")\n"
239 <<
"value (" << lookupValue <<
") greater than upper "
240 <<
"bound (" << maxLimit <<
")\n"
241 <<
" Zero rate of change." <<
endl;
255 scalar span = maxLimit-minLimit;
256 lookupValue = fmod(lookupValue - minLimit, span) + minLimit;
266 for (label i = 0; i <
n; ++i)
268 if (lookupValue >= list[i].first())
294 (list[hi].second() - list[lo].second())
295 / (list[hi].first() + minLimit - list[lo].first())
303 (list[hi].second() - list[lo].second())
304 / (list[hi].first() - list[lo].first())
317 const label
n = list.
size();
325 <<
"Cannot interpolate from zero-sized table" <<
nl
330 return list.
first().second();
333 const scalar minLimit = list.
first().first();
334 const scalar maxLimit = list.
last().first();
336 if (lookupValue < minLimit)
343 <<
"value (" << lookupValue <<
") less than lower "
344 <<
"bound (" << minLimit <<
")\n"
351 <<
"value (" << lookupValue <<
") less than lower "
352 <<
"bound (" << minLimit <<
")\n"
353 <<
" Continuing with the first entry" <<
endl;
356 return list.
first().second();
361 return list.
first().second();
367 const scalar span = maxLimit-minLimit;
368 lookupValue = fmod(lookupValue - minLimit, span) + minLimit;
373 else if (lookupValue >= maxLimit)
380 <<
"value (" << lookupValue <<
") greater than upper "
381 <<
"bound (" << maxLimit <<
")\n"
388 <<
"value (" << lookupValue <<
") greater than upper "
389 <<
"bound (" << maxLimit <<
")\n"
390 <<
" Continuing with the last entry" <<
endl;
393 return list.
last().second();
398 return list.
last().second();
404 const scalar span = maxLimit-minLimit;
405 lookupValue = fmod(lookupValue - minLimit, span) + minLimit;
416 for (label i = 0; i <
n; ++i)
418 if (lookupValue >= list[i].first())
431 return list[hi].second();
445 + (list[hi].second() - list[lo].second())
446 * (lookupValue / minLimit)
455 + (list[hi].second() - list[lo].second())
456 * (lookupValue - list[lo].first())
457 / (list[hi].first() - list[lo].first())
468 return interpolateValue(*
this, lookupValue, bounding_);
480 auto&
fld = tfld.ref();
484 fld[i] = interpolateValue(vals[i]);
505 bounding_ = rhs.bounding_;
506 fileName_ = rhs.fileName_;
507 reader_.reset(rhs.reader_.clone());
516 const label
n = list.
size();
526 <<
"Cannot interpolate from zero-sized table" <<
nl
538 <<
"index (" << idx <<
") underflow" <<
nl
545 <<
"index (" << idx <<
") underflow" <<
nl
546 <<
" Continuing with the first entry" <<
nl;
574 <<
"index (" << idx <<
") overflow" <<
nl
581 <<
"index (" << idx <<
") overflow" <<
nl
582 <<
" Continuing with the last entry" <<
nl;
611 return interpolateValue(*
this, lookupValue, bounding_);
Info<< nl<< "Wrote faMesh in vtk format: "<< writer.output().name()<< nl;}{ vtk::lineWriter writer(aMesh.points(), aMesh.edges(), fileName(aMesh.mesh().time().globalPath()/"finiteArea-edges"));writer.writeGeometry();writer.beginCellData(4);writer.writeProcIDs();{ Field< scalar > fld(faMeshTools::flattenEdgeField(aMesh.magLe(), true))
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Ostream & writeEntry(const keyType &key, const T &value)
Write a keyword/value entry.
virtual bool write(const token &tok)=0
Write token to stream or otherwise handle it.
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
T & first()
Return the first element of the list.
void size(const label n)
Older name for setAddressableSize.
T & last()
Return the last element of the list.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Ostream & operator()() const
Output stream (master only).
A class for handling file names.
virtual bool write()
Write the output fields.
An interpolation/look-up table of scalar vs <Type> values. The reference scalar values must be monoto...
void check() const
Check that list is monotonically increasing.
interpolationTable()
Default construct.
tmp< Field< Type > > interpolateValues(const UList< scalar > &vals) const
Return multiple interpolated values.
static Type interpolateValue(const List< Tuple2< scalar, Type > > &list, scalar lookupValue, bounds::repeatableBounding=bounds::repeatableBounding::CLAMP)
Return an interpolated value in List.
Type rateOfChange(scalar lookupValue) const
const Tuple2< scalar, Type > & operator[](label idx) const
Return an element of constant Tuple2<scalar, Type>
Reads an interpolation table from a file - OpenFOAM-format.
Base class to read table data for the interpolationTable.
A class for managing temporary objects.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
OBJstream os(runTime.globalPath()/outputName)
#define WarningInFunction
Report a warning using Foam::Warning.
repeatableBounding
Enumeration for handling out-of-bound values that are repeatable.
@ WARN
Issue warning and clamp value (this is a good default)
@ REPEAT
Treat as a repeating list.
@ ERROR
Exit with a FatalError.
@ CLAMP
Clamp value to the start/end value.
const Foam::Enum< repeatableBounding > repeatableBoundingNames
Strings corresponding to the repeatableBounding.
Ostream & endl(Ostream &os)
Add newline and flush stream.
static constexpr const zero Zero
Global zero (0)
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh > > &tdf1, const word &name, const dimensionSet &dimensions)
Global function forwards to reuseTmpDimensionedField::New.
errorManipArg< error, int > exit(error &err, const int errNo=1)
constexpr char nl
The newline '\n' character (0x0a)
#define forAll(list, i)
Loop across all elements in list.