diff --git a/src/OpenFOAM/db/functionObjects/functionObjectList/functionObjectList.C b/src/OpenFOAM/db/functionObjects/functionObjectList/functionObjectList.C index 30bfd63210..94ba5eb6bc 100644 --- a/src/OpenFOAM/db/functionObjects/functionObjectList/functionObjectList.C +++ b/src/OpenFOAM/db/functionObjects/functionObjectList/functionObjectList.C @@ -67,6 +67,25 @@ void Foam::functionObjectList::createStateDict() const } +void Foam::functionObjectList::createOutputRegistry() const +{ + objectsRegistryPtr_.reset + ( + new objectRegistry + ( + IOobject + ( + "functionObjectObjects", + time_.timeName(), + time_, + IOobject::NO_READ, + IOobject::NO_WRITE + ) + ) + ); +} + + Foam::autoPtr Foam::functionObjectList::remove ( const word& key, @@ -339,6 +358,7 @@ Foam::functionObjectList::functionObjectList time_(runTime), parentDict_(runTime.controlDict()), stateDictPtr_(), + objectsRegistryPtr_(), execution_(execution), updated_(false) {} @@ -357,6 +377,7 @@ Foam::functionObjectList::functionObjectList time_(runTime), parentDict_(parentDict), stateDictPtr_(), + objectsRegistryPtr_(), execution_(execution), updated_(false) {} @@ -491,6 +512,28 @@ const Foam::IOdictionary& Foam::functionObjectList::stateDict() const } +Foam::objectRegistry& Foam::functionObjectList::storedObjects() +{ + if (!objectsRegistryPtr_.valid()) + { + createOutputRegistry(); + } + + return *objectsRegistryPtr_; +} + + +const Foam::objectRegistry& Foam::functionObjectList::storedObjects() const +{ + if (!objectsRegistryPtr_.valid()) + { + createOutputRegistry(); + } + + return *objectsRegistryPtr_; +} + + void Foam::functionObjectList::clear() { PtrList::clear(); diff --git a/src/OpenFOAM/db/functionObjects/functionObjectList/functionObjectList.H b/src/OpenFOAM/db/functionObjects/functionObjectList/functionObjectList.H index 872bc02bbe..232d04f1a5 100644 --- a/src/OpenFOAM/db/functionObjects/functionObjectList/functionObjectList.H +++ b/src/OpenFOAM/db/functionObjects/functionObjectList/functionObjectList.H @@ -84,6 +84,9 @@ class functionObjectList //- Function object properties - stores state information mutable autoPtr stateDictPtr_; + //- Function objects output registry + mutable autoPtr objectsRegistryPtr_; + //- Switch for the execution of the functionObjects bool execution_; @@ -102,6 +105,9 @@ class functionObjectList //- Create state dictionary - attached to Time. void createStateDict() const; + //- Create registry for output objects - attached to Time. + void createOutputRegistry() const; + //- Remove and return the function object pointer by name, //- and returns the old index (into digest) via the parameter. // Returns nullptr (and index -1) if it didn't exist @@ -188,11 +194,21 @@ public: void resetState(); //- Write access to the state dictionary ("functionObjectProperties") + //- registered on Time IOdictionary& stateDict(); //- Const access to the state dictionary ("functionObjectProperties") + //- registered on Time const IOdictionary& stateDict() const; + //- Write access to the output objects ("functionObjectObjects") + //- registered on Time + objectRegistry& storedObjects(); + + //- Const access to the output objects ("functionObjectObjects") + //- registered on Time + const objectRegistry& storedObjects() const; + //- Clear the list of function objects void clear(); diff --git a/src/OpenFOAM/db/functionObjects/timeFunctionObject/timeFunctionObject.C b/src/OpenFOAM/db/functionObjects/timeFunctionObject/timeFunctionObject.C index cecb3c930e..08daa28fc4 100644 --- a/src/OpenFOAM/db/functionObjects/timeFunctionObject/timeFunctionObject.C +++ b/src/OpenFOAM/db/functionObjects/timeFunctionObject/timeFunctionObject.C @@ -39,4 +39,20 @@ Foam::functionObjects::timeFunctionObject::timeFunctionObject {} +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +Foam::objectRegistry& +Foam::functionObjects::timeFunctionObject::storedObjects() +{ + return const_cast(time_).functionObjects().storedObjects(); +} + + +const Foam::objectRegistry& +Foam::functionObjects::timeFunctionObject::storedObjects() const +{ + return time_.functionObjects().storedObjects(); +} + + // ************************************************************************* // diff --git a/src/OpenFOAM/db/functionObjects/timeFunctionObject/timeFunctionObject.H b/src/OpenFOAM/db/functionObjects/timeFunctionObject/timeFunctionObject.H index 1577fb1f9d..90e3bcfc4e 100644 --- a/src/OpenFOAM/db/functionObjects/timeFunctionObject/timeFunctionObject.H +++ b/src/OpenFOAM/db/functionObjects/timeFunctionObject/timeFunctionObject.H @@ -92,6 +92,14 @@ public: { return time_; } + + //- Write access to the output objects ("functionObjectObjects") + //- registered on Time + objectRegistry& storedObjects(); + + //- Const access to the output objects ("functionObjectObjects") + //- registered on Time + const objectRegistry& storedObjects() const; };