Function1s::NonUniformTable, UniformTable: Templated on Type
Function1s::NonUniformTable,UniformTable can now be used for any primitive type used for fields.
This commit is contained in:
@ -98,8 +98,6 @@ primitives/functions/Function1/quarterCosineRamp/quarterCosineRamp.C
|
||||
primitives/functions/Function1/halfCosineRamp/halfCosineRamp.C
|
||||
primitives/functions/Function1/Table/tableBase.C
|
||||
primitives/functions/Function1/Table/TableReader/makeTableReaders.C
|
||||
primitives/functions/Function1/uniformTable1/uniformTable1.C
|
||||
primitives/functions/Function1/nonUniformTable1/nonUniformTable1.C
|
||||
|
||||
primitives/functions/Function2/makeFunction2s.C
|
||||
|
||||
|
||||
@ -243,6 +243,13 @@ public:
|
||||
|
||||
|
||||
#define makeFunction1s(Type) \
|
||||
\
|
||||
template<> \
|
||||
const char* const Foam::Tuple2<Foam::scalar, Type>::typeName \
|
||||
( \
|
||||
"Tuple2<scalar," #Type ">" \
|
||||
); \
|
||||
\
|
||||
makeFunction1(Type); \
|
||||
makeFunction1Type(None, Type); \
|
||||
makeFunction1Type(Constant, Type); \
|
||||
@ -253,6 +260,8 @@ public:
|
||||
makeFunction1Type(Sine, Type); \
|
||||
makeFunction1Type(Square, Type); \
|
||||
makeFunction1Type(Table, Type); \
|
||||
makeFunction1Type(UniformTable, Type); \
|
||||
makeFunction1Type(NonUniformTable, Type); \
|
||||
makeNamedFunction1Type(Table, Type, tableFile); \
|
||||
makeFunction1Type(Scale, Type); \
|
||||
makeFunction1Type(Coded, Type);
|
||||
|
||||
@ -23,35 +23,18 @@ License
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "nonUniformTable1.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace Function1s
|
||||
{
|
||||
makeScalarFunction1(nonUniformTable)
|
||||
}
|
||||
}
|
||||
|
||||
template<>
|
||||
const char* const Foam::Tuple2<Foam::scalar, Foam::scalar>::typeName
|
||||
(
|
||||
"Tuple2<scalar,scalar>"
|
||||
);
|
||||
|
||||
#include "NonUniformTable1.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::Function1s::nonUniformTable::nonUniformTable
|
||||
template<class Type>
|
||||
Foam::Function1s::NonUniformTable<Type>::NonUniformTable
|
||||
(
|
||||
const word& name,
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
FieldFunction1<scalar, nonUniformTable>(name),
|
||||
FieldFunction1<Type, NonUniformTable<Type>>(name),
|
||||
low_(great),
|
||||
high_(-great),
|
||||
values_(dict.lookup("values")),
|
||||
@ -97,7 +80,8 @@ Foam::Function1s::nonUniformTable::nonUniformTable
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
Foam::scalar Foam::Function1s::nonUniformTable::value
|
||||
template<class Type>
|
||||
Type Foam::Function1s::NonUniformTable<Type>::value
|
||||
(
|
||||
scalar x
|
||||
) const
|
||||
@ -112,18 +96,20 @@ Foam::scalar Foam::Function1s::nonUniformTable::value
|
||||
}
|
||||
|
||||
|
||||
Foam::scalar Foam::Function1s::nonUniformTable::integral
|
||||
template<class Type>
|
||||
Type Foam::Function1s::NonUniformTable<Type>::integral
|
||||
(
|
||||
const scalar x1,
|
||||
const scalar x2
|
||||
) const
|
||||
{
|
||||
NotImplemented;
|
||||
return 0;
|
||||
return Zero;
|
||||
}
|
||||
|
||||
|
||||
Foam::scalar Foam::Function1s::nonUniformTable::dfdT
|
||||
template<class Type>
|
||||
Type Foam::Function1s::NonUniformTable<Type>::dfdT
|
||||
(
|
||||
scalar T
|
||||
) const
|
||||
@ -136,7 +122,8 @@ Foam::scalar Foam::Function1s::nonUniformTable::dfdT
|
||||
}
|
||||
|
||||
|
||||
void Foam::Function1s::nonUniformTable::write(Ostream& os) const
|
||||
template<class Type>
|
||||
void Foam::Function1s::NonUniformTable<Type>::write(Ostream& os) const
|
||||
{
|
||||
writeEntry(os, "values", values_);
|
||||
}
|
||||
@ -22,7 +22,7 @@ License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
Foam::Function1s::nonUniformTable
|
||||
Foam::Function1s::NonUniformTable
|
||||
|
||||
Description
|
||||
Non-uniform tabulated property function that linearly interpolates between
|
||||
@ -33,16 +33,16 @@ Description
|
||||
the table.
|
||||
|
||||
Usage
|
||||
\nonUniformTable
|
||||
\NonUniformTable
|
||||
Property | Description
|
||||
values | List of value pairs
|
||||
\endnonUniformTable
|
||||
\endNonUniformTable
|
||||
|
||||
Example for the density of water between 280 and 350K
|
||||
\verbatim
|
||||
rho
|
||||
{
|
||||
type nonUniformTable;
|
||||
type NonUniformTable;
|
||||
|
||||
values
|
||||
(
|
||||
@ -55,8 +55,8 @@ Usage
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef nonUniformTable1_H
|
||||
#define nonUniformTable1_H
|
||||
#ifndef NonUniformTable1_H
|
||||
#define NonUniformTable1_H
|
||||
|
||||
#include "Function1.H"
|
||||
#include "Tuple2.H"
|
||||
@ -69,23 +69,24 @@ namespace Function1s
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class nonUniformTable Declaration
|
||||
Class NonUniformTable Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class nonUniformTable
|
||||
template<class Type>
|
||||
class NonUniformTable
|
||||
:
|
||||
public FieldFunction1<scalar, nonUniformTable>
|
||||
public FieldFunction1<Type, NonUniformTable<Type>>
|
||||
{
|
||||
// Private member data
|
||||
|
||||
//- Lowest value in the nonUniformTable
|
||||
//- Lowest value in the NonUniformTable
|
||||
scalar low_;
|
||||
|
||||
//- Highest value in the nonUniformTable
|
||||
//- Highest value in the NonUniformTable
|
||||
scalar high_;
|
||||
|
||||
//- Table values
|
||||
List<Tuple2<scalar, scalar>> values_;
|
||||
List<Tuple2<scalar, Type>> values_;
|
||||
|
||||
//- Increment derived from low_, high_ and values_.size()
|
||||
scalar delta_;
|
||||
@ -109,25 +110,25 @@ public:
|
||||
// Constructors
|
||||
|
||||
//- Construct from name and dictionary
|
||||
nonUniformTable(const word& name, const dictionary& dict);
|
||||
NonUniformTable(const word& name, const dictionary& dict);
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Return the non-uniform table of values
|
||||
const List<Tuple2<scalar, scalar>>& values() const
|
||||
const List<Tuple2<scalar, Type>>& values() const
|
||||
{
|
||||
return values_;
|
||||
}
|
||||
|
||||
//- Evaluate the function and return the result
|
||||
virtual scalar value(scalar x) const;
|
||||
virtual Type value(scalar x) const;
|
||||
|
||||
//- Integrate between two scalar values
|
||||
virtual scalar integral(const scalar x1, const scalar x2) const;
|
||||
virtual Type integral(const scalar x1, const scalar x2) const;
|
||||
|
||||
//- Evaluate the derivative of the function and return the result
|
||||
scalar dfdT(scalar T) const;
|
||||
Type dfdT(scalar T) const;
|
||||
|
||||
//- Write the function coefficients
|
||||
void write(Ostream& os) const;
|
||||
@ -141,7 +142,11 @@ public:
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#include "nonUniformTable1I.H"
|
||||
#include "NonUniformTable1I.H"
|
||||
|
||||
#ifdef NoRepository
|
||||
#include "NonUniformTable1.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -25,7 +25,8 @@ License
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
inline Foam::label Foam::Function1s::nonUniformTable::index
|
||||
template<class Type>
|
||||
inline Foam::label Foam::Function1s::NonUniformTable<Type>::index
|
||||
(
|
||||
scalar x
|
||||
) const
|
||||
@ -35,7 +36,7 @@ inline Foam::label Foam::Function1s::nonUniformTable::index
|
||||
FatalErrorInFunction
|
||||
<< x << " out of range "
|
||||
<< low_ << " to " << high_ << nl
|
||||
<< " of nonUniformTable " << name_
|
||||
<< " of NonUniformTable " << this->name_
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
@ -73,8 +73,7 @@ void Foam::TableReaders::Embedded<Type>::write
|
||||
const List<Tuple2<scalar, Type>>& table
|
||||
) const
|
||||
{
|
||||
os << indent << "values" << table
|
||||
<< token::END_STATEMENT << endl;
|
||||
writeEntry(os, "values", table);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -23,29 +23,18 @@ License
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "uniformTable1.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace Function1s
|
||||
{
|
||||
makeScalarFunction1(uniformTable)
|
||||
}
|
||||
}
|
||||
|
||||
#include "UniformTable1.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::Function1s::uniformTable::uniformTable
|
||||
template<class Type>
|
||||
Foam::Function1s::UniformTable<Type>::UniformTable
|
||||
(
|
||||
const word& name,
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
FieldFunction1<scalar, uniformTable>(name),
|
||||
FieldFunction1<Type, UniformTable<Type>>(name),
|
||||
dictName_(dict.name()),
|
||||
low_(dict.lookup<scalar>("low")),
|
||||
high_(dict.lookup<scalar>("high")),
|
||||
@ -68,7 +57,8 @@ Foam::Function1s::uniformTable::uniformTable
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
Foam::scalar Foam::Function1s::uniformTable::value(scalar x) const
|
||||
template<class Type>
|
||||
Type Foam::Function1s::UniformTable<Type>::value(scalar x) const
|
||||
{
|
||||
const scalar nd = (x - low_)/delta_;
|
||||
const label i = nd;
|
||||
@ -89,18 +79,20 @@ Foam::scalar Foam::Function1s::uniformTable::value(scalar x) const
|
||||
}
|
||||
|
||||
|
||||
Foam::scalar Foam::Function1s::uniformTable::integral
|
||||
template<class Type>
|
||||
Type Foam::Function1s::UniformTable<Type>::integral
|
||||
(
|
||||
const scalar x1,
|
||||
const scalar x2
|
||||
) const
|
||||
{
|
||||
NotImplemented;
|
||||
return 0;
|
||||
return Zero;
|
||||
}
|
||||
|
||||
|
||||
void Foam::Function1s::uniformTable::write(Ostream& os) const
|
||||
template<class Type>
|
||||
void Foam::Function1s::UniformTable<Type>::write(Ostream& os) const
|
||||
{
|
||||
writeEntry(os, "low", low_);
|
||||
writeEntry(os, "high", high_);
|
||||
@ -22,11 +22,11 @@ License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
Foam::Function1s::uniformTable
|
||||
Foam::Function1s::UniformTable
|
||||
|
||||
Description
|
||||
Tabulated property function that linearly interpolates between
|
||||
the uniformTable values.
|
||||
the UniformTable values.
|
||||
|
||||
Usage
|
||||
\table
|
||||
@ -40,7 +40,7 @@ Usage
|
||||
\verbatim
|
||||
rho
|
||||
{
|
||||
type uniformTable;
|
||||
type UniformTable;
|
||||
|
||||
low 280;
|
||||
high 350;
|
||||
@ -56,8 +56,8 @@ Usage
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef uniformTable1_H
|
||||
#define uniformTable1_H
|
||||
#ifndef UniformTable1_H
|
||||
#define UniformTable1_H
|
||||
|
||||
#include "Function1.H"
|
||||
|
||||
@ -69,12 +69,13 @@ namespace Function1s
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class uniformTable Declaration
|
||||
Class UniformTable Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class uniformTable
|
||||
template<class Type>
|
||||
class UniformTable
|
||||
:
|
||||
public FieldFunction1<scalar, uniformTable>
|
||||
public FieldFunction1<Type, UniformTable<Type>>
|
||||
{
|
||||
// Private member data
|
||||
|
||||
@ -88,7 +89,7 @@ class uniformTable
|
||||
scalar high_;
|
||||
|
||||
//- Table values
|
||||
List<scalar> values_;
|
||||
List<Type> values_;
|
||||
|
||||
//- Increment derived from low_, high_ and values_.size()
|
||||
scalar delta_;
|
||||
@ -103,16 +104,16 @@ public:
|
||||
// Constructors
|
||||
|
||||
//- Construct from name and dictionary
|
||||
uniformTable(const word& name, const dictionary& dict);
|
||||
UniformTable(const word& name, const dictionary& dict);
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Evaluate the function and return the result
|
||||
virtual scalar value(scalar x) const;
|
||||
virtual Type value(scalar x) const;
|
||||
|
||||
//- Integrate between two scalar values
|
||||
virtual scalar integral(const scalar x1, const scalar x2) const;
|
||||
virtual Type integral(const scalar x1, const scalar x2) const;
|
||||
|
||||
//- Write the function coefficients
|
||||
void write(Ostream& os) const;
|
||||
@ -126,6 +127,12 @@ public:
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
#include "UniformTable1.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -32,6 +32,8 @@ License
|
||||
#include "Sine.H"
|
||||
#include "Square.H"
|
||||
#include "Table.H"
|
||||
#include "UniformTable1.H"
|
||||
#include "NonUniformTable1.H"
|
||||
#include "Scale.H"
|
||||
#include "CodedFunction1.H"
|
||||
|
||||
|
||||
@ -57,6 +57,8 @@ namespace solidBodyMotionFunctions
|
||||
#include "Sine.H"
|
||||
#include "Square.H"
|
||||
#include "Table.H"
|
||||
#include "UniformTable1.H"
|
||||
#include "NonUniformTable1.H"
|
||||
#include "EmbeddedTableReader.H"
|
||||
#include "FoamTableReader.H"
|
||||
#include "Scale.H"
|
||||
|
||||
@ -56,6 +56,8 @@ namespace fv
|
||||
#include "Sine.H"
|
||||
#include "Square.H"
|
||||
#include "Table.H"
|
||||
#include "UniformTable1.H"
|
||||
#include "NonUniformTable1.H"
|
||||
#include "EmbeddedTableReader.H"
|
||||
#include "FoamTableReader.H"
|
||||
#include "Scale.H"
|
||||
|
||||
@ -52,14 +52,14 @@ SourceFiles
|
||||
icoTabulated.C
|
||||
|
||||
See also
|
||||
Foam::Function1s::nonUniformTable
|
||||
Foam::Function1s::NonUniformTable
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef icoTabulated_H
|
||||
#define icoTabulated_H
|
||||
|
||||
#include "nonUniformTable1.H"
|
||||
#include "NonUniformTable1.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -88,7 +88,7 @@ class icoTabulated
|
||||
:
|
||||
public Specie
|
||||
{
|
||||
typedef Function1s::nonUniformTable nonUniformTable;
|
||||
typedef Function1s::NonUniformTable<scalar> nonUniformTable;
|
||||
|
||||
|
||||
// Private Data
|
||||
|
||||
@ -71,7 +71,7 @@ SourceFiles
|
||||
rhoTabulated.C
|
||||
|
||||
See also
|
||||
Foam::Function1s::nonUniformTable
|
||||
Foam::Function1s::NonUniformTable
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
@ -57,7 +57,7 @@ SourceFiles
|
||||
eIcoTabulatedThermo.C
|
||||
|
||||
See also
|
||||
Foam::Function1s::nonUniformTable
|
||||
Foam::Function1s::UniformTable
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
@ -57,7 +57,7 @@ SourceFiles
|
||||
hIcoTabulatedThermo.C
|
||||
|
||||
See also
|
||||
Foam::Function1s::nonUniformTable
|
||||
Foam::Function1s::UniformTable
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
@ -46,7 +46,7 @@ Foam::Function1s::integratedNonUniformTable::integratedNonUniformTable
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
nonUniformTable(name, dict),
|
||||
NonUniformTable<scalar>(name, dict),
|
||||
intf_(values().size()),
|
||||
intfByT_(values().size())
|
||||
{
|
||||
@ -110,7 +110,7 @@ void Foam::Function1s::integratedNonUniformTable::write
|
||||
Ostream& os
|
||||
) const
|
||||
{
|
||||
nonUniformTable::write(os);
|
||||
NonUniformTable<scalar>::write(os);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -58,7 +58,7 @@ Usage
|
||||
#ifndef integratedNonUniformTable1_H
|
||||
#define integratedNonUniformTable1_H
|
||||
|
||||
#include "nonUniformTable1.H"
|
||||
#include "NonUniformTable1.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -73,7 +73,7 @@ namespace Function1s
|
||||
|
||||
class integratedNonUniformTable
|
||||
:
|
||||
public nonUniformTable
|
||||
public NonUniformTable<scalar>
|
||||
{
|
||||
// Private member data
|
||||
|
||||
|
||||
@ -61,14 +61,14 @@ SourceFiles
|
||||
icoTabulatedTransport.C
|
||||
|
||||
See also
|
||||
Foam::Function1s::nonUniformTable
|
||||
Foam::Function1s::NonUniformTable
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef icoTabulatedTransport_H
|
||||
#define icoTabulatedTransport_H
|
||||
|
||||
#include "nonUniformTable1.H"
|
||||
#include "NonUniformTable1.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -92,7 +92,7 @@ class icoTabulatedTransport
|
||||
:
|
||||
public Thermo
|
||||
{
|
||||
typedef Function1s::nonUniformTable nonUniformTable;
|
||||
typedef Function1s::NonUniformTable<scalar> nonUniformTable;
|
||||
|
||||
|
||||
// Private Data
|
||||
|
||||
Reference in New Issue
Block a user