diff --git a/src/OpenFOAM/interpolations/interpolationTable/interpolationTable.C b/src/OpenFOAM/interpolations/interpolationTable/interpolationTable.C index e2f1f92e77..eb79f936ef 100644 --- a/src/OpenFOAM/interpolations/interpolationTable/interpolationTable.C +++ b/src/OpenFOAM/interpolations/interpolationTable/interpolationTable.C @@ -34,9 +34,8 @@ template Foam::interpolationTable::interpolationTable() : List >(), - dict_(dictionary::null), - boundAction_(interpolationTable::WARN), - fileName_("undefined_fileName") + boundsHandling_(interpolationTable::WARN), + fileName_("fileNameIsUndefined") {} @@ -48,20 +47,23 @@ Foam::interpolationTable::interpolationTable ) : List >(), - dict_(dict), - boundAction_(wordToBoundAction(dict.lookup("boundAction"))), + boundsHandling_(wordToBoundsHandling(dict.lookup("outOfBounds"))), fileName_(dict.lookup("fileName")) { - fileName_.expand(); + // preserve the original (unexpanded) fileName to avoid absolute paths + // appearing in the write() method + fileName fName(fileName_); + + fName.expand(); // Correct for relative path - if (fileName_[0] != '/') + if (fName[0] != '/') { - fileName_ = obr.db().path()/fileName_; + fName = obr.db().path()/fName; } // Read data from file - IFstream(fileName_)() >> *this; + IFstream(fName)() >> *this; // Check that the data is okay check(); @@ -71,7 +73,7 @@ Foam::interpolationTable::interpolationTable FatalErrorIn ( "Foam::interpolationTable::interpolationTable" - "(const dictionary& dict)" + "(const dictionary&)" ) << "table is empty" << nl << exit(FatalError); } @@ -85,8 +87,7 @@ Foam::interpolationTable::interpolationTable ) : List >(interpTable), - dict_(interpTable.dict_), - boundAction_(interpTable.boundAction_), + boundsHandling_(interpTable.boundsHandling_), fileName_(interpTable.fileName_) {} @@ -101,9 +102,9 @@ Foam::interpolationTable::~interpolationTable() // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // template -Foam::word Foam::interpolationTable::boundActionToWord +Foam::word Foam::interpolationTable::boundsHandlingToWord ( - const boundActions& bound + const boundsHandling& bound ) const { word enumName("warn"); @@ -137,8 +138,8 @@ Foam::word Foam::interpolationTable::boundActionToWord template -typename Foam::interpolationTable::boundActions -Foam::interpolationTable::wordToBoundAction +typename Foam::interpolationTable::boundsHandling +Foam::interpolationTable::wordToBoundsHandling ( const word& bound ) const @@ -163,8 +164,8 @@ Foam::interpolationTable::wordToBoundAction { WarningIn ( - "Foam::interpolationTable::wordToBoundAction(const word&)" - ) << "bad bounding specifier " << bound << " using 'warn'" << endl; + "Foam::interpolationTable::wordToBoundsHandling(const word&)" + ) << "bad outOfBounds specifier " << bound << " using 'warn'" << endl; return interpolationTable::WARN; } @@ -198,14 +199,14 @@ void Foam::interpolationTable::check() const template -typename Foam::interpolationTable::boundActions -Foam::interpolationTable::boundAction +typename Foam::interpolationTable::boundsHandling +Foam::interpolationTable::outOfBounds ( - const boundActions& bound + const boundsHandling& bound ) { - boundActions prev = boundAction_; - boundAction_ = bound; + boundsHandling prev = boundsHandling_; + boundsHandling_ = bound; return prev; } @@ -215,8 +216,8 @@ void Foam::interpolationTable::write(Ostream& os) const { os.writeKeyword("fileName") << fileName_ << token::END_STATEMENT << nl; - os.writeKeyword("boundAction") - << boundActionToWord(boundAction_) << token::END_STATEMENT << nl; + os.writeKeyword("outOfBounds") + << boundsHandlingToWord(boundsHandling_) << token::END_STATEMENT << nl; } @@ -235,7 +236,7 @@ Foam::interpolationTable::operator[](const label i) const } else if (ii < 0) { - switch (boundAction_) + switch (boundsHandling_) { case interpolationTable::ERROR: { @@ -275,7 +276,7 @@ Foam::interpolationTable::operator[](const label i) const } else if (ii >= n) { - switch (boundAction_) + switch (boundsHandling_) { case interpolationTable::ERROR: { @@ -334,7 +335,7 @@ Type Foam::interpolationTable::operator()(const scalar value) const if (lookupValue < minLimit) { - switch (boundAction_) + switch (boundsHandling_) { case interpolationTable::ERROR: { @@ -375,7 +376,7 @@ Type Foam::interpolationTable::operator()(const scalar value) const } else if (lookupValue >= maxLimit) { - switch (boundAction_) + switch (boundsHandling_) { case interpolationTable::ERROR: { @@ -478,5 +479,4 @@ Type Foam::interpolationTable::operator()(const scalar value) const } } - // ************************************************************************* // diff --git a/src/OpenFOAM/interpolations/interpolationTable/interpolationTable.H b/src/OpenFOAM/interpolations/interpolationTable/interpolationTable.H index 207e19f91c..c60121bb88 100644 --- a/src/OpenFOAM/interpolations/interpolationTable/interpolationTable.H +++ b/src/OpenFOAM/interpolations/interpolationTable/interpolationTable.H @@ -27,16 +27,16 @@ Class Description A list of times and values. - The time values must be positive and monotonically increasing. + The time values must be positive monotonically increasing. - The treatment of out-of-bounds values depends on the current setting - of bounding. + The handling of out-of-bounds values depends on the current setting + of @a outOfBounds. - If @a REPEAT bounding is in effect, the final time value is treated - as being equivalent to time=0 for the following periods. + If @a REPEAT is chosen for the out-of-bounds handling, the final time + value is treated as being equivalent to time=0 for the following periods. Note - - Accessing an empty list will result in an error. + - Accessing an empty list results in an error. - Accessing a list with a single element will always return the same value. SourceFiles @@ -58,7 +58,7 @@ namespace Foam class objectRegistry; /*---------------------------------------------------------------------------*\ - Class interpolationTable Declaration + Class interpolationTable Declaration \*---------------------------------------------------------------------------*/ template @@ -71,7 +71,7 @@ public: // Public data types //- Enumeration for handling out-of-bound values - enum boundActions + enum boundsHandling { ERROR, /*!< Exit with a FatalError */ WARN, /*!< Issue warning and clamp value (default) */ @@ -84,11 +84,8 @@ private: // Private data - //- Parent dictionary - const dictionary& dict_; - //- Enumeration for handling out-of-bound values - boundActions boundAction_; + boundsHandling boundsHandling_; //- File name fileName fileName_; @@ -122,11 +119,11 @@ public: return List >::size(); } - //- Return the out-of-bounds treatment as a word - word boundActionToWord(const boundActions& bound) const; + //- Return the out-of-bounds handling as a word + word boundsHandlingToWord(const boundsHandling& bound) const; - //- Return the out-of-bounds treatment as an enumeration - boundActions wordToBoundAction(const word& bound) const; + //- Return the out-of-bounds handling as an enumeration + boundsHandling wordToBoundsHandling(const word& bound) const; // Check @@ -138,9 +135,9 @@ public: // Edit - //- Set the out-of-bounds treatment from enum, return previous - // setting - boundActions boundAction(const boundActions& bound); + //- Set the out-of-bounds handling from enum, + // return previous setting + boundsHandling outOfBounds(const boundsHandling& bound); // Member Operators