mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: add support for an output object registry for function objects
This commit is contained in:
@ -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::functionObject> 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<functionObject>::clear();
|
||||
|
||||
@ -84,6 +84,9 @@ class functionObjectList
|
||||
//- Function object properties - stores state information
|
||||
mutable autoPtr<IOdictionary> stateDictPtr_;
|
||||
|
||||
//- Function objects output registry
|
||||
mutable autoPtr<objectRegistry> 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();
|
||||
|
||||
|
||||
@ -39,4 +39,20 @@ Foam::functionObjects::timeFunctionObject::timeFunctionObject
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
Foam::objectRegistry&
|
||||
Foam::functionObjects::timeFunctionObject::storedObjects()
|
||||
{
|
||||
return const_cast<Time&>(time_).functionObjects().storedObjects();
|
||||
}
|
||||
|
||||
|
||||
const Foam::objectRegistry&
|
||||
Foam::functionObjects::timeFunctionObject::storedObjects() const
|
||||
{
|
||||
return time_.functionObjects().storedObjects();
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -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;
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user