From b5a1f093215caf808713be4e9c506e0b8972fddf Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Thu, 12 Feb 2009 10:51:30 +0100 Subject: [PATCH 01/10] functionObjectList with SHA1Digest tracking --- .../execFlowFunctionObjects.C | 2 +- .../db/functionObject/functionObject.C | 14 ++--- .../db/functionObject/functionObject.H | 4 +- .../functionObjectList/functionObjectList.C | 63 ++++++++++++++----- .../functionObjectList/functionObjectList.H | 31 +++++---- 5 files changed, 74 insertions(+), 40 deletions(-) diff --git a/applications/utilities/postProcessing/miscellaneous/execFlowFunctionObjects/execFlowFunctionObjects.C b/applications/utilities/postProcessing/miscellaneous/execFlowFunctionObjects/execFlowFunctionObjects.C index 3132872c03..45faede694 100644 --- a/applications/utilities/postProcessing/miscellaneous/execFlowFunctionObjects/execFlowFunctionObjects.C +++ b/applications/utilities/postProcessing/miscellaneous/execFlowFunctionObjects/execFlowFunctionObjects.C @@ -74,7 +74,7 @@ namespace Foam } else { - functionObjectList fol(runTime, runTime.controlDict()); + functionObjectList fol(runTime); fol.start(); fol.execute(); } diff --git a/src/OpenFOAM/db/functionObject/functionObject.C b/src/OpenFOAM/db/functionObject/functionObject.C index c7eb279303..5fb128a327 100644 --- a/src/OpenFOAM/db/functionObject/functionObject.C +++ b/src/OpenFOAM/db/functionObject/functionObject.C @@ -71,10 +71,10 @@ Foam::autoPtr Foam::functionObject::New FatalErrorIn ( "functionObject::New" - "(const word& functionType, const Time&, const dictionary&)" + "(const word& name, const Time&, const dictionary&)" ) << "Unknown function type " - << functionType << endl << endl - << "Table of functionObjects is empty" + << functionType << nl << nl + << "Table of functionObjects is empty" << endl << exit(FatalError); } @@ -86,11 +86,11 @@ Foam::autoPtr Foam::functionObject::New FatalErrorIn ( "functionObject::New" - "(const word& functionType, const Time&, const dictionary&)" + "(const word& name, const Time&, const dictionary&)" ) << "Unknown function type " - << functionType << endl << endl - << "Valid functions are : " << endl - << dictionaryConstructorTablePtr_->toc() + << functionType << nl << nl + << "Valid functions are : " << nl + << dictionaryConstructorTablePtr_->toc() << endl << exit(FatalError); } diff --git a/src/OpenFOAM/db/functionObject/functionObject.H b/src/OpenFOAM/db/functionObject/functionObject.H index 72bf1b166c..30d0c9caf0 100644 --- a/src/OpenFOAM/db/functionObject/functionObject.H +++ b/src/OpenFOAM/db/functionObject/functionObject.H @@ -121,7 +121,7 @@ public: // Selectors - //- Select from Time and Istream + //- Select from dictionary, based on its "type" entry static autoPtr New ( const word& name, @@ -143,7 +143,7 @@ public: //- execute is called at each ++ or += of the time-loop virtual bool execute() = 0; - //- Read and set the function object if its data has changed + //- Read and set the function object if its data have changed virtual bool read(const dictionary& dict) = 0; }; diff --git a/src/OpenFOAM/db/functionObjectList/functionObjectList.C b/src/OpenFOAM/db/functionObjectList/functionObjectList.C index 00f6131547..6f014d7859 100644 --- a/src/OpenFOAM/db/functionObjectList/functionObjectList.C +++ b/src/OpenFOAM/db/functionObjectList/functionObjectList.C @@ -29,7 +29,8 @@ License // * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * // -Foam::functionObject* Foam::functionObjectList::remove(const word& key) +Foam::functionObject* +Foam::functionObjectList::remove(const word& key, label& oldIndex) { functionObject* ptr = 0; @@ -38,10 +39,16 @@ Foam::functionObject* Foam::functionObjectList::remove(const word& key) if (fnd != indices_.end()) { - // remove the pointer from the old list - ptr = functions_.set(fnd(), 0).ptr(); + oldIndex = fnd(); + + // retrieve the pointer and remove it from the old list + ptr = this->set(oldIndex, 0).ptr(); indices_.erase(fnd); } + else + { + oldIndex = -1; + } return ptr; } @@ -55,7 +62,8 @@ Foam::functionObjectList::functionObjectList const bool execution ) : - functions_(), + PtrList(), + digests_(), indices_(), time_(t), parentDict_(t.controlDict()), @@ -71,7 +79,8 @@ Foam::functionObjectList::functionObjectList const bool execution ) : - functions_(), + PtrList(), + digests_(), indices_(), time_(t), parentDict_(parentDict), @@ -105,7 +114,7 @@ bool Foam::functionObjectList::execute() read(); } - forAllIter(PtrList, functions_, iter) + forAllIter(PtrList, *this, iter) { ok = iter().execute() && ok; } @@ -123,7 +132,8 @@ void Foam::functionObjectList::on() void Foam::functionObjectList::off() { - execution_ = false; + // for safety, also force a read() when execution is turned back on + updated_ = execution_ = false; } @@ -143,15 +153,19 @@ bool Foam::functionObjectList::read() if (entryPtr) { PtrList newPtrs; + List newDigs; HashTable