DataEntry: Created the DataEntryTypes namespace for all the concrete DataEntry types

to avoid name conflicts with these primitive names in the OpenFOAM namespace
This commit is contained in:
Henry Weller
2016-02-07 13:32:38 +00:00
parent e9a2848232
commit d1387a8563
22 changed files with 231 additions and 159 deletions

View File

@ -135,7 +135,7 @@ int main(int argc, char *argv[])
#include "createFields.H" #include "createFields.H"
Info<< "Reading data file" << endl; Info<< "Reading data file" << endl;
CSV<scalar> pData("pressure", dict, "Data"); DataEntryTypes::CSV<scalar> pData("pressure", dict, "Data");
// time history data // time history data
const scalarField t(pData.x()); const scalarField t(pData.x());

View File

@ -29,63 +29,67 @@ License
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
namespace Foam template<>
Foam::label Foam::DataEntryTypes::CSV<Foam::label>::readValue
(
const List<string>& splitted
)
{ {
template<> if (componentColumns_[0] >= splitted.size())
label CSV<label>::readValue(const List<string>& splitted)
{ {
if (componentColumns_[0] >= splitted.size()) FatalErrorInFunction
{ << "No column " << componentColumns_[0] << " in "
FatalErrorInFunction << splitted << endl
<< "No column " << componentColumns_[0] << " in " << exit(FatalError);
<< splitted << endl
<< exit(FatalError);
}
return readLabel(IStringStream(splitted[componentColumns_[0]])());
} }
template<> return readLabel(IStringStream(splitted[componentColumns_[0]])());
scalar CSV<scalar>::readValue(const List<string>& splitted) }
{
if (componentColumns_[0] >= splitted.size())
{
FatalErrorInFunction
<< "No column " << componentColumns_[0] << " in "
<< splitted << endl
<< exit(FatalError);
}
return readScalar(IStringStream(splitted[componentColumns_[0]])());
template<>
Foam::scalar Foam::DataEntryTypes::CSV<Foam::scalar>::readValue
(
const List<string>& splitted
)
{
if (componentColumns_[0] >= splitted.size())
{
FatalErrorInFunction
<< "No column " << componentColumns_[0] << " in "
<< splitted << endl
<< exit(FatalError);
} }
return readScalar(IStringStream(splitted[componentColumns_[0]])());
template<class Type>
Type CSV<Type>::readValue(const List<string>& splitted)
{
Type result;
for (label i = 0; i < pTraits<Type>::nComponents; i++)
{
if (componentColumns_[i] >= splitted.size())
{
FatalErrorInFunction
<< "No column " << componentColumns_[i] << " in "
<< splitted << endl
<< exit(FatalError);
}
result[i] =
readScalar(IStringStream(splitted[componentColumns_[i]])());
}
return result;
}
} }
template<class Type> template<class Type>
void Foam::CSV<Type>::read() Type Foam::DataEntryTypes::CSV<Type>::readValue(const List<string>& splitted)
{
Type result;
for (label i = 0; i < pTraits<Type>::nComponents; i++)
{
if (componentColumns_[i] >= splitted.size())
{
FatalErrorInFunction
<< "No column " << componentColumns_[i] << " in "
<< splitted << endl
<< exit(FatalError);
}
result[i] =
readScalar(IStringStream(splitted[componentColumns_[i]])());
}
return result;
}
template<class Type>
void Foam::DataEntryTypes::CSV<Type>::read()
{ {
fileName expandedFile(fName_); fileName expandedFile(fName_);
IFstream is(expandedFile.expand()); IFstream is(expandedFile.expand());
@ -196,7 +200,7 @@ void Foam::CSV<Type>::read()
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class Type> template<class Type>
Foam::CSV<Type>::CSV Foam::DataEntryTypes::CSV<Type>::CSV
( (
const word& entryName, const word& entryName,
const dictionary& dict, const dictionary& dict,
@ -227,7 +231,7 @@ Foam::CSV<Type>::CSV
template<class Type> template<class Type>
Foam::CSV<Type>::CSV(const CSV<Type>& tbl) Foam::DataEntryTypes::CSV<Type>::CSV(const CSV<Type>& tbl)
: :
TableBase<Type>(tbl), TableBase<Type>(tbl),
nHeaderLine_(tbl.nHeaderLine_), nHeaderLine_(tbl.nHeaderLine_),
@ -242,14 +246,14 @@ Foam::CSV<Type>::CSV(const CSV<Type>& tbl)
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
template<class Type> template<class Type>
Foam::CSV<Type>::~CSV() Foam::DataEntryTypes::CSV<Type>::~CSV()
{} {}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Type> template<class Type>
const Foam::fileName& Foam::CSV<Type>::fName() const const Foam::fileName& Foam::DataEntryTypes::CSV<Type>::fName() const
{ {
return fName_; return fName_;
} }

View File

@ -62,15 +62,17 @@ SourceFiles
namespace Foam namespace Foam
{ {
template<class Type> // Forward declaration of friend functions and operators
class CSV; namespace DataEntryTypes
{
template<class Type> class CSV;
};
template<class Type> template<class Type>
Ostream& operator<< Ostream& operator<<(Ostream&, const DataEntryTypes::CSV<Type>&);
(
Ostream&, namespace DataEntryTypes
const CSV<Type>& {
);
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
Class CSV Declaration Class CSV Declaration
@ -169,8 +171,16 @@ public:
}; };
template<>
label CSV<label>::readValue(const List<string>& splitted);
template<>
Foam::scalar CSV<scalar>::readValue(const List<string>& splitted);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace DataEntryTypes
} // End namespace Foam } // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -31,7 +31,7 @@ template<class Type>
Foam::Ostream& Foam::operator<< Foam::Ostream& Foam::operator<<
( (
Ostream& os, Ostream& os,
const CSV<Type>& tbl const DataEntryTypes::CSV<Type>& tbl
) )
{ {
os << static_cast<const DataEntry<Type>& >(tbl) os << static_cast<const DataEntry<Type>& >(tbl)
@ -50,7 +50,7 @@ Foam::Ostream& Foam::operator<<
template<class Type> template<class Type>
void Foam::CSV<Type>::writeData(Ostream& os) const void Foam::DataEntryTypes::CSV<Type>::writeData(Ostream& os) const
{ {
DataEntry<Type>::writeData(os); DataEntry<Type>::writeData(os);
os << token::END_STATEMENT << nl; os << token::END_STATEMENT << nl;

View File

@ -28,7 +28,11 @@ License
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class Type> template<class Type>
Foam::Constant<Type>::Constant(const word& entryName, const dictionary& dict) Foam::DataEntryTypes::Constant<Type>::Constant
(
const word& entryName,
const dictionary& dict
)
: :
DataEntry<Type>(entryName), DataEntry<Type>(entryName),
value_(pTraits<Type>::zero) value_(pTraits<Type>::zero)
@ -40,7 +44,11 @@ Foam::Constant<Type>::Constant(const word& entryName, const dictionary& dict)
template<class Type> template<class Type>
Foam::Constant<Type>::Constant(const word& entryName, Istream& is) Foam::DataEntryTypes::Constant<Type>::Constant
(
const word& entryName,
Istream& is
)
: :
DataEntry<Type>(entryName), DataEntry<Type>(entryName),
value_(pTraits<Type>(is)) value_(pTraits<Type>(is))
@ -48,7 +56,7 @@ Foam::Constant<Type>::Constant(const word& entryName, Istream& is)
template<class Type> template<class Type>
Foam::Constant<Type>::Constant(const Constant<Type>& cnst) Foam::DataEntryTypes::Constant<Type>::Constant(const Constant<Type>& cnst)
: :
DataEntry<Type>(cnst), DataEntry<Type>(cnst),
value_(cnst.value_) value_(cnst.value_)
@ -58,21 +66,25 @@ Foam::Constant<Type>::Constant(const Constant<Type>& cnst)
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
template<class Type> template<class Type>
Foam::Constant<Type>::~Constant() Foam::DataEntryTypes::Constant<Type>::~Constant()
{} {}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Type> template<class Type>
Type Foam::Constant<Type>::value(const scalar x) const Type Foam::DataEntryTypes::Constant<Type>::value(const scalar x) const
{ {
return value_; return value_;
} }
template<class Type> template<class Type>
Type Foam::Constant<Type>::integrate(const scalar x1, const scalar x2) const Type Foam::DataEntryTypes::Constant<Type>::integrate
(
const scalar x1,
const scalar x2
) const
{ {
return (x2 - x1)*value_; return (x2 - x1)*value_;
} }

View File

@ -48,8 +48,16 @@ namespace Foam
{ {
// Forward declaration of friend functions and operators // Forward declaration of friend functions and operators
template<class Type> class Constant; namespace DataEntryTypes
template<class Type> Ostream& operator<<(Ostream&, const Constant<Type>&); {
template<class Type> class Constant;
};
template<class Type>
Ostream& operator<<(Ostream&, const DataEntryTypes::Constant<Type>&);
namespace DataEntryTypes
{
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
Class Constant Declaration Class Constant Declaration
@ -127,6 +135,7 @@ public:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace DataEntryTypes
} // End namespace Foam } // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -31,7 +31,7 @@ template<class Type>
Foam::Ostream& Foam::operator<< Foam::Ostream& Foam::operator<<
( (
Ostream& os, Ostream& os,
const Constant<Type>& cnst const DataEntryTypes::Constant<Type>& cnst
) )
{ {
os << static_cast<const DataEntry<Type>& >(cnst) os << static_cast<const DataEntry<Type>& >(cnst)
@ -48,7 +48,7 @@ Foam::Ostream& Foam::operator<<
template<class Type> template<class Type>
void Foam::Constant<Type>::writeData(Ostream& os) const void Foam::DataEntryTypes::Constant<Type>::writeData(Ostream& os) const
{ {
DataEntry<Type>::writeData(os); DataEntry<Type>::writeData(os);

View File

@ -189,9 +189,9 @@ public:
#define makeDataEntryType(SS, Type) \ #define makeDataEntryType(SS, Type) \
\ \
defineNamedTemplateTypeNameAndDebug(SS<Type>, 0); \ defineNamedTemplateTypeNameAndDebug(DataEntryTypes::SS<Type>, 0); \
\ \
DataEntry<Type>::adddictionaryConstructorToTable<SS<Type>> \ DataEntry<Type>::adddictionaryConstructorToTable<DataEntryTypes::SS<Type>> \
add##SS##Type##ConstructorToTable_; add##SS##Type##ConstructorToTable_;

View File

@ -42,7 +42,10 @@ Foam::autoPtr<Foam::DataEntry<Type>> Foam::DataEntry<Type>::New
if (!firstToken.isWord()) if (!firstToken.isWord())
{ {
is.putBack(firstToken); is.putBack(firstToken);
return autoPtr<DataEntry<Type>>(new Constant<Type>(entryName, is)); return autoPtr<DataEntry<Type>>
(
new DataEntryTypes::Constant<Type>(entryName, is)
);
} }
else else
{ {

View File

@ -28,7 +28,7 @@ License
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class Type> template<class Type>
Foam::PolynomialEntry<Type>::PolynomialEntry Foam::DataEntryTypes::Polynomial<Type>::Polynomial
( (
const word& entryName, const word& entryName,
const dictionary& dict const dictionary& dict
@ -46,7 +46,7 @@ Foam::PolynomialEntry<Type>::PolynomialEntry
if (!coeffs_.size()) if (!coeffs_.size())
{ {
FatalErrorInFunction FatalErrorInFunction
<< "PolynomialEntry coefficients for entry " << this->name_ << "Polynomial coefficients for entry " << this->name_
<< " are invalid (empty)" << nl << exit(FatalError); << " are invalid (empty)" << nl << exit(FatalError);
} }
@ -64,7 +64,7 @@ Foam::PolynomialEntry<Type>::PolynomialEntry
if (!canIntegrate_) if (!canIntegrate_)
{ {
WarningInFunction WarningInFunction
<< "PolynomialEntry " << this->name_ << " cannot be integrated" << "Polynomial " << this->name_ << " cannot be integrated"
<< endl; << endl;
} }
} }
@ -72,7 +72,7 @@ Foam::PolynomialEntry<Type>::PolynomialEntry
template<class Type> template<class Type>
Foam::PolynomialEntry<Type>::PolynomialEntry Foam::DataEntryTypes::Polynomial<Type>::Polynomial
( (
const word& entryName, const word& entryName,
const List<Tuple2<Type, Type>>& coeffs const List<Tuple2<Type, Type>>& coeffs
@ -85,7 +85,7 @@ Foam::PolynomialEntry<Type>::PolynomialEntry
if (!coeffs_.size()) if (!coeffs_.size())
{ {
FatalErrorInFunction FatalErrorInFunction
<< "PolynomialEntry coefficients for entry " << this->name_ << "Polynomial coefficients for entry " << this->name_
<< " are invalid (empty)" << nl << exit(FatalError); << " are invalid (empty)" << nl << exit(FatalError);
} }
@ -103,7 +103,7 @@ Foam::PolynomialEntry<Type>::PolynomialEntry
if (!canIntegrate_) if (!canIntegrate_)
{ {
WarningInFunction WarningInFunction
<< "PolynomialEntry " << this->name_ << " cannot be integrated" << "Polynomial " << this->name_ << " cannot be integrated"
<< endl; << endl;
} }
} }
@ -111,7 +111,7 @@ Foam::PolynomialEntry<Type>::PolynomialEntry
template<class Type> template<class Type>
Foam::PolynomialEntry<Type>::PolynomialEntry(const PolynomialEntry& poly) Foam::DataEntryTypes::Polynomial<Type>::Polynomial(const Polynomial& poly)
: :
DataEntry<Type>(poly), DataEntry<Type>(poly),
coeffs_(poly.coeffs_), coeffs_(poly.coeffs_),
@ -122,14 +122,14 @@ Foam::PolynomialEntry<Type>::PolynomialEntry(const PolynomialEntry& poly)
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
template<class Type> template<class Type>
Foam::PolynomialEntry<Type>::~PolynomialEntry() Foam::DataEntryTypes::Polynomial<Type>::~Polynomial()
{} {}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Type> template<class Type>
void Foam::PolynomialEntry<Type>::convertTimeBase(const Time& t) void Foam::DataEntryTypes::Polynomial<Type>::convertTimeBase(const Time& t)
{ {
forAll(coeffs_, i) forAll(coeffs_, i)
{ {
@ -144,7 +144,7 @@ void Foam::PolynomialEntry<Type>::convertTimeBase(const Time& t)
template<class Type> template<class Type>
Type Foam::PolynomialEntry<Type>::value(const scalar x) const Type Foam::DataEntryTypes::Polynomial<Type>::value(const scalar x) const
{ {
Type y(pTraits<Type>::zero); Type y(pTraits<Type>::zero);
forAll(coeffs_, i) forAll(coeffs_, i)
@ -161,7 +161,7 @@ Type Foam::PolynomialEntry<Type>::value(const scalar x) const
template<class Type> template<class Type>
Type Foam::PolynomialEntry<Type>::integrate Type Foam::DataEntryTypes::Polynomial<Type>::integrate
( (
const scalar x1, const scalar x1,
const scalar x2 const scalar x2

View File

@ -55,22 +55,29 @@ namespace Foam
{ {
// Forward declaration of friend functions and operators // Forward declaration of friend functions and operators
template<class Type> class PolynomialEntry; namespace DataEntryTypes
{
template<class Type> class Polynomial;
};
template<class Type> template<class Type>
Ostream& operator<<(Ostream&, const PolynomialEntry<Type>&); Ostream& operator<<(Ostream&, const DataEntryTypes::Polynomial<Type>&);
namespace DataEntryTypes
{
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
Class PolynomialEntry Declaration Class Polynomial Declaration
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
template<class Type> template<class Type>
class PolynomialEntry class Polynomial
: :
public DataEntry<Type> public DataEntry<Type>
{ {
// Private data // Private data
//- PolynomialEntry coefficients - list of prefactor, exponent //- Polynomial coefficients - list of prefactor, exponent
List<Tuple2<Type, Type>> coeffs_; List<Tuple2<Type, Type>> coeffs_;
//- Flag to indicate whether poly can be integrated //- Flag to indicate whether poly can be integrated
@ -80,7 +87,7 @@ class PolynomialEntry
// Private Member Functions // Private Member Functions
//- Disallow default bitwise assignment //- Disallow default bitwise assignment
void operator=(const PolynomialEntry<Type>&); void operator=(const Polynomial<Type>&);
public: public:
@ -91,27 +98,27 @@ public:
// Constructors // Constructors
PolynomialEntry(const word& entryName, const dictionary& dict); Polynomial(const word& entryName, const dictionary& dict);
//- Construct from components //- Construct from components
PolynomialEntry Polynomial
( (
const word& entryName, const word& entryName,
const List<Tuple2<Type, Type>>& const List<Tuple2<Type, Type>>&
); );
//- Copy constructor //- Copy constructor
PolynomialEntry(const PolynomialEntry& poly); Polynomial(const Polynomial& poly);
//- Construct and return a clone //- Construct and return a clone
virtual tmp<DataEntry<Type>> clone() const virtual tmp<DataEntry<Type>> clone() const
{ {
return tmp<DataEntry<Type>>(new PolynomialEntry(*this)); return tmp<DataEntry<Type>>(new Polynomial(*this));
} }
//- Destructor //- Destructor
virtual ~PolynomialEntry(); virtual ~Polynomial();
// Member Functions // Member Functions
@ -124,7 +131,7 @@ public:
// Evaluation // Evaluation
//- Return PolynomialEntry value //- Return Polynomial value
Type value(const scalar x) const; Type value(const scalar x) const;
//- Integrate between two (scalar) values //- Integrate between two (scalar) values
@ -137,7 +144,7 @@ public:
friend Ostream& operator<< <Type> friend Ostream& operator<< <Type>
( (
Ostream& os, Ostream& os,
const PolynomialEntry<Type>& cnst const Polynomial<Type>& cnst
); );
//- Write in dictionary format //- Write in dictionary format
@ -147,6 +154,7 @@ public:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace DataEntryTypes
} // End namespace Foam } // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -31,7 +31,7 @@ template<class Type>
Foam::Ostream& Foam::operator<< Foam::Ostream& Foam::operator<<
( (
Ostream& os, Ostream& os,
const PolynomialEntry<Type>& poly const DataEntryTypes::Polynomial<Type>& poly
) )
{ {
os << static_cast<const DataEntry<Type>& >(poly) os << static_cast<const DataEntry<Type>& >(poly)
@ -40,7 +40,7 @@ Foam::Ostream& Foam::operator<<
// Check state of Ostream // Check state of Ostream
os.check os.check
( (
"Ostream& operator<<(Ostream&, const PolynomialEntry&)" "Ostream& operator<<(Ostream&, const Polynomial&)"
); );
return os; return os;
@ -48,7 +48,7 @@ Foam::Ostream& Foam::operator<<
template<class Type> template<class Type>
void Foam::PolynomialEntry<Type>::writeData(Ostream& os) const void Foam::DataEntryTypes::Polynomial<Type>::writeData(Ostream& os) const
{ {
DataEntry<Type>::writeData(os); DataEntry<Type>::writeData(os);

View File

@ -28,7 +28,11 @@ License
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class Type> template<class Type>
Foam::Table<Type>::Table(const word& entryName, const dictionary& dict) Foam::DataEntryTypes::Table<Type>::Table
(
const word& entryName,
const dictionary& dict
)
: :
TableBase<Type>(entryName, dict) TableBase<Type>(entryName, dict)
{ {
@ -40,7 +44,7 @@ Foam::Table<Type>::Table(const word& entryName, const dictionary& dict)
template<class Type> template<class Type>
Foam::Table<Type>::Table(const Table<Type>& tbl) Foam::DataEntryTypes::Table<Type>::Table(const Table<Type>& tbl)
: :
TableBase<Type>(tbl) TableBase<Type>(tbl)
{} {}
@ -49,7 +53,7 @@ Foam::Table<Type>::Table(const Table<Type>& tbl)
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
template<class Type> template<class Type>
Foam::Table<Type>::~Table() Foam::DataEntryTypes::Table<Type>::~Table()
{} {}

View File

@ -53,15 +53,17 @@ SourceFiles
namespace Foam namespace Foam
{ {
template<class Type> // Forward declaration of friend functions and operators
class Table; namespace DataEntryTypes
{
template<class Type> class Table;
};
template<class Type> template<class Type>
Ostream& operator<< Ostream& operator<<(Ostream&, const DataEntryTypes::Table<Type>&);
(
Ostream&, namespace DataEntryTypes
const Table<Type>& {
);
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
Class Table Declaration Class Table Declaration
@ -106,6 +108,7 @@ public:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace DataEntryTypes
} // End namespace Foam } // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -30,7 +30,8 @@ License
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
template<class Type> template<class Type>
const Foam::interpolationWeights& Foam::TableBase<Type>::interpolator() const const Foam::interpolationWeights&
Foam::DataEntryTypes::TableBase<Type>::interpolator() const
{ {
if (interpolatorPtr_.empty()) if (interpolatorPtr_.empty())
{ {
@ -55,7 +56,11 @@ const Foam::interpolationWeights& Foam::TableBase<Type>::interpolator() const
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class Type> template<class Type>
Foam::TableBase<Type>::TableBase(const word& name, const dictionary& dict) Foam::DataEntryTypes::TableBase<Type>::TableBase
(
const word& name,
const dictionary& dict
)
: :
DataEntry<Type>(name), DataEntry<Type>(name),
name_(name), name_(name),
@ -75,7 +80,7 @@ Foam::TableBase<Type>::TableBase(const word& name, const dictionary& dict)
template<class Type> template<class Type>
Foam::TableBase<Type>::TableBase(const TableBase<Type>& tbl) Foam::DataEntryTypes::TableBase<Type>::TableBase(const TableBase<Type>& tbl)
: :
DataEntry<Type>(tbl), DataEntry<Type>(tbl),
name_(tbl.name_), name_(tbl.name_),
@ -90,14 +95,14 @@ Foam::TableBase<Type>::TableBase(const TableBase<Type>& tbl)
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
template<class Type> template<class Type>
Foam::TableBase<Type>::~TableBase() Foam::DataEntryTypes::TableBase<Type>::~TableBase()
{} {}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Type> template<class Type>
Foam::word Foam::TableBase<Type>::boundsHandlingToWord Foam::word Foam::DataEntryTypes::TableBase<Type>::boundsHandlingToWord
( (
const boundsHandling& bound const boundsHandling& bound
) const ) const
@ -133,8 +138,8 @@ Foam::word Foam::TableBase<Type>::boundsHandlingToWord
template<class Type> template<class Type>
typename Foam::TableBase<Type>::boundsHandling typename Foam::DataEntryTypes::TableBase<Type>::boundsHandling
Foam::TableBase<Type>::wordToBoundsHandling Foam::DataEntryTypes::TableBase<Type>::wordToBoundsHandling
( (
const word& bound const word& bound
) const ) const
@ -167,8 +172,8 @@ Foam::TableBase<Type>::wordToBoundsHandling
template<class Type> template<class Type>
typename Foam::TableBase<Type>::boundsHandling typename Foam::DataEntryTypes::TableBase<Type>::boundsHandling
Foam::TableBase<Type>::outOfBounds Foam::DataEntryTypes::TableBase<Type>::outOfBounds
( (
const boundsHandling& bound const boundsHandling& bound
) )
@ -181,7 +186,7 @@ Foam::TableBase<Type>::outOfBounds
template<class Type> template<class Type>
void Foam::TableBase<Type>::check() const void Foam::DataEntryTypes::TableBase<Type>::check() const
{ {
if (!table_.size()) if (!table_.size())
{ {
@ -210,7 +215,7 @@ void Foam::TableBase<Type>::check() const
template<class Type> template<class Type>
bool Foam::TableBase<Type>::checkMinBounds bool Foam::DataEntryTypes::TableBase<Type>::checkMinBounds
( (
const scalar x, const scalar x,
scalar& xDash scalar& xDash
@ -260,7 +265,7 @@ bool Foam::TableBase<Type>::checkMinBounds
template<class Type> template<class Type>
bool Foam::TableBase<Type>::checkMaxBounds bool Foam::DataEntryTypes::TableBase<Type>::checkMaxBounds
( (
const scalar x, const scalar x,
scalar& xDash scalar& xDash
@ -310,7 +315,7 @@ bool Foam::TableBase<Type>::checkMaxBounds
template<class Type> template<class Type>
void Foam::TableBase<Type>::convertTimeBase(const Time& t) void Foam::DataEntryTypes::TableBase<Type>::convertTimeBase(const Time& t)
{ {
forAll(table_, i) forAll(table_, i)
{ {
@ -324,7 +329,7 @@ void Foam::TableBase<Type>::convertTimeBase(const Time& t)
template<class Type> template<class Type>
Type Foam::TableBase<Type>::value(const scalar x) const Type Foam::DataEntryTypes::TableBase<Type>::value(const scalar x) const
{ {
scalar xDash = x; scalar xDash = x;
@ -352,7 +357,11 @@ Type Foam::TableBase<Type>::value(const scalar x) const
template<class Type> template<class Type>
Type Foam::TableBase<Type>::integrate(const scalar x1, const scalar x2) const Type Foam::DataEntryTypes::TableBase<Type>::integrate
(
const scalar x1,
const scalar x2
) const
{ {
// Use interpolator // Use interpolator
interpolator().integrationWeights(x1, x2, currentIndices_, currentWeights_); interpolator().integrationWeights(x1, x2, currentIndices_, currentWeights_);
@ -368,7 +377,7 @@ Type Foam::TableBase<Type>::integrate(const scalar x1, const scalar x2) const
template<class Type> template<class Type>
Foam::tmp<Foam::scalarField> Foam::TableBase<Type>::x() const Foam::tmp<Foam::scalarField> Foam::DataEntryTypes::TableBase<Type>::x() const
{ {
tmp<scalarField> tfld(new scalarField(table_.size(), 0.0)); tmp<scalarField> tfld(new scalarField(table_.size(), 0.0));
scalarField& fld = tfld(); scalarField& fld = tfld();
@ -383,7 +392,7 @@ Foam::tmp<Foam::scalarField> Foam::TableBase<Type>::x() const
template<class Type> template<class Type>
Foam::tmp<Foam::Field<Type>> Foam::TableBase<Type>::y() const Foam::tmp<Foam::Field<Type>> Foam::DataEntryTypes::TableBase<Type>::y() const
{ {
tmp<Field<Type>> tfld(new Field<Type>(table_.size(), pTraits<Type>::zero)); tmp<Field<Type>> tfld(new Field<Type>(table_.size(), pTraits<Type>::zero));
Field<Type>& fld = tfld(); Field<Type>& fld = tfld();

View File

@ -43,18 +43,20 @@ SourceFiles
namespace Foam namespace Foam
{ {
template<class Type>
class TableBase;
template<class Type>
Ostream& operator<<
(
Ostream&,
const TableBase<Type>&
);
class interpolationWeights; class interpolationWeights;
// Forward declaration of friend functions and operators
namespace DataEntryTypes
{
template<class Type> class TableBase;
};
template<class Type>
Ostream& operator<<(Ostream&, const DataEntryTypes::TableBase<Type>&);
namespace DataEntryTypes
{
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
Class TableBase Declaration Class TableBase Declaration
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
@ -186,6 +188,7 @@ public:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace DataEntryTypes
} // End namespace Foam } // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -31,7 +31,7 @@ template<class Type>
Foam::Ostream& Foam::operator<< Foam::Ostream& Foam::operator<<
( (
Ostream& os, Ostream& os,
const TableBase<Type>& tbl const DataEntryTypes::TableBase<Type>& tbl
) )
{ {
os << static_cast<const DataEntry<Type>&>(tbl); os << static_cast<const DataEntry<Type>&>(tbl);
@ -48,7 +48,7 @@ Foam::Ostream& Foam::operator<<
template<class Type> template<class Type>
void Foam::TableBase<Type>::writeData(Ostream& os) const void Foam::DataEntryTypes::TableBase<Type>::writeData(Ostream& os) const
{ {
DataEntry<Type>::writeData(os); DataEntry<Type>::writeData(os);
os << nl << indent << table_ << token::END_STATEMENT << nl; os << nl << indent << table_ << token::END_STATEMENT << nl;
@ -57,7 +57,7 @@ void Foam::TableBase<Type>::writeData(Ostream& os) const
template<class Type> template<class Type>
void Foam::TableBase<Type>::writeEntries(Ostream& os) const void Foam::DataEntryTypes::TableBase<Type>::writeEntries(Ostream& os) const
{ {
if (boundsHandling_ != CLAMP) if (boundsHandling_ != CLAMP)
{ {

View File

@ -28,7 +28,11 @@ License
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class Type> template<class Type>
Foam::TableFile<Type>::TableFile(const word& entryName, const dictionary& dict) Foam::DataEntryTypes::TableFile<Type>::TableFile
(
const word& entryName,
const dictionary& dict
)
: :
TableBase<Type>(entryName, dict.subDict(entryName + "Coeffs")), TableBase<Type>(entryName, dict.subDict(entryName + "Coeffs")),
fName_("none") fName_("none")
@ -54,7 +58,7 @@ Foam::TableFile<Type>::TableFile(const word& entryName, const dictionary& dict)
template<class Type> template<class Type>
Foam::TableFile<Type>::TableFile(const TableFile<Type>& tbl) Foam::DataEntryTypes::TableFile<Type>::TableFile(const TableFile<Type>& tbl)
: :
TableBase<Type>(tbl), TableBase<Type>(tbl),
fName_(tbl.fName_) fName_(tbl.fName_)
@ -64,7 +68,7 @@ Foam::TableFile<Type>::TableFile(const TableFile<Type>& tbl)
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
template<class Type> template<class Type>
Foam::TableFile<Type>::~TableFile() Foam::DataEntryTypes::TableFile<Type>::~TableFile()
{} {}

View File

@ -64,15 +64,17 @@ SourceFiles
namespace Foam namespace Foam
{ {
template<class Type> // Forward declaration of friend functions and operators
class TableFile; namespace DataEntryTypes
{
template<class Type> class TableFile;
};
template<class Type> template<class Type>
Ostream& operator<< Ostream& operator<<(Ostream&, const DataEntryTypes::TableFile<Type>&);
(
Ostream&, namespace DataEntryTypes
const TableFile<Type>& {
);
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
Class TableFile Declaration Class TableFile Declaration
@ -129,6 +131,7 @@ public:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace DataEntryTypes
} // End namespace Foam } // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -28,7 +28,7 @@ License
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * // // * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
template<class Type> template<class Type>
void Foam::TableFile<Type>::writeData(Ostream& os) const void Foam::DataEntryTypes::TableFile<Type>::writeData(Ostream& os) const
{ {
DataEntry<Type>::writeData(os); DataEntry<Type>::writeData(os);

View File

@ -43,42 +43,42 @@ namespace Foam
// Polynomial functions and interpolation do evaluate to label // Polynomial functions and interpolation do evaluate to label
// Instead evaluate a scalar and convert to label as appropriate // Instead evaluate a scalar and convert to label as appropriate
// makeDataEntryType(PolynomialEntry, label); // makeDataEntryType(Polynomial, label);
// makeDataEntryType(CSV, label); // makeDataEntryType(CSV, label);
// makeDataEntryType(Table, label); // makeDataEntryType(Table, label);
// makeDataEntryType(TableFile, label); // makeDataEntryType(TableFile, label);
makeDataEntry(scalar); makeDataEntry(scalar);
makeDataEntryType(Constant, scalar); makeDataEntryType(Constant, scalar);
makeDataEntryType(PolynomialEntry, scalar); makeDataEntryType(Polynomial, scalar);
makeDataEntryType(CSV, scalar); makeDataEntryType(CSV, scalar);
makeDataEntryType(Table, scalar); makeDataEntryType(Table, scalar);
makeDataEntryType(TableFile, scalar); makeDataEntryType(TableFile, scalar);
makeDataEntry(vector); makeDataEntry(vector);
makeDataEntryType(Constant, vector); makeDataEntryType(Constant, vector);
makeDataEntryType(PolynomialEntry, vector); makeDataEntryType(Polynomial, vector);
makeDataEntryType(CSV, vector); makeDataEntryType(CSV, vector);
makeDataEntryType(Table, vector); makeDataEntryType(Table, vector);
makeDataEntryType(TableFile, vector); makeDataEntryType(TableFile, vector);
makeDataEntry(sphericalTensor); makeDataEntry(sphericalTensor);
makeDataEntryType(Constant, sphericalTensor); makeDataEntryType(Constant, sphericalTensor);
makeDataEntryType(PolynomialEntry, sphericalTensor); makeDataEntryType(Polynomial, sphericalTensor);
makeDataEntryType(CSV, sphericalTensor); makeDataEntryType(CSV, sphericalTensor);
makeDataEntryType(Table, sphericalTensor); makeDataEntryType(Table, sphericalTensor);
makeDataEntryType(TableFile, sphericalTensor); makeDataEntryType(TableFile, sphericalTensor);
makeDataEntry(symmTensor); makeDataEntry(symmTensor);
makeDataEntryType(Constant, symmTensor); makeDataEntryType(Constant, symmTensor);
makeDataEntryType(PolynomialEntry, symmTensor); makeDataEntryType(Polynomial, symmTensor);
makeDataEntryType(CSV, symmTensor); makeDataEntryType(CSV, symmTensor);
makeDataEntryType(Table, symmTensor); makeDataEntryType(Table, symmTensor);
makeDataEntryType(TableFile, symmTensor); makeDataEntryType(TableFile, symmTensor);
makeDataEntry(tensor); makeDataEntry(tensor);
makeDataEntryType(Constant, tensor); makeDataEntryType(Constant, tensor);
makeDataEntryType(PolynomialEntry, tensor); makeDataEntryType(Polynomial, tensor);
makeDataEntryType(CSV, tensor); makeDataEntryType(CSV, tensor);
makeDataEntryType(Table, tensor); makeDataEntryType(Table, tensor);
makeDataEntryType(TableFile, tensor); makeDataEntryType(TableFile, tensor);

View File

@ -98,7 +98,7 @@ Foam::fanFvPatchField<Foam::scalar>::fanFvPatchField
this->jumpTable_.reset this->jumpTable_.reset
( (
new PolynomialEntry<scalar>("jumpTable", coeffs) new DataEntryTypes::Polynomial<scalar>("jumpTable", coeffs)
); );
} }
else else