72 bounds::repeatableBoundingNames.getOrDefault
76 bounds::repeatableBounding::CLAMP,
84 "interpolationScheme",
99 bounding_(tbl.bounding_),
100 interpolationScheme_(tbl.interpolationScheme_),
102 tableSamplesPtr_(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_)
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;Info<< "Write faMesh in vtk format:"<< nl;{ vtk::uindirectPatchWriter writer(aMesh.patch(), fileName(aMesh.time().globalPath()/vtkBaseFileName));writer.writeGeometry();globalIndex procAddr(aMesh.nFaces());labelList cellIDs;if(UPstream::master()) { cellIDs.resize(procAddr.totalSize());for(const labelRange &range :procAddr.ranges()) { auto slice=cellIDs.slice(range);slice=identity(range);} } writer.beginCellData(4);writer.writeProcIDs();writer.write("cellID", cellIDs);writer.write("area", aMesh.S().field());writer.write("normal", aMesh.faceAreaNormals());writer.beginPointData(1);writer.write("normal", aMesh.pointAreaNormals());Info<< " "<< writer.output().name()<< nl;}{ vtk::lineWriter writer(aMesh.points(), aMesh.edges(), fileName(aMesh.time().globalPath()/(vtkBaseFileName+"-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.
scalarField currentWeights_
virtual tmp< scalarField > x() const
Return the reference values.
bool checkMaxBounds(const scalar x, scalar &xDash) const
Check maximum table bounds.
TableBase(const word &name, const dictionary &dict, const objectRegistry *obrPtr=nullptr)
Construct from dictionary - note table is not populated.
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.
const word interpolationScheme_
Interpolation type.
List< Tuple2< scalar, Type > > table_
Table data.
labelList currentIndices_
Cached indices and weights.
virtual tmp< Field< Type > > y() const
Return the dependent values.
virtual Type value(const scalar x) const
Return Table value.
autoPtr< scalarField > tableSamplesPtr_
Extracted values.
virtual Type integrate(const scalar x1, const scalar x2) const
Integrate between two (scalar) values.
autoPtr< interpolationWeights > interpolatorPtr_
Interpolator method.
const bounds::repeatableBounding bounding_
Handling for out-of-bound 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...
virtual void writeData(Ostream &os) const
Write in dictionary format.
Function1(const word &entryName, const objectRegistry *obrPtr=nullptr)
Construct from entry name.
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.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
const word & name() const noexcept
The name of the entry.
Abstract base class for interpolating in 1D.
static autoPtr< interpolationWeights > New(const word &type, const scalarField &samples)
Return a reference to the selected interpolationWeights.
A class for handling keywords in dictionaries.
Registry of regIOobjects.
A class for managing temporary objects.
static tmp< T > New(Args &&... args)
Construct tmp with forwarding arguments.
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.
Namespace for bounding specifications. At the moment, mostly for tables.
@ 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.
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.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
Ostream & endl(Ostream &os)
Add newline and flush stream.
Ostream & indent(Ostream &os)
Indent stream.
dimensioned< Type > sum(const DimensionedField< Type, GeoMesh > &f1, const label comm)
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...
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::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)