39 if (!interpolatorPtr_)
42 tableSamplesPtr_.reset(
new scalarField(table_.size()));
43 auto&
samples = *tableSamplesPtr_;
55 return *interpolatorPtr_;
84 "interpolationScheme",
90 tableSamplesPtr_(nullptr),
91 interpolatorPtr_(nullptr)
99 bounding_(tbl.bounding_),
100 interpolationScheme_(tbl.interpolationScheme_),
102 tableSamplesPtr_(nullptr),
103 interpolatorPtr_(nullptr)
115 <<
"Table for entry " << this->
name() <<
" is invalid (empty)" 122 for (
const auto& item : table_)
124 const scalar& currValue = item.first();
127 if (i && currValue <= prevValue)
130 <<
"out-of-order value: " 131 << currValue <<
" at index " << i <<
nl 134 prevValue = currValue;
147 const scalar minLimit = table_.first().first();
148 const scalar maxLimit = table_.last().first();
154 case bounds::repeatableBounding::ERROR:
157 <<
"value (" <<
x <<
") less than lower " 158 <<
"bound (" << minLimit <<
")" <<
nl 162 case bounds::repeatableBounding::WARN:
165 <<
"value (" <<
x <<
") less than lower " 166 <<
"bound (" << minLimit <<
")" <<
nl 167 <<
" Continuing with the first entry" <<
endl;
174 case bounds::repeatableBounding::CLAMP:
180 case bounds::repeatableBounding::REPEAT:
183 const scalar span = maxLimit - minLimit;
184 xDash = fmod(
x - minLimit, span) + minLimit;
205 const scalar minLimit = table_.first().first();
206 const scalar maxLimit = table_.last().first();
212 case bounds::repeatableBounding::ERROR:
215 <<
"value (" <<
x <<
") greater than upper " 216 <<
"bound (" << maxLimit <<
")" <<
nl 220 case bounds::repeatableBounding::WARN:
223 <<
"value (" <<
x <<
") greater than upper " 224 <<
"bound (" << maxLimit <<
")" <<
nl 225 <<
" Continuing with the last entry" <<
endl;
232 case bounds::repeatableBounding::CLAMP:
238 case bounds::repeatableBounding::REPEAT:
241 const scalar span = maxLimit - minLimit;
242 xDash = fmod(
x - minLimit, span) + minLimit;
259 for (
auto& item : table_)
264 tableSamplesPtr_.clear();
265 interpolatorPtr_.clear();
274 if (checkMinBounds(
x, xDash))
276 return table_.first().second();
279 if (checkMaxBounds(xDash, xDash))
281 return table_.last().second();
285 interpolator().valueWeights(xDash, currentIndices_, currentWeights_);
287 Type t(currentWeights_[0]*table_[currentIndices_[0]].second());
288 for (label i = 1; i < currentIndices_.size(); i++)
290 t += currentWeights_[i]*table_[currentIndices_[i]].second();
305 interpolator().integrationWeights(x1, x2, currentIndices_, currentWeights_);
307 Type
sum(currentWeights_[0]*table_[currentIndices_[0]].second());
308 for (label i = 1; i < currentIndices_.size(); i++)
310 sum += currentWeights_[i]*table_[currentIndices_[i]].second();
321 auto&
fld = tfld.ref();
325 fld[i] = table_[i].first();
336 auto&
fld = tfld.ref();
340 fld[i] = table_[i].second();
350 if (bounds::repeatableBounding::CLAMP != bounding_)
359 os.writeEntryIfDifferent<word>
361 "interpolationScheme",
A class for handling keywords in dictionaries.
Top level data entry class for use in dictionaries. Provides a mechanism to specify a variable as a c...
dimensioned< Type > sum(const DimensionedField< Type, GeoMesh > &f1)
Ostream & indent(Ostream &os)
Indent stream.
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.
const interpolationWeights & interpolator() const
Return (demand driven) interpolator.
const Foam::Enum< repeatableBounding > repeatableBoundingNames
Strings corresponding to the repeatableBounding.
constexpr char nl
The newline '\n' character (0x0a)
scalarField samples(nIntervals, Zero)
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.
repeatableBounding
Enumeration for handling out-of-bound values that are repeatable.
const bool writeData(pdfDictionary.get< bool >("writeData"))
Abstract base class for interpolating in 1D.
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
#define forAll(list, i)
Loop across all elements in list.
Base class for table with bounds handling, interpolation and integration.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
virtual scalar userTimeToTime(const scalar theta) const
Convert the user-time (e.g. CA deg) to real-time (s).
A class for handling words, derived from Foam::string.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
virtual Type value(const scalar x) const
Return Table value.
bool checkMinBounds(const scalar x, scalar &xDash) const
Check minimum table bounds.
virtual tmp< scalarField > x() const
Return the reference values.
void initialise()
Check the table for size and consistency.
virtual Type integrate(const scalar x1, const scalar x2) const
Integrate between two (scalar) values.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
virtual tmp< Field< Type > > y() const
Return the dependent values.
TableBase(const word &name, const dictionary &dict, const objectRegistry *obrPtr=nullptr)
Construct from dictionary - note table is not populated.
OBJstream os(runTime.globalPath()/outputName)
virtual void userTimeToTime(const Time &t)
Convert time.
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.
bool checkMaxBounds(const scalar x, scalar &xDash) const
Check maximum table bounds.
A class for managing temporary objects.
Registry of regIOobjects.
virtual void writeData(Ostream &os) const
Write all table data in dictionary format.
virtual void writeEntries(Ostream &os) const
Write keywords only in dictionary format.
static constexpr const zero Zero
Global zero (0)