39 fileName fName(fileName_);
44 reader_()(fName, *
this);
49 <<
"table read from " << fName <<
" is empty" <<
nl 65 fileName_(
"fileNameIsUndefined"),
124 List<value_type>(tbl),
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;
162 os.writeEntry(
"file", fileName_);
174 const List<value_type>& list = *
this;
176 const label
n = list.size();
184 const scalar minLimit = list.first().first();
185 const scalar maxLimit = list.last().first();
187 if (lookupValue < minLimit)
191 case bounds::repeatableBounding::ERROR:
194 <<
"value (" << lookupValue <<
") less than lower " 195 <<
"bound (" << minLimit <<
")\n" 199 case bounds::repeatableBounding::WARN:
202 <<
"value (" << lookupValue <<
") less than lower " 203 <<
"bound (" << minLimit <<
")\n" 204 <<
" Zero rate of change." <<
endl;
210 case bounds::repeatableBounding::CLAMP:
215 case bounds::repeatableBounding::REPEAT:
218 scalar span = maxLimit-minLimit;
219 lookupValue = fmod(lookupValue - minLimit, span) + minLimit;
224 else if (lookupValue >= maxLimit)
228 case bounds::repeatableBounding::ERROR:
231 <<
"value (" << lookupValue <<
") greater than upper " 232 <<
"bound (" << maxLimit <<
")\n" 236 case bounds::repeatableBounding::WARN:
239 <<
"value (" << lookupValue <<
") greater than upper " 240 <<
"bound (" << maxLimit <<
")\n" 241 <<
" Zero rate of change." <<
endl;
247 case bounds::repeatableBounding::CLAMP:
252 case bounds::repeatableBounding::REPEAT:
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)
340 case bounds::repeatableBounding::ERROR:
343 <<
"value (" << lookupValue <<
") less than lower " 344 <<
"bound (" << minLimit <<
")\n" 348 case bounds::repeatableBounding::WARN:
351 <<
"value (" << lookupValue <<
") less than lower " 352 <<
"bound (" << minLimit <<
")\n" 353 <<
" Continuing with the first entry" <<
endl;
356 return list.first().second();
359 case bounds::repeatableBounding::CLAMP:
361 return list.first().second();
364 case bounds::repeatableBounding::REPEAT:
367 const scalar span = maxLimit-minLimit;
368 lookupValue = fmod(lookupValue - minLimit, span) + minLimit;
373 else if (lookupValue >= maxLimit)
377 case bounds::repeatableBounding::ERROR:
380 <<
"value (" << lookupValue <<
") greater than upper " 381 <<
"bound (" << maxLimit <<
")\n" 385 case bounds::repeatableBounding::WARN:
388 <<
"value (" << lookupValue <<
") greater than upper " 389 <<
"bound (" << maxLimit <<
")\n" 390 <<
" Continuing with the last entry" <<
endl;
393 return list.last().second();
396 case bounds::repeatableBounding::CLAMP:
398 return list.last().second();
401 case bounds::repeatableBounding::REPEAT:
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]);
504 static_cast<List<value_type>&
>(*this) = rhs;
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 535 case bounds::repeatableBounding::ERROR:
538 <<
"index (" << idx <<
") underflow" <<
nl 542 case bounds::repeatableBounding::WARN:
545 <<
"index (" << idx <<
") underflow" <<
nl 546 <<
" Continuing with the first entry" <<
nl;
552 case bounds::repeatableBounding::CLAMP:
557 case bounds::repeatableBounding::REPEAT:
571 case bounds::repeatableBounding::ERROR:
574 <<
"index (" << idx <<
") overflow" <<
nl 578 case bounds::repeatableBounding::WARN:
581 <<
"index (" << idx <<
") overflow" <<
nl 582 <<
" Continuing with the last entry" <<
nl;
588 case bounds::repeatableBounding::CLAMP:
593 case bounds::repeatableBounding::REPEAT:
611 return interpolateValue(*
this, lookupValue, bounding_);
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)
interpolationTable()
Default construct.
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...
const Foam::Enum< repeatableBounding > repeatableBoundingNames
Strings corresponding to the repeatableBounding.
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)
const Tuple2< scalar, Type > & operator[](label idx) const
Return an element of constant Tuple2<scalar, Type>
Ostream & endl(Ostream &os)
Add newline and flush stream.
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.
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.
#define forAll(list, i)
Loop across all elements in list.
List< T > values(const HashTable< T, Key, Hash > &tbl, const bool doSort=false)
List of values from HashTable, optionally sorted.
tmp< Field< Type > > interpolateValues(const UList< scalar > &vals) const
Return multiple interpolated values.
void check() const
Check that list is monotonically increasing.
Type operator()(scalar lookupValue) const
Return an interpolated value.
An interpolation/look-up table of scalar vs <Type> values. The reference scalar values must be monoto...
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
Type rateOfChange(scalar lookupValue) const
Return the rate of change at the interpolation location for the given lookup value.
OBJstream os(runTime.globalPath()/outputName)
static void check(const int retVal, const char *what)
void write(Ostream &os) const
Write.
gmvFile<< "tracers "<< particles.size()<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().x()<< ' ';}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().y()<< ' ';}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().z()<< ' ';}gmvFile<< nl;for(const word &name :lagrangianScalarNames){ IOField< scalar > fld(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
#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...
A class for managing temporary objects.
static Type interpolateValue(const List< Tuple2< scalar, Type >> &list, scalar lookupValue, bounds::repeatableBounding=bounds::repeatableBounding::CLAMP)
Return an interpolated value in List.
static constexpr const zero Zero
Global zero (0)