mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
templated uniformInterpolationTable
This commit is contained in:
@ -72,7 +72,7 @@ protected:
|
|||||||
word invertedTableName_;
|
word invertedTableName_;
|
||||||
|
|
||||||
//- Inverted table
|
//- Inverted table
|
||||||
uniformInterpolationTable invertedTable_;
|
uniformInterpolationTable<scalar> invertedTable_;
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -121,7 +121,8 @@ public:
|
|||||||
inline const word& invertedTableName() const;
|
inline const word& invertedTableName() const;
|
||||||
|
|
||||||
//- Return the inverted table
|
//- Return the inverted table
|
||||||
inline const uniformInterpolationTable& invertedTable() const;
|
inline const uniformInterpolationTable<scalar>&
|
||||||
|
invertedTable() const;
|
||||||
|
|
||||||
|
|
||||||
// I-O
|
// I-O
|
||||||
|
|||||||
@ -35,7 +35,7 @@ Foam::tabulatedWallFunctions::tabulatedWallFunction::invertedTableName() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline const Foam::uniformInterpolationTable&
|
inline const Foam::uniformInterpolationTable<Foam::scalar>&
|
||||||
Foam::tabulatedWallFunctions::tabulatedWallFunction::invertedTable() const
|
Foam::tabulatedWallFunctions::tabulatedWallFunction::invertedTable() const
|
||||||
{
|
{
|
||||||
return invertedTable_;
|
return invertedTable_;
|
||||||
|
|||||||
@ -509,7 +509,6 @@ meshes/preservePatchTypes/preservePatchTypes.C
|
|||||||
interpolations = interpolations
|
interpolations = interpolations
|
||||||
interpolation = $(interpolations)/interpolation
|
interpolation = $(interpolations)/interpolation
|
||||||
$(interpolations)/patchToPatchInterpolation/PatchToPatchInterpolationName.C
|
$(interpolations)/patchToPatchInterpolation/PatchToPatchInterpolationName.C
|
||||||
$(interpolations)/uniformInterpolationTable/uniformInterpolationTable.C
|
|
||||||
|
|
||||||
algorithms/MeshWave/MeshWaveName.C
|
algorithms/MeshWave/MeshWaveName.C
|
||||||
algorithms/MeshWave/FaceCellWaveName.C
|
algorithms/MeshWave/FaceCellWaveName.C
|
||||||
|
|||||||
@ -27,20 +27,14 @@ License
|
|||||||
#include "uniformInterpolationTable.H"
|
#include "uniformInterpolationTable.H"
|
||||||
#include "Time.H"
|
#include "Time.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
|
||||||
|
|
||||||
namespace Foam
|
|
||||||
{
|
|
||||||
defineTypeNameAndDebug(uniformInterpolationTable, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
|
// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
|
||||||
|
|
||||||
void Foam::uniformInterpolationTable::checkTable() const
|
template <class Type>
|
||||||
|
void Foam::uniformInterpolationTable<Type>::checkTable() const
|
||||||
{
|
{
|
||||||
if (size() < 2)
|
if (size() < 2)
|
||||||
{
|
{
|
||||||
FatalErrorIn("uniformInterpolationTable::checkTable()")
|
FatalErrorIn("uniformInterpolationTable<Type>::checkTable()")
|
||||||
<< "Table " << name() << ": must have at least 2 values." << nl
|
<< "Table " << name() << ": must have at least 2 values." << nl
|
||||||
<< "Table size = " << size() << nl
|
<< "Table size = " << size() << nl
|
||||||
<< " min, interval width = " << x0_ << ", " << dx_ << nl
|
<< " min, interval width = " << x0_ << ", " << dx_ << nl
|
||||||
@ -51,7 +45,8 @@ void Foam::uniformInterpolationTable::checkTable() const
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
Foam::uniformInterpolationTable::uniformInterpolationTable
|
template <class Type>
|
||||||
|
Foam::uniformInterpolationTable<Type>::uniformInterpolationTable
|
||||||
(
|
(
|
||||||
const IOobject& io,
|
const IOobject& io,
|
||||||
bool readFields
|
bool readFields
|
||||||
@ -79,7 +74,8 @@ Foam::uniformInterpolationTable::uniformInterpolationTable
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Foam::uniformInterpolationTable::uniformInterpolationTable
|
template <class Type>
|
||||||
|
Foam::uniformInterpolationTable<Type>::uniformInterpolationTable
|
||||||
(
|
(
|
||||||
const word& tableName,
|
const word& tableName,
|
||||||
const objectRegistry& db,
|
const objectRegistry& db,
|
||||||
@ -106,7 +102,7 @@ Foam::uniformInterpolationTable::uniformInterpolationTable
|
|||||||
{
|
{
|
||||||
scalar xMax = readScalar(dict.lookup("xMax"));
|
scalar xMax = readScalar(dict.lookup("xMax"));
|
||||||
label nIntervals = static_cast<label>(xMax - x0_)/dx_ + 1;
|
label nIntervals = static_cast<label>(xMax - x0_)/dx_ + 1;
|
||||||
setSize(nIntervals);
|
this->setSize(nIntervals);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -117,7 +113,11 @@ Foam::uniformInterpolationTable::uniformInterpolationTable
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Foam::uniformInterpolationTable::uniformInterpolationTable(const uniformInterpolationTable& uit)
|
template <class Type>
|
||||||
|
Foam::uniformInterpolationTable<Type>::uniformInterpolationTable
|
||||||
|
(
|
||||||
|
const uniformInterpolationTable& uit
|
||||||
|
)
|
||||||
:
|
:
|
||||||
IOobject(uit),
|
IOobject(uit),
|
||||||
List<scalar>(uit),
|
List<scalar>(uit),
|
||||||
@ -132,13 +132,15 @@ Foam::uniformInterpolationTable::uniformInterpolationTable(const uniformInterpol
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
Foam::uniformInterpolationTable::~uniformInterpolationTable()
|
template <class Type>
|
||||||
|
Foam::uniformInterpolationTable<Type>::~uniformInterpolationTable()
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
Foam::scalar Foam::uniformInterpolationTable::interpolate(scalar x) const
|
template <class Type>
|
||||||
|
Type Foam::uniformInterpolationTable<Type>::interpolate(scalar x) const
|
||||||
{
|
{
|
||||||
if (bound_)
|
if (bound_)
|
||||||
{
|
{
|
||||||
@ -148,16 +150,20 @@ Foam::scalar Foam::uniformInterpolationTable::interpolate(scalar x) const
|
|||||||
{
|
{
|
||||||
if (x < x0_)
|
if (x < x0_)
|
||||||
{
|
{
|
||||||
FatalErrorIn("uniformInterpolationTable::interpolate(scalar x)")
|
FatalErrorIn
|
||||||
<< "Supplied value is less than minimum table value:" << nl
|
(
|
||||||
|
"uniformInterpolationTable<Type>::interpolate(scalar x)"
|
||||||
|
) << "Supplied value is less than minimum table value:" << nl
|
||||||
<< "xMin=" << x0_ << ", xMax=" << xMax() << ", x=" << x << nl
|
<< "xMin=" << x0_ << ", xMax=" << xMax() << ", x=" << x << nl
|
||||||
<< exit(FatalError);
|
<< exit(FatalError);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (x > xMax())
|
if (x > xMax())
|
||||||
{
|
{
|
||||||
FatalErrorIn("uniformInterpolationTable::interpolate(scalar x)")
|
FatalErrorIn
|
||||||
<< "Supplied value is greater than maximum table value:" << nl
|
(
|
||||||
|
"uniformInterpolationTable<Type>::interpolate(scalar x)"
|
||||||
|
) << "Supplied value is greater than maximum table value:" << nl
|
||||||
<< "xMin=" << x0_ << ", xMax=" << xMax() << ", x=" << x << nl
|
<< "xMin=" << x0_ << ", xMax=" << xMax() << ", x=" << x << nl
|
||||||
<< exit(FatalError);
|
<< exit(FatalError);
|
||||||
}
|
}
|
||||||
@ -167,7 +173,7 @@ Foam::scalar Foam::uniformInterpolationTable::interpolate(scalar x) const
|
|||||||
|
|
||||||
scalar xLo = x0_ + i*dx_;
|
scalar xLo = x0_ + i*dx_;
|
||||||
|
|
||||||
scalar fx = (x - xLo)/dx_*(operator[](i+1) - operator[](i)) + operator[](i);
|
Type fx = (x - xLo)/dx_*(operator[](i+1) - operator[](i)) + operator[](i);
|
||||||
|
|
||||||
if (debug)
|
if (debug)
|
||||||
{
|
{
|
||||||
@ -181,7 +187,11 @@ Foam::scalar Foam::uniformInterpolationTable::interpolate(scalar x) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Foam::scalar Foam::uniformInterpolationTable::interpolateLog10(scalar x) const
|
template <class Type>
|
||||||
|
Type Foam::uniformInterpolationTable<Type>::interpolateLog10
|
||||||
|
(
|
||||||
|
scalar x
|
||||||
|
) const
|
||||||
{
|
{
|
||||||
if (log10_)
|
if (log10_)
|
||||||
{
|
{
|
||||||
@ -197,7 +207,7 @@ Foam::scalar Foam::uniformInterpolationTable::interpolateLog10(scalar x) const
|
|||||||
{
|
{
|
||||||
FatalErrorIn
|
FatalErrorIn
|
||||||
(
|
(
|
||||||
"uniformInterpolationTable::interpolateLog10(scalar x)"
|
"uniformInterpolationTable<Type>::interpolateLog10(scalar x)"
|
||||||
) << "Table " << name() << nl
|
) << "Table " << name() << nl
|
||||||
<< "Supplied value must be greater than 0 when in log10 mode"
|
<< "Supplied value must be greater than 0 when in log10 mode"
|
||||||
<< nl << "x=" << x << nl << exit(FatalError);
|
<< nl << "x=" << x << nl << exit(FatalError);
|
||||||
@ -208,7 +218,8 @@ Foam::scalar Foam::uniformInterpolationTable::interpolateLog10(scalar x) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Foam::uniformInterpolationTable::write() const
|
template <class Type>
|
||||||
|
void Foam::uniformInterpolationTable<Type>::write() const
|
||||||
{
|
{
|
||||||
IOdictionary dict(*this);
|
IOdictionary dict(*this);
|
||||||
|
|
||||||
|
|||||||
@ -29,7 +29,7 @@ Description
|
|||||||
Table with uniform interval in independant variable, with linear
|
Table with uniform interval in independant variable, with linear
|
||||||
interpolation
|
interpolation
|
||||||
|
|
||||||
Values specified in a dictionary:
|
Example usage (scalar): values specified in a dictionary:
|
||||||
|
|
||||||
{
|
{
|
||||||
x0 0; // lower limit
|
x0 0; // lower limit
|
||||||
@ -66,10 +66,11 @@ namespace Foam
|
|||||||
Class uniformInterpolationTable Declaration
|
Class uniformInterpolationTable Declaration
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
template <class Type>
|
||||||
class uniformInterpolationTable
|
class uniformInterpolationTable
|
||||||
:
|
:
|
||||||
public IOobject,
|
public IOobject,
|
||||||
public List<scalar>
|
public List<Type>
|
||||||
{
|
{
|
||||||
// Private data
|
// Private data
|
||||||
|
|
||||||
@ -99,10 +100,6 @@ class uniformInterpolationTable
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
//- Runtime type information
|
|
||||||
TypeName("uniformInterpolationTable");
|
|
||||||
|
|
||||||
|
|
||||||
// Constructors
|
// Constructors
|
||||||
|
|
||||||
//- Construct from IOobject and readFields flag. Creates a null object
|
//- Construct from IOobject and readFields flag. Creates a null object
|
||||||
@ -169,10 +166,10 @@ public:
|
|||||||
inline scalar xMax() const;
|
inline scalar xMax() const;
|
||||||
|
|
||||||
//- Interpolate
|
//- Interpolate
|
||||||
scalar interpolate(scalar x) const;
|
Type interpolate(scalar x) const;
|
||||||
|
|
||||||
//- Interpolate - takes log10 flag into account
|
//- Interpolate - takes log10 flag into account
|
||||||
scalar interpolateLog10(scalar x) const;
|
Type interpolateLog10(scalar x) const;
|
||||||
|
|
||||||
|
|
||||||
// Override ancestor size() function and [] operator
|
// Override ancestor size() function and [] operator
|
||||||
@ -180,19 +177,19 @@ public:
|
|||||||
//- Return the size of the table
|
//- Return the size of the table
|
||||||
label size() const
|
label size() const
|
||||||
{
|
{
|
||||||
return List<scalar>::size();
|
return List<Type>::size();
|
||||||
}
|
}
|
||||||
|
|
||||||
//- Use List[] operator for read access
|
//- Use List[] operator for read access
|
||||||
scalar operator[](label x) const
|
Type operator[](label x) const
|
||||||
{
|
{
|
||||||
return List<scalar>::operator[](x);
|
return List<Type>::operator[](x);
|
||||||
}
|
}
|
||||||
|
|
||||||
//- Use List[] operator for write access
|
//- Use List[] operator for write access
|
||||||
scalar& operator[](label x)
|
Type& operator[](label x)
|
||||||
{
|
{
|
||||||
return List<scalar>::operator[](x);
|
return List<Type>::operator[](x);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -213,6 +210,12 @@ public:
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#ifdef NoRepository
|
||||||
|
#include "uniformInterpolationTable.C"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// ************************************************************************* //
|
// ************************************************************************* //
|
||||||
|
|||||||
@ -24,63 +24,73 @@ License
|
|||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
Foam::scalar Foam::uniformInterpolationTable::x0() const
|
template <class Type>
|
||||||
|
Foam::scalar Foam::uniformInterpolationTable<Type>::x0() const
|
||||||
{
|
{
|
||||||
return x0_;
|
return x0_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Foam::scalar Foam::uniformInterpolationTable::dx() const
|
template <class Type>
|
||||||
|
Foam::scalar Foam::uniformInterpolationTable<Type>::dx() const
|
||||||
{
|
{
|
||||||
return dx_;
|
return dx_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const Foam::Switch& Foam::uniformInterpolationTable::log10() const
|
template <class Type>
|
||||||
|
const Foam::Switch& Foam::uniformInterpolationTable<Type>::log10() const
|
||||||
{
|
{
|
||||||
return log10_;
|
return log10_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const Foam::Switch& Foam::uniformInterpolationTable::bound() const
|
template <class Type>
|
||||||
|
const Foam::Switch& Foam::uniformInterpolationTable<Type>::bound() const
|
||||||
{
|
{
|
||||||
return bound_;
|
return bound_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Foam::scalar& Foam::uniformInterpolationTable::x0()
|
template <class Type>
|
||||||
|
Foam::scalar& Foam::uniformInterpolationTable<Type>::x0()
|
||||||
{
|
{
|
||||||
return x0_;
|
return x0_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Foam::scalar& Foam::uniformInterpolationTable::dx()
|
template <class Type>
|
||||||
|
Foam::scalar& Foam::uniformInterpolationTable<Type>::dx()
|
||||||
{
|
{
|
||||||
return dx_;
|
return dx_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Foam::Switch& Foam::uniformInterpolationTable::log10()
|
template <class Type>
|
||||||
|
Foam::Switch& Foam::uniformInterpolationTable<Type>::log10()
|
||||||
{
|
{
|
||||||
return log10_;
|
return log10_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Foam::Switch& Foam::uniformInterpolationTable::bound()
|
template <class Type>
|
||||||
|
Foam::Switch& Foam::uniformInterpolationTable<Type>::bound()
|
||||||
{
|
{
|
||||||
return bound_;
|
return bound_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Foam::scalar Foam::uniformInterpolationTable::xMin() const
|
template <class Type>
|
||||||
|
Foam::scalar Foam::uniformInterpolationTable<Type>::xMin() const
|
||||||
{
|
{
|
||||||
return x0_;
|
return x0_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Foam::scalar Foam::uniformInterpolationTable::xMax() const
|
template <class Type>
|
||||||
|
Foam::scalar Foam::uniformInterpolationTable<Type>::xMax() const
|
||||||
{
|
{
|
||||||
return x0_ + (size()-1)*dx_;
|
return x0_ + dx_*(size() - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -68,7 +68,7 @@ protected:
|
|||||||
word uPlusTableName_;
|
word uPlusTableName_;
|
||||||
|
|
||||||
//- U+ table
|
//- U+ table
|
||||||
uniformInterpolationTable uPlusTable_;
|
uniformInterpolationTable<scalar> uPlusTable_;
|
||||||
|
|
||||||
|
|
||||||
// Protected member functions
|
// Protected member functions
|
||||||
|
|||||||
Reference in New Issue
Block a user