DataEntry: Rationalized IO to ensure consistency between read and write

Removed inconsistent binary output.
Removed unused and IO-inconsistent functions.
Simplified the handling of backward-compatible constant value:
    Removed the unnecessary CompatibilityConstant,
    Updated Constant and DataEntryNew to handle constant value construction.
This commit is contained in:
Henry Weller
2016-02-06 19:34:43 +00:00
parent 8e04a529d9
commit 1fdf881377
20 changed files with 60 additions and 716 deletions

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -34,20 +34,13 @@ Foam::Ostream& Foam::operator<<
const CSV<Type>& tbl
)
{
if (os.format() == IOstream::ASCII)
{
os << static_cast<const DataEntry<Type>& >(tbl)
<< token::SPACE << tbl.nHeaderLine_
<< token::SPACE << tbl.timeColumn_
<< token::SPACE << tbl.componentColumns_
<< token::SPACE << tbl.separator_
<< token::SPACE << tbl.mergeSeparators_
<< token::SPACE << tbl.fileName_;
}
else
{
os << static_cast<const DataEntry<Type>& >(tbl);
}
os << static_cast<const DataEntry<Type>& >(tbl)
<< token::SPACE << tbl.nHeaderLine_
<< token::SPACE << tbl.timeColumn_
<< token::SPACE << tbl.componentColumns_
<< token::SPACE << tbl.separator_
<< token::SPACE << tbl.mergeSeparators_
<< token::SPACE << tbl.fileName_;
// Check state of Ostream
os.check("Ostream& operator<<(Ostream&, const CSV<Type>&)");

View File

@ -1,123 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "CompatibilityConstant.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class Type>
Foam::CompatibilityConstant<Type>::CompatibilityConstant
(
const word& entryName,
const dictionary& dict
)
:
DataEntry<Type>(entryName),
value_(pTraits<Type>::zero),
dimensions_(dimless)
{
Istream& is(dict.lookup(entryName));
token firstToken(is);
if (firstToken.isWord())
{
token nextToken(is);
if (nextToken == token::BEGIN_SQR)
{
is.putBack(nextToken);
is >> dimensions_;
is >> value_;
}
}
else
{
is.putBack(firstToken);
is >> value_;
}
}
template<class Type>
Foam::CompatibilityConstant<Type>::CompatibilityConstant
(
const CompatibilityConstant<Type>& cnst
)
:
DataEntry<Type>(cnst),
value_(cnst.value_),
dimensions_(cnst.dimensions_)
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
template<class Type>
Foam::CompatibilityConstant<Type>::~CompatibilityConstant()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Type>
Type Foam::CompatibilityConstant<Type>::value(const scalar x) const
{
return value_;
}
template<class Type>
Type Foam::CompatibilityConstant<Type>::integrate
(
const scalar x1,
const scalar x2
) const
{
return (x2 - x1)*value_;
}
template<class Type>
Foam::dimensioned<Type> Foam::CompatibilityConstant<Type>::
dimValue(const scalar x) const
{
return dimensioned<Type>("dimensionedValue", dimensions_, value_);
}
template<class Type>
Foam::dimensioned<Type> Foam::CompatibilityConstant<Type>::dimIntegrate
(
const scalar x1, const scalar x2
) const
{
return dimensioned<Type>("dimensionedValue", dimensions_, (x2-x1)*value_);
}
// * * * * * * * * * * * * * * IOStream operators * * * * * * * * * * * * * //
#include "CompatibilityConstantIO.C"
// ************************************************************************* //

View File

@ -1,157 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::CompatibilityConstant
Description
Templated basic entry that holds a constant value for backwards
compatibility (when DataEntry type is not present)
Usage - for entry \<entryName\> having the value <value>:
\verbatim
<entryName> <value>
\endverbatim
SourceFiles
CompatibilityConstant.C
\*---------------------------------------------------------------------------*/
#ifndef CompatibilityConstant_H
#define CompatibilityConstant_H
#include "DataEntry.H"
#include "dimensionSet.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
template<class Type>
class CompatibilityConstant;
template<class Type>
Ostream& operator<<(Ostream&, const CompatibilityConstant<Type>&);
/*---------------------------------------------------------------------------*\
Class CompatibilityConstant Declaration
\*---------------------------------------------------------------------------*/
template<class Type>
class CompatibilityConstant
:
public DataEntry<Type>
{
// Private data
//- Constant value
Type value_;
//- The dimension set
dimensionSet dimensions_;
// Private Member Functions
//- Disallow default bitwise assignment
void operator=(const CompatibilityConstant<Type>&);
public:
// Runtime type information
TypeName("CompatibilityConstant");
// Constructors
//- Construct from entry name and Istream
CompatibilityConstant(const word& entryName, const dictionary& dict);
//- Copy constructor
CompatibilityConstant(const CompatibilityConstant<Type>& cnst);
//- Construct and return a clone
virtual tmp<DataEntry<Type>> clone() const
{
return tmp<DataEntry<Type>>
(
new CompatibilityConstant<Type>(*this)
);
}
//- Destructor
virtual ~CompatibilityConstant();
// Member Functions
//- Return constant value
Type value(const scalar) const;
//- Integrate between two values
Type integrate(const scalar x1, const scalar x2) const;
//- Return dimensioned constant value
dimensioned<Type> dimValue(const scalar) const;
//- Integrate between two values and return dimensioned type
dimensioned<Type> dimIntegrate
(
const scalar x1,
const scalar x2
) const;
// I/O
//- Ostream Operator
friend Ostream& operator<< <Type>
(
Ostream& os,
const CompatibilityConstant<Type>& cnst
);
//- Write in dictionary format
virtual void writeData(Ostream& os) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
# include "CompatibilityConstant.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -1,69 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "DataEntry.H"
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
template<class Type>
Foam::Ostream& Foam::operator<<
(
Ostream& os,
const CompatibilityConstant<Type>& cnst
)
{
if (os.format() == IOstream::ASCII)
{
os << static_cast<const DataEntry<Type>& >(cnst)
<< token::SPACE << cnst.value_;
}
else
{
os << static_cast<const DataEntry<Type>& >(cnst);
os.write
(
reinterpret_cast<const char*>(&cnst.value_),
sizeof(cnst.value_)
);
}
// Check state of Ostream
os.check
(
"Ostream& operator<<(Ostream&, const CompatibilityConstant<Type>&)"
);
return os;
}
template<class Type>
void Foam::CompatibilityConstant<Type>::writeData(Ostream& os) const
{
os.writeKeyword(this->name_) << value_ << token::END_STATEMENT << nl;
}
// ************************************************************************* //

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -31,36 +31,27 @@ template<class Type>
Foam::Constant<Type>::Constant(const word& entryName, const dictionary& dict)
:
DataEntry<Type>(entryName),
value_(pTraits<Type>::zero),
dimensions_(dimless)
value_(pTraits<Type>::zero)
{
Istream& is(dict.lookup(entryName));
word entryType(is);
token firstToken(is);
if (firstToken.isWord())
{
token nextToken(is);
if (nextToken == token::BEGIN_SQR)
{
is.putBack(nextToken);
is >> dimensions_;
is >> value_;
}
}
else
{
is.putBack(firstToken);
is >> value_;
}
is >> value_;
}
template<class Type>
Foam::Constant<Type>::Constant(const word& entryName, Istream& is)
:
DataEntry<Type>(entryName),
value_(pTraits<Type>(is))
{}
template<class Type>
Foam::Constant<Type>::Constant(const Constant<Type>& cnst)
:
DataEntry<Type>(cnst),
value_(cnst.value_),
dimensions_(cnst.dimensions_)
value_(cnst.value_)
{}
@ -87,26 +78,8 @@ Type Foam::Constant<Type>::integrate(const scalar x1, const scalar x2) const
}
template<class Type>
Foam::dimensioned<Type> Foam::Constant<Type>::dimValue(const scalar x) const
{
return dimensioned<Type>("dimensionedValue", dimensions_, value_);
}
template<class Type>
Foam::dimensioned<Type> Foam::Constant<Type>::dimIntegrate
(
const scalar x1, const scalar x2
) const
{
return dimensioned<Type>("dimensionedValue", dimensions_, (x2-x1)*value_);
}
// * * * * * * * * * * * * * * IOStream operators * * * * * * * * * * * * * //
#include "ConstantIO.C"
// ************************************************************************* //

View File

@ -41,18 +41,15 @@ SourceFiles
#define Constant_H
#include "DataEntry.H"
#include "dimensionSet.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
template<class Type>
class Constant;
template<class Type>
Ostream& operator<<(Ostream&, const Constant<Type>&);
// Forward declaration of friend functions and operators
template<class Type> class Constant;
template<class Type> Ostream& operator<<(Ostream&, const Constant<Type>&);
/*---------------------------------------------------------------------------*\
Class Constant Declaration
@ -68,9 +65,6 @@ class Constant
//- Constant value
Type value_;
//- The dimension set
dimensionSet dimensions_;
// Private Member Functions
@ -86,9 +80,14 @@ public:
// Constructors
//- Construct from entry name and Istream
//- Construct from entry name and dictionary
Constant(const word& entryName, const dictionary& dict);
//- Construct from entry name and Istream
// Reads the constant value without the DataEntry type
// for backward compatibility
Constant(const word& entryName, Istream& is);
//- Copy constructor
Constant(const Constant<Type>& cnst);
@ -111,16 +110,6 @@ public:
//- Integrate between two values
Type integrate(const scalar x1, const scalar x2) const;
//- Return dimensioned constant value
dimensioned<Type> dimValue(const scalar) const;
//- Integrate between two values and return dimensioned type
dimensioned<Type> dimIntegrate
(
const scalar x1,
const scalar x2
) const;
// I/O
@ -144,6 +133,7 @@ public:
#ifdef NoRepository
# include "Constant.C"
# include "DataEntryNew.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -34,20 +34,8 @@ Foam::Ostream& Foam::operator<<
const Constant<Type>& cnst
)
{
if (os.format() == IOstream::ASCII)
{
os << static_cast<const DataEntry<Type>& >(cnst)
<< token::SPACE << cnst.value_;
}
else
{
os << static_cast<const DataEntry<Type>& >(cnst);
os.write
(
reinterpret_cast<const char*>(&cnst.value_),
sizeof(cnst.value_)
);
}
os << static_cast<const DataEntry<Type>& >(cnst)
<< token::SPACE << cnst.value_;
// Check state of Ostream
os.check

View File

@ -120,79 +120,6 @@ Foam::tmp<Foam::Field<Type>> Foam::DataEntry<Type>::integrate
}
template<class Type>
Foam::dimensioned<Type> Foam::DataEntry<Type>::dimValue(const scalar x) const
{
NotImplemented;
return dimensioned<Type>("zero", dimless, pTraits<Type>::zero);
}
template<class Type>
Foam::dimensioned<Type> Foam::DataEntry<Type>::dimIntegrate
(
const scalar x1,
const scalar x2
) const
{
NotImplemented;
return dimensioned<Type>("zero", dimless, pTraits<Type>::zero);
}
template<class Type>
Foam::tmp<Foam::Field<Foam::dimensioned<Type>>>
Foam::DataEntry<Type>::dimValue
(
const scalarField& x
) const
{
tmp<Field<dimensioned<Type>>> tfld
(
new Field<dimensioned<Type>>
(
x.size(),
dimensioned<Type>("zero", dimless, pTraits<Type>::zero)
)
);
Field<dimensioned<Type>>& fld = tfld();
forAll(x, i)
{
fld[i] = this->dimValue(x[i]);
}
return tfld;
}
template<class Type>
Foam::tmp<Foam::Field<Foam::dimensioned<Type>>>
Foam::DataEntry<Type>::dimIntegrate
(
const scalarField& x1,
const scalarField& x2
) const
{
tmp<Field<dimensioned<Type>>> tfld
(
new Field<dimensioned<Type>>(x1.size())
);
Field<dimensioned<Type>>& fld = tfld();
forAll(x1, i)
{
fld[i] = this->dimIntegrate(x1[i], x2[i]);
}
return tfld;
}
// * * * * * * * * * * * * * * IOStream operators * * * * * * * * * * * * * //
#include "DataEntryIO.C"

View File

@ -41,23 +41,18 @@ SourceFiles
#include "dictionary.H"
#include "Field.H"
#include "dimensionedType.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// Forward declarations
class Time;
template<class Type>
class DataEntry;
template<class Type>
Ostream& operator<<
(
Ostream&,
const DataEntry<Type>&
);
// Forward declaration of friend functions and operators
template<class Type> class DataEntry;
template<class Type> Ostream& operator<<(Ostream&, const DataEntry<Type>&);
/*---------------------------------------------------------------------------*\
Class DataEntry Declaration
@ -160,30 +155,6 @@ public:
const scalarField& x2
) const;
//- Return dimensioned type
virtual dimensioned<Type> dimValue(const scalar x) const;
//- Return dimensioned type as a function of (scalar)
virtual tmp<Field<dimensioned<Type>>> dimValue
(
const scalarField& x
) const;
//- Integrate between two scalars and return a dimensioned type
virtual dimensioned<Type> dimIntegrate
(
const scalar x1,
const scalar x2
) const;
//- Integrate between two scalar fields and return a field of
// dimensioned type
virtual tmp<Field<dimensioned<Type>>> dimIntegrate
(
const scalarField& x1,
const scalarField& x2
) const;
// I/O
@ -228,7 +199,7 @@ public:
#ifdef NoRepository
# include "DataEntry.C"
# include "DataEntryNew.C"
# include "Constant.H"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -23,7 +23,7 @@ License
\*---------------------------------------------------------------------------*/
#include "DataEntry.H"
#include "Constant.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -37,24 +37,16 @@ Foam::autoPtr<Foam::DataEntry<Type>> Foam::DataEntry<Type>::New
Istream& is(dict.lookup(entryName, false));
token firstToken(is);
word DataEntryType;
if (firstToken.isWord())
if (!firstToken.isWord())
{
// Dimensioned type default compatibility
if (firstToken.wordToken() == entryName)
{
DataEntryType = "CompatibilityConstant";
}
else
{
DataEntryType = firstToken.wordToken();
}
is.putBack(firstToken);
return autoPtr<DataEntry<Type>>(new Constant<Type>(entryName, is));
}
else
{
// DataEntryType = CompatibilityConstant<Type>::typeName;
DataEntryType = "CompatibilityConstant";
DataEntryType = firstToken.wordToken();
}
typename dictionaryConstructorTable::iterator cstrIter =
@ -71,7 +63,7 @@ Foam::autoPtr<Foam::DataEntry<Type>> Foam::DataEntry<Type>::New
<< exit(FatalError);
}
return autoPtr<DataEntry<Type>>(cstrIter()(entryName, dict));
return cstrIter()(entryName, dict);
}

View File

@ -36,19 +36,11 @@ Foam::PolynomialEntry<Type>::PolynomialEntry
:
DataEntry<Type>(entryName),
coeffs_(),
canIntegrate_(true),
dimensions_(dimless)
canIntegrate_(true)
{
Istream& is(dict.lookup(entryName));
word entryType(is);
token firstToken(is);
is.putBack(firstToken);
if (firstToken == token::BEGIN_SQR)
{
is >> this->dimensions_;
}
is >> coeffs_;
if (!coeffs_.size())
@ -88,8 +80,7 @@ Foam::PolynomialEntry<Type>::PolynomialEntry
:
DataEntry<Type>(entryName),
coeffs_(coeffs),
canIntegrate_(true),
dimensions_(dimless)
canIntegrate_(true)
{
if (!coeffs_.size())
{
@ -124,8 +115,7 @@ Foam::PolynomialEntry<Type>::PolynomialEntry(const PolynomialEntry& poly)
:
DataEntry<Type>(poly),
coeffs_(poly.coeffs_),
canIntegrate_(poly.canIntegrate_),
dimensions_(poly.dimensions_)
canIntegrate_(poly.canIntegrate_)
{}
@ -208,35 +198,8 @@ Type Foam::PolynomialEntry<Type>::integrate
}
template<class Type>
Foam::dimensioned<Type> Foam::PolynomialEntry<Type>::dimValue
(
const scalar x
) const
{
return dimensioned<Type>("dimensionedValue", dimensions_, value(x));
}
template<class Type>
Foam::dimensioned<Type> Foam::PolynomialEntry<Type>::dimIntegrate
(
const scalar x1,
const scalar x2
) const
{
return dimensioned<Type>
(
"dimensionedValue",
dimensions_,
integrate(x1, x2)
);
}
// * * * * * * * * * * * * * * IOStream operators * * * * * * * * * * * * * //
#include "PolynomialEntryIO.C"
// ************************************************************************* //

View File

@ -30,7 +30,7 @@ Description
e.g. for an entry \<entryName\> that describes y = x^2 + 2x^3
\verbatim
<entryName> polynomial [0 0 1 0 0] // optional dimensions
<entryName> polynomial
(
(1 2)
(2 3)
@ -47,7 +47,6 @@ SourceFiles
#include "DataEntry.H"
#include "Tuple2.H"
#include "dimensionSet.H"
#include "DataEntryFwd.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -55,12 +54,8 @@ SourceFiles
namespace Foam
{
// Forward declaration of classes
template<class Type>
class PolynomialEntry;
// Forward declaration of friend functions
// Forward declaration of friend functions and operators
template<class Type> class PolynomialEntry;
template<class Type>
Ostream& operator<<(Ostream&, const PolynomialEntry<Type>&);
@ -81,9 +76,6 @@ class PolynomialEntry
//- Flag to indicate whether poly can be integrated
bool canIntegrate_;
//- The dimension set
dimensionSet dimensions_;
// Private Member Functions
@ -138,16 +130,6 @@ public:
//- Integrate between two (scalar) values
Type integrate(const scalar x1, const scalar x2) const;
//- Return dimensioned constant value
dimensioned<Type> dimValue(const scalar) const;
//- Integrate between two values and return dimensioned type
dimensioned<Type> dimIntegrate
(
const scalar x1,
const scalar x2
) const;
// I/O

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -34,20 +34,8 @@ Foam::Ostream& Foam::operator<<
const PolynomialEntry<Type>& poly
)
{
if (os.format() == IOstream::ASCII)
{
os << static_cast<const DataEntry<Type>& >(poly)
<< token::SPACE << poly.coeffs_;
}
else
{
os << static_cast<const DataEntry<Type>& >(poly);
os.write
(
reinterpret_cast<const char*>(&poly.coeffs_),
sizeof(poly.coeffs_)
);
}
os << static_cast<const DataEntry<Type>& >(poly)
<< token::SPACE << poly.coeffs_;
// Check state of Ostream
os.check

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -34,15 +34,7 @@ Foam::Table<Type>::Table(const word& entryName, const dictionary& dict)
{
Istream& is(dict.lookup(entryName));
word entryType(is);
token firstToken(is);
is.putBack(firstToken);
if (firstToken == token::BEGIN_SQR)
{
is >> this->dimensions_;
}
is >> this->table_;
TableBase<Type>::check();
}

View File

@ -70,8 +70,7 @@ Foam::TableBase<Type>::TableBase(const word& name, const dictionary& dict)
(
dict.lookupOrDefault<word>("interpolationScheme", "linear")
),
table_(),
dimensions_(dimless)
table_()
{}
@ -83,7 +82,6 @@ Foam::TableBase<Type>::TableBase(const TableBase<Type>& tbl)
boundsHandling_(tbl.boundsHandling_),
interpolationScheme_(tbl.interpolationScheme_),
table_(tbl.table_),
dimensions_(tbl.dimensions_),
tableSamplesPtr_(tbl.tableSamplesPtr_),
interpolatorPtr_(tbl.interpolatorPtr_)
{}
@ -369,29 +367,6 @@ Type Foam::TableBase<Type>::integrate(const scalar x1, const scalar x2) const
}
template<class Type>
Foam::dimensioned<Type> Foam::TableBase<Type>::
dimValue(const scalar x) const
{
return dimensioned<Type>("dimensionedValue", dimensions_, this->value(x));
}
template<class Type>
Foam::dimensioned<Type> Foam::TableBase<Type>::dimIntegrate
(
const scalar x1, const scalar x2
) const
{
return dimensioned<Type>
(
"dimensionedValue",
dimensions_,
this->integrate(x2, x1)
);
}
template<class Type>
Foam::tmp<Foam::scalarField> Foam::TableBase<Type>::x() const
{

View File

@ -37,7 +37,6 @@ SourceFiles
#include "DataEntry.H"
#include "Tuple2.H"
#include "dimensionSet.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -95,9 +94,6 @@ protected:
//- Table data
List<Tuple2<scalar, Type>> table_;
//- The dimension set
dimensionSet dimensions_;
//- Extracted values
mutable autoPtr<scalarField> tableSamplesPtr_;
@ -163,16 +159,6 @@ public:
//- Integrate between two (scalar) values
virtual Type integrate(const scalar x1, const scalar x2) const;
//- Return dimensioned constant value
virtual dimensioned<Type> dimValue(const scalar x) const;
//- Integrate between two values and return dimensioned type
virtual dimensioned<Type> dimIntegrate
(
const scalar x1,
const scalar x2
) const;
//- Return the reference values
virtual tmp<scalarField> x() const;

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -35,19 +35,7 @@ Foam::Ostream& Foam::operator<<
)
{
os << static_cast<const DataEntry<Type>&>(tbl);
if (os.format() == IOstream::ASCII)
{
os << token::SPACE << tbl.table_;
}
else
{
os.write
(
reinterpret_cast<const char*>(&tbl.table_),
tbl.table_.byteSize()
);
}
os << token::SPACE << tbl.table_;
// Check state of Ostream
os.check

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -36,11 +36,6 @@ Foam::TableFile<Type>::TableFile(const word& entryName, const dictionary& dict)
const dictionary coeffs(dict.subDict(entryName + "Coeffs"));
coeffs.lookup("fileName") >> fName_;
if (coeffs.found("dimensions"))
{
coeffs.lookup("dimensions") >> this->dimensions_;
}
fileName expandedFile(fName_);
IFstream is(expandedFile.expand());
@ -77,5 +72,4 @@ Foam::TableFile<Type>::~TableFile()
#include "TableFileIO.C"
// ************************************************************************* //

View File

@ -31,7 +31,6 @@ Description
<entryName> tableFile;
<entryName>Coeffs
{
dimensions [0 0 1 0 0]; // optional dimensions
fileName dataFile; // name of data file
outOfBounds clamp; // optional out-of-bounds handling
interpolationScheme linear; // optional interpolation method

View File

@ -23,11 +23,9 @@ License
\*---------------------------------------------------------------------------*/
#include "CompatibilityConstant.H"
#include "Constant.H"
#include "PolynomialEntry.H"
#include "CSV.H"
#include "DataEntry.H"
#include "Table.H"
#include "TableFile.H"
@ -41,7 +39,6 @@ License
namespace Foam
{
makeDataEntry(label);
makeDataEntryType(CompatibilityConstant, label);
makeDataEntryType(Constant, label);
// Polynomial functions and interpolation do evaluate to label
@ -52,7 +49,6 @@ namespace Foam
// makeDataEntryType(TableFile, label);
makeDataEntry(scalar);
makeDataEntryType(CompatibilityConstant, scalar);
makeDataEntryType(Constant, scalar);
makeDataEntryType(PolynomialEntry, scalar);
makeDataEntryType(CSV, scalar);
@ -60,7 +56,6 @@ namespace Foam
makeDataEntryType(TableFile, scalar);
makeDataEntry(vector);
makeDataEntryType(CompatibilityConstant, vector);
makeDataEntryType(Constant, vector);
makeDataEntryType(PolynomialEntry, vector);
makeDataEntryType(CSV, vector);
@ -68,7 +63,6 @@ namespace Foam
makeDataEntryType(TableFile, vector);
makeDataEntry(sphericalTensor);
makeDataEntryType(CompatibilityConstant, sphericalTensor);
makeDataEntryType(Constant, sphericalTensor);
makeDataEntryType(PolynomialEntry, sphericalTensor);
makeDataEntryType(CSV, sphericalTensor);
@ -76,7 +70,6 @@ namespace Foam
makeDataEntryType(TableFile, sphericalTensor);
makeDataEntry(symmTensor);
makeDataEntryType(CompatibilityConstant, symmTensor);
makeDataEntryType(Constant, symmTensor);
makeDataEntryType(PolynomialEntry, symmTensor);
makeDataEntryType(CSV, symmTensor);
@ -84,7 +77,6 @@ namespace Foam
makeDataEntryType(TableFile, symmTensor);
makeDataEntry(tensor);
makeDataEntryType(CompatibilityConstant, tensor);
makeDataEntryType(Constant, tensor);
makeDataEntryType(PolynomialEntry, tensor);
makeDataEntryType(CSV, tensor);