Added new constructor from fileName to interpolationTable and

removed the objectRegistry argument from the constructor from
dictionary.  Now case-relative paths should be specified using
$FOAM_CASE.
This commit is contained in:
henry
2008-07-08 16:25:00 +01:00
parent e3ee5fcf37
commit 4a68c38ec4
5 changed files with 83 additions and 103 deletions

View File

@ -26,40 +26,14 @@ License
#include "interpolationTable.H" #include "interpolationTable.H"
#include "IFstream.H" #include "IFstream.H"
#include "objectRegistry.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
template<class Type> template<class Type>
Foam::interpolationTable<Type>::interpolationTable() void Foam::interpolationTable<Type>::readTable()
:
List<Tuple2<scalar, Type> >(),
dict_(dictionary::null),
boundAction_(interpolationTable::WARN),
fileName_("undefined_fileName")
{}
template<class Type>
Foam::interpolationTable<Type>::interpolationTable
(
const objectRegistry& obr,
const dictionary& dict
)
:
List<Tuple2<scalar, Type> >(),
dict_(dict),
boundAction_(wordToBoundAction(dict.lookup("boundAction"))),
fileName_(dict.lookup("fileName"))
{ {
fileName_.expand(); fileName_.expand();
// Correct for relative path
if (fileName_[0] != '/')
{
fileName_ = obr.db().path()/fileName_;
}
// Read data from file // Read data from file
IFstream(fileName_)() >> *this; IFstream(fileName_)() >> *this;
@ -78,6 +52,39 @@ Foam::interpolationTable<Type>::interpolationTable
} }
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class Type>
Foam::interpolationTable<Type>::interpolationTable()
:
List<Tuple2<scalar, Type> >(),
boundAction_(interpolationTable::WARN),
fileName_("undefined_fileName")
{}
template<class Type>
Foam::interpolationTable<Type>::interpolationTable(const fileName& fn)
:
List<Tuple2<scalar, Type> >(),
boundAction_(interpolationTable::WARN),
fileName_(fn)
{
readTable();
}
template<class Type>
Foam::interpolationTable<Type>::interpolationTable(const dictionary& dict)
:
List<Tuple2<scalar, Type> >(),
boundAction_(wordToBoundAction(dict.lookup("boundAction"))),
fileName_(dict.lookup("fileName"))
{
readTable();
}
template<class Type> template<class Type>
Foam::interpolationTable<Type>::interpolationTable Foam::interpolationTable<Type>::interpolationTable
( (
@ -85,18 +92,11 @@ Foam::interpolationTable<Type>::interpolationTable
) )
: :
List<Tuple2<scalar, Type> >(interpTable), List<Tuple2<scalar, Type> >(interpTable),
dict_(interpTable.dict_),
boundAction_(interpTable.boundAction_), boundAction_(interpTable.boundAction_),
fileName_(interpTable.fileName_) fileName_(interpTable.fileName_)
{} {}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
template<class Type>
Foam::interpolationTable<Type>::~interpolationTable()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
@ -174,7 +174,7 @@ Foam::interpolationTable<Type>::wordToBoundAction
template<class Type> template<class Type>
void Foam::interpolationTable<Type>::check() const void Foam::interpolationTable<Type>::check() const
{ {
label n = size(); label n = this->size();
scalar prevValue = List<Tuple2<scalar, Type> >::operator[](0).first(); scalar prevValue = List<Tuple2<scalar, Type> >::operator[](0).first();
for (label i=1; i<n; ++i) for (label i=1; i<n; ++i)
@ -227,7 +227,7 @@ const Foam::Tuple2<Foam::scalar, Type>&
Foam::interpolationTable<Type>::operator[](const label i) const Foam::interpolationTable<Type>::operator[](const label i) const
{ {
label ii = i; label ii = i;
label n = size(); label n = this->size();
if (n <= 1) if (n <= 1)
{ {
@ -321,7 +321,7 @@ Foam::interpolationTable<Type>::operator[](const label i) const
template<class Type> template<class Type>
Type Foam::interpolationTable<Type>::operator()(const scalar value) const Type Foam::interpolationTable<Type>::operator()(const scalar value) const
{ {
label n = size(); label n = this->size();
if (n <= 1) if (n <= 1)
{ {

View File

@ -84,9 +84,6 @@ private:
// Private data // Private data
//- Parent dictionary
const dictionary& dict_;
//- Enumeration for handling out-of-bound values //- Enumeration for handling out-of-bound values
boundActions boundAction_; boundActions boundAction_;
@ -94,6 +91,12 @@ private:
fileName fileName_; fileName fileName_;
// Private Member Functions
//- Read the table of data from file
void readTable();
public: public:
// Constructors // Constructors
@ -101,61 +104,45 @@ public:
//- Construct null //- Construct null
interpolationTable(); interpolationTable();
//- Construct from objectRegistry and dictionary //- Construct given the name of the file containing the table of data
interpolationTable(const objectRegistry& obr, const dictionary& dict); interpolationTable(const fileName& fn);
//- Construct by reading the fileName and boundAction from dictionary
// and read the table from that file.
// This is a specialised constructor used by patchFields
interpolationTable(const dictionary& dict);
//- Construct copy //- Construct copy
interpolationTable(const interpolationTable& interpTable); interpolationTable(const interpolationTable& interpTable);
//- Destructor
~interpolationTable();
// Member Functions // Member Functions
// Access //- Return the out-of-bounds treatment as a word
word boundActionToWord(const boundActions& bound) const;
//- Return the size //- Return the out-of-bounds treatment as an enumeration
label size() const boundActions wordToBoundAction(const word& bound) const;
{
return List<Tuple2<scalar, Type> >::size();
}
//- Return the out-of-bounds treatment as a word //- Check that list is monotonically increasing
word boundActionToWord(const boundActions& bound) const; // Exit with a FatalError if there is a problem
void check() const;
//- Return the out-of-bounds treatment as an enumeration //- Set the out-of-bounds treatment from enum, return previous
boundActions wordToBoundAction(const word& bound) const; // setting
boundActions boundAction(const boundActions& bound);
//- Write
void write(Ostream& os) const;
// Check // Member Operators
//- Check that list is monotonically increasing //- Return an element of constant Tuple2<scalar, Type>
// Exit with a FatalError if there is a problem const Tuple2<scalar, Type>& operator[](const label) const;
void check() const;
//- Return an interpolated value
// Edit Type operator()(const scalar) const;
//- Set the out-of-bounds treatment from enum, return previous
// setting
boundActions boundAction(const boundActions& bound);
// Member Operators
//- Return an element of constant Tuple2<scalar, Type>
const Tuple2<scalar, Type>& operator[](const label) const;
//- Return an interpolated value
Type operator()(const scalar) const;
// I-O
//- Write
void write(Ostream& os) const;
}; };
@ -169,6 +156,8 @@ public:
# include "interpolationTable.C" # include "interpolationTable.C"
#endif #endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif #endif
// ************************************************************************* // // ************************************************************************* //

View File

@ -30,12 +30,10 @@ License
#include "fvPatchFieldMapper.H" #include "fvPatchFieldMapper.H"
#include "surfaceFields.H" #include "surfaceFields.H"
#include "Time.H" #include "Time.H"
#include "IFstream.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam:: Foam::timeVaryingFlowRateInletVelocityFvPatchVectorField::
timeVaryingFlowRateInletVelocityFvPatchVectorField::
timeVaryingFlowRateInletVelocityFvPatchVectorField timeVaryingFlowRateInletVelocityFvPatchVectorField
( (
const fvPatch& p, const fvPatch& p,
@ -47,8 +45,7 @@ timeVaryingFlowRateInletVelocityFvPatchVectorField
{} {}
Foam:: Foam::timeVaryingFlowRateInletVelocityFvPatchVectorField::
timeVaryingFlowRateInletVelocityFvPatchVectorField::
timeVaryingFlowRateInletVelocityFvPatchVectorField timeVaryingFlowRateInletVelocityFvPatchVectorField
( (
const timeVaryingFlowRateInletVelocityFvPatchVectorField& ptf, const timeVaryingFlowRateInletVelocityFvPatchVectorField& ptf,
@ -62,8 +59,7 @@ timeVaryingFlowRateInletVelocityFvPatchVectorField
{} {}
Foam:: Foam::timeVaryingFlowRateInletVelocityFvPatchVectorField::
timeVaryingFlowRateInletVelocityFvPatchVectorField::
timeVaryingFlowRateInletVelocityFvPatchVectorField timeVaryingFlowRateInletVelocityFvPatchVectorField
( (
const fvPatch& p, const fvPatch& p,
@ -72,12 +68,11 @@ timeVaryingFlowRateInletVelocityFvPatchVectorField
) )
: :
flowRateInletVelocityFvPatchVectorField(p, iF, dict), flowRateInletVelocityFvPatchVectorField(p, iF, dict),
timeSeries_(this->db(), dict) timeSeries_(dict)
{} {}
Foam:: Foam::timeVaryingFlowRateInletVelocityFvPatchVectorField::
timeVaryingFlowRateInletVelocityFvPatchVectorField::
timeVaryingFlowRateInletVelocityFvPatchVectorField timeVaryingFlowRateInletVelocityFvPatchVectorField
( (
const timeVaryingFlowRateInletVelocityFvPatchVectorField& ptf const timeVaryingFlowRateInletVelocityFvPatchVectorField& ptf
@ -88,8 +83,7 @@ timeVaryingFlowRateInletVelocityFvPatchVectorField
{} {}
Foam:: Foam::timeVaryingFlowRateInletVelocityFvPatchVectorField::
timeVaryingFlowRateInletVelocityFvPatchVectorField::
timeVaryingFlowRateInletVelocityFvPatchVectorField timeVaryingFlowRateInletVelocityFvPatchVectorField
( (
const timeVaryingFlowRateInletVelocityFvPatchVectorField& ptf, const timeVaryingFlowRateInletVelocityFvPatchVectorField& ptf,
@ -103,8 +97,7 @@ timeVaryingFlowRateInletVelocityFvPatchVectorField
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam:: void Foam::timeVaryingFlowRateInletVelocityFvPatchVectorField::
timeVaryingFlowRateInletVelocityFvPatchVectorField::
updateCoeffs() updateCoeffs()
{ {
if (updated()) if (updated())
@ -117,8 +110,7 @@ updateCoeffs()
} }
void Foam:: void Foam::timeVaryingFlowRateInletVelocityFvPatchVectorField::
timeVaryingFlowRateInletVelocityFvPatchVectorField::
write(Ostream& os) const write(Ostream& os) const
{ {
flowRateInletVelocityFvPatchVectorField::write(os); flowRateInletVelocityFvPatchVectorField::write(os);

View File

@ -26,7 +26,6 @@ License
#include "timeVaryingUniformFixedValueFvPatchField.H" #include "timeVaryingUniformFixedValueFvPatchField.H"
#include "Time.H" #include "Time.H"
#include "IFstream.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
@ -53,7 +52,7 @@ timeVaryingUniformFixedValueFvPatchField
) )
: :
fixedValueFvPatchField<Type>(p, iF), fixedValueFvPatchField<Type>(p, iF),
timeSeries_(this->db(), dict) timeSeries_(dict)
{ {
if (dict.found("value")) if (dict.found("value"))
{ {

View File

@ -29,7 +29,6 @@ License
#include "fvPatchFieldMapper.H" #include "fvPatchFieldMapper.H"
#include "volFields.H" #include "volFields.H"
#include "surfaceFields.H" #include "surfaceFields.H"
#include "IFstream.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
@ -66,7 +65,7 @@ timeVaryingUniformTotalPressureFvPatchScalarField
psiName_(dict.lookup("psi")), psiName_(dict.lookup("psi")),
gamma_(readScalar(dict.lookup("gamma"))), gamma_(readScalar(dict.lookup("gamma"))),
p0_(readScalar(dict.lookup("p0"))), p0_(readScalar(dict.lookup("p0"))),
totalPressureTimeSeries_(this->db(), dict) totalPressureTimeSeries_(dict)
{ {
if (dict.found("value")) if (dict.found("value"))
{ {
@ -215,7 +214,8 @@ void Foam::timeVaryingUniformTotalPressureFvPatchScalarField::updateCoeffs()
} }
void Foam::timeVaryingUniformTotalPressureFvPatchScalarField::write(Ostream& os) const void Foam::timeVaryingUniformTotalPressureFvPatchScalarField::
write(Ostream& os) const
{ {
fvPatchScalarField::write(os); fvPatchScalarField::write(os);
os.writeKeyword("U") << UName_ << token::END_STATEMENT << nl; os.writeKeyword("U") << UName_ << token::END_STATEMENT << nl;