mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: Added state dictionary to functionObjectList
Note: added as a pointer since the list operates in multiple modes, e.g. as constructed by the Time database and 'outside' by execFlowFunctionObjects
This commit is contained in:
@ -2,8 +2,8 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation | Copyright (C) 2011-2014 OpenCFD Ltd
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -29,6 +29,28 @@ License
|
|||||||
|
|
||||||
// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
|
// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
void Foam::functionObjectList::createStateDict() const
|
||||||
|
{
|
||||||
|
// Cannot set the state dictionary on construction since Time has not
|
||||||
|
// been fully initialised
|
||||||
|
stateDictPtr_.reset
|
||||||
|
(
|
||||||
|
new IOdictionary
|
||||||
|
(
|
||||||
|
IOobject
|
||||||
|
(
|
||||||
|
"functionObjectProperties",
|
||||||
|
time_.timeName(),
|
||||||
|
"uniform"/word("functionObjects"),
|
||||||
|
time_,
|
||||||
|
IOobject::READ_IF_PRESENT,
|
||||||
|
IOobject::NO_WRITE
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Foam::functionObject* Foam::functionObjectList::remove
|
Foam::functionObject* Foam::functionObjectList::remove
|
||||||
(
|
(
|
||||||
const word& key,
|
const word& key,
|
||||||
@ -70,6 +92,7 @@ Foam::functionObjectList::functionObjectList
|
|||||||
indices_(),
|
indices_(),
|
||||||
time_(t),
|
time_(t),
|
||||||
parentDict_(t.controlDict()),
|
parentDict_(t.controlDict()),
|
||||||
|
stateDictPtr_(),
|
||||||
execution_(execution),
|
execution_(execution),
|
||||||
updated_(false)
|
updated_(false)
|
||||||
{}
|
{}
|
||||||
@ -87,6 +110,7 @@ Foam::functionObjectList::functionObjectList
|
|||||||
indices_(),
|
indices_(),
|
||||||
time_(t),
|
time_(t),
|
||||||
parentDict_(parentDict),
|
parentDict_(parentDict),
|
||||||
|
stateDictPtr_(),
|
||||||
execution_(execution),
|
execution_(execution),
|
||||||
updated_(false)
|
updated_(false)
|
||||||
{}
|
{}
|
||||||
@ -100,6 +124,28 @@ Foam::functionObjectList::~functionObjectList()
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::IOdictionary& Foam::functionObjectList::stateDict()
|
||||||
|
{
|
||||||
|
if (!stateDictPtr_.valid())
|
||||||
|
{
|
||||||
|
createStateDict();
|
||||||
|
}
|
||||||
|
|
||||||
|
return stateDictPtr_();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const Foam::IOdictionary& Foam::functionObjectList::stateDict() const
|
||||||
|
{
|
||||||
|
if (!stateDictPtr_.valid())
|
||||||
|
{
|
||||||
|
createStateDict();
|
||||||
|
}
|
||||||
|
|
||||||
|
return stateDictPtr_();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void Foam::functionObjectList::clear()
|
void Foam::functionObjectList::clear()
|
||||||
{
|
{
|
||||||
PtrList<functionObject>::clear();
|
PtrList<functionObject>::clear();
|
||||||
@ -165,6 +211,22 @@ bool Foam::functionObjectList::execute(const bool forceWrite)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Force writing of state dictionary after function object execution
|
||||||
|
if (time_.outputTime())
|
||||||
|
{
|
||||||
|
label oldPrecision = IOstream::precision_;
|
||||||
|
IOstream::precision_ = 16;
|
||||||
|
|
||||||
|
stateDictPtr_->writeObject
|
||||||
|
(
|
||||||
|
IOstream::ASCII,
|
||||||
|
IOstream::currentVersion,
|
||||||
|
time_.writeCompression()
|
||||||
|
);
|
||||||
|
|
||||||
|
IOstream::precision_ = oldPrecision;
|
||||||
|
}
|
||||||
|
|
||||||
return ok;
|
return ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -234,6 +296,11 @@ bool Foam::functionObjectList::adjustTimeStep()
|
|||||||
|
|
||||||
bool Foam::functionObjectList::read()
|
bool Foam::functionObjectList::read()
|
||||||
{
|
{
|
||||||
|
if (!stateDictPtr_.valid())
|
||||||
|
{
|
||||||
|
createStateDict();
|
||||||
|
}
|
||||||
|
|
||||||
bool ok = true;
|
bool ok = true;
|
||||||
updated_ = execution_;
|
updated_ = execution_;
|
||||||
|
|
||||||
|
|||||||
@ -2,8 +2,8 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -43,6 +43,7 @@ SourceFiles
|
|||||||
#include "functionObject.H"
|
#include "functionObject.H"
|
||||||
#include "SHA1Digest.H"
|
#include "SHA1Digest.H"
|
||||||
#include "HashTable.H"
|
#include "HashTable.H"
|
||||||
|
#include "IOdictionary.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
@ -74,6 +75,9 @@ class functionObjectList
|
|||||||
// functionObject specifications.
|
// functionObject specifications.
|
||||||
const dictionary& parentDict_;
|
const dictionary& parentDict_;
|
||||||
|
|
||||||
|
//- Function object properties - stores state information
|
||||||
|
mutable autoPtr<IOdictionary> stateDictPtr_;
|
||||||
|
|
||||||
//- Switch for the execution of the functionObjects
|
//- Switch for the execution of the functionObjects
|
||||||
bool execution_;
|
bool execution_;
|
||||||
|
|
||||||
@ -83,6 +87,9 @@ class functionObjectList
|
|||||||
|
|
||||||
// Private Member Functions
|
// Private Member Functions
|
||||||
|
|
||||||
|
//- Create state dictionary
|
||||||
|
void createStateDict() const;
|
||||||
|
|
||||||
//- Remove and return the function object pointer by name,
|
//- Remove and return the function object pointer by name,
|
||||||
// and returns the old index via the parameter.
|
// and returns the old index via the parameter.
|
||||||
// Returns a NULL pointer (and index -1) if it didn't exist.
|
// Returns a NULL pointer (and index -1) if it didn't exist.
|
||||||
@ -136,6 +143,12 @@ public:
|
|||||||
//- Access to the functionObjects
|
//- Access to the functionObjects
|
||||||
using PtrList<functionObject>::operator[];
|
using PtrList<functionObject>::operator[];
|
||||||
|
|
||||||
|
//- Return the state dictionary
|
||||||
|
IOdictionary& stateDict();
|
||||||
|
|
||||||
|
//- Return const access to the state dictionary
|
||||||
|
const IOdictionary& stateDict() const;
|
||||||
|
|
||||||
//- Clear the list of function objects
|
//- Clear the list of function objects
|
||||||
virtual void clear();
|
virtual void clear();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user