39 if (!interpolatorPtr_)
42 tableSamplesPtr_.reset(
new scalarField(table_.size()));
43 auto&
samples = *tableSamplesPtr_;
48 interpolatorPtr_ = interpolationWeights::New
55 return *interpolatorPtr_;
72 bounds::repeatableBoundingNames.getOrDefault
76 bounds::repeatableBounding::CLAMP,
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();
157 <<
"value (" <<
x <<
") less than lower "
158 <<
"bound (" << minLimit <<
")" <<
nl
165 <<
"value (" <<
x <<
") less than lower "
166 <<
"bound (" << minLimit <<
")" <<
nl
167 <<
" Continuing with the first entry" <<
endl;
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();
215 <<
"value (" <<
x <<
") greater than upper "
216 <<
"bound (" << maxLimit <<
")" <<
nl
223 <<
"value (" <<
x <<
") greater than upper "
224 <<
"bound (" << maxLimit <<
")" <<
nl
225 <<
" Continuing with the last entry" <<
endl;
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();
359 os.writeEntryIfDifferent<
word>
361 "interpolationScheme",
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))
Base class for table with bounds handling, interpolation and integration.
void initialise()
Check the table for size and consistency.
const interpolationWeights & interpolator() const
Return (demand driven) interpolator.
bool checkMinBounds(const scalar x, scalar &xDash) const
Check minimum table bounds.
virtual tmp< scalarField > x() const
Return the reference values.
bool checkMaxBounds(const scalar x, scalar &xDash) const
Check maximum table bounds.
virtual void writeEntries(Ostream &os) const
Write keywords only in dictionary format.
virtual tmp< Field< Type > > y() const
Return the dependent values.
virtual Type integrate(const scalar x1, const scalar x2) const
Integrate between two (scalar) values.
virtual void userTimeToTime(const Time &t)
Convert time.
Top level data entry class for use in dictionaries. Provides a mechanism to specify a variable as a c...
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
virtual scalar userTimeToTime(const scalar theta) const
Convert the user-time (e.g. CA deg) to real-time (s).
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
static autoPtr< Time > New()
Construct (dummy) Time - no functionObjects or libraries.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Abstract base class for interpolating in 1D.
A class for handling keywords in dictionaries.
Registry of regIOobjects.
A class for managing temporary objects.
A class for handling words, derived from Foam::string.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
OBJstream os(runTime.globalPath()/outputName)
#define WarningInFunction
Report a warning using Foam::Warning.
@ 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.
dimensioned< Type > sum(const DimensionedField< Type, GeoMesh > &df)
Ostream & endl(Ostream &os)
Add newline and flush stream.
Ostream & indent(Ostream &os)
Indent 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.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
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.
scalarField samples(nIntervals, Zero)