mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
BUG: functionObjectState required update when accessed via execFlowFunctionObjects- fixes #54
This commit is contained in:
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2015 OpenFOAM Foundation
|
||||
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
|
||||
\\/ M anipulation | Copyright (C) 2015-2016 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -28,6 +28,19 @@ License
|
||||
|
||||
const Foam::word Foam::functionObjectState::resultsName_ = "results";
|
||||
|
||||
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
|
||||
|
||||
const Foam::IOdictionary& Foam::functionObjectState::stateDict() const
|
||||
{
|
||||
return obr_.time().functionObjects().stateDict();
|
||||
}
|
||||
|
||||
|
||||
Foam::IOdictionary& Foam::functionObjectState::stateDict()
|
||||
{
|
||||
return const_cast<IOdictionary&>(obr_.time().functionObjects().stateDict());
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
@ -39,11 +52,7 @@ Foam::functionObjectState::functionObjectState
|
||||
:
|
||||
obr_(obr),
|
||||
name_(name),
|
||||
active_(true),
|
||||
stateDict_
|
||||
(
|
||||
const_cast<IOdictionary&>(obr.time().functionObjects().stateDict())
|
||||
)
|
||||
active_(true)
|
||||
{}
|
||||
|
||||
|
||||
@ -67,28 +76,26 @@ bool Foam::functionObjectState::active() const
|
||||
}
|
||||
|
||||
|
||||
const Foam::IOdictionary& Foam::functionObjectState::stateDict() const
|
||||
{
|
||||
return stateDict_;
|
||||
}
|
||||
|
||||
|
||||
Foam::dictionary& Foam::functionObjectState::propertyDict()
|
||||
{
|
||||
if (!stateDict_.found(name_))
|
||||
IOdictionary& stateDict = this->stateDict();
|
||||
|
||||
if (!stateDict.found(name_))
|
||||
{
|
||||
stateDict_.add(name_, dictionary());
|
||||
stateDict.add(name_, dictionary());
|
||||
}
|
||||
|
||||
return stateDict_.subDict(name_);
|
||||
return stateDict.subDict(name_);
|
||||
}
|
||||
|
||||
|
||||
bool Foam::functionObjectState::foundProperty(const word& entryName) const
|
||||
{
|
||||
if (stateDict_.found(name_))
|
||||
const IOdictionary& stateDict = this->stateDict();
|
||||
|
||||
if (stateDict.found(name_))
|
||||
{
|
||||
const dictionary& baseDict = stateDict_.subDict(name_);
|
||||
const dictionary& baseDict = stateDict.subDict(name_);
|
||||
return baseDict.found(entryName);
|
||||
}
|
||||
|
||||
@ -109,10 +116,11 @@ Foam::word Foam::functionObjectState::objectResultType
|
||||
) const
|
||||
{
|
||||
word result = word::null;
|
||||
const IOdictionary& stateDict = this->stateDict();
|
||||
|
||||
if (stateDict_.found(resultsName_))
|
||||
if (stateDict.found(resultsName_))
|
||||
{
|
||||
const dictionary& resultsDict = stateDict_.subDict(resultsName_);
|
||||
const dictionary& resultsDict = stateDict.subDict(resultsName_);
|
||||
|
||||
if (resultsDict.found(objectName))
|
||||
{
|
||||
@ -147,9 +155,11 @@ Foam::List<Foam::word> Foam::functionObjectState::objectResultEntries
|
||||
{
|
||||
DynamicList<word> result(2);
|
||||
|
||||
if (stateDict_.found(resultsName_))
|
||||
const IOdictionary& stateDict = this->stateDict();
|
||||
|
||||
if (stateDict.found(resultsName_))
|
||||
{
|
||||
const dictionary& resultsDict = stateDict_.subDict(resultsName_);
|
||||
const dictionary& resultsDict = stateDict.subDict(resultsName_);
|
||||
|
||||
if (resultsDict.found(objectName))
|
||||
{
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2015 OpenFOAM Foundation
|
||||
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
|
||||
\\/ M anipulation | Copyright (C) 2015-2016 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -65,6 +65,15 @@ private:
|
||||
const objectRegistry& obr_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
functionObjectState(const functionObjectState&);
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const functionObjectState&);
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
// Protected data
|
||||
@ -75,19 +84,15 @@ protected:
|
||||
//- Flag to indicate whether the object is active
|
||||
bool active_;
|
||||
|
||||
//- Reference to the state dictionary
|
||||
IOdictionary& stateDict_;
|
||||
|
||||
// Protacted Member Functions
|
||||
|
||||
protected:
|
||||
//- Return a const reference to the state dictionary
|
||||
const IOdictionary& stateDict() const;
|
||||
|
||||
// Protected Member Functions
|
||||
//- Return non-const access to the state dictionary
|
||||
IOdictionary& stateDict();
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
functionObjectState(const functionObjectState&);
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const functionObjectState&);
|
||||
|
||||
|
||||
public:
|
||||
@ -95,11 +100,7 @@ public:
|
||||
// Constructors
|
||||
|
||||
//- Construct from components
|
||||
functionObjectState
|
||||
(
|
||||
const objectRegistry& obr,
|
||||
const word& name
|
||||
);
|
||||
functionObjectState(const objectRegistry& obr, const word& name);
|
||||
|
||||
|
||||
//- Destructor
|
||||
@ -114,9 +115,6 @@ public:
|
||||
//- Return the active flag
|
||||
bool active() const;
|
||||
|
||||
//- Return access to the state dictionary
|
||||
const IOdictionary& stateDict() const;
|
||||
|
||||
//- Return access to the property dictionary
|
||||
dictionary& propertyDict();
|
||||
|
||||
|
||||
@ -100,9 +100,11 @@ void Foam::functionObjectState::getObjectProperty
|
||||
Type& value
|
||||
) const
|
||||
{
|
||||
if (stateDict_.found(objectName))
|
||||
const IOdictionary& stateDict = this->stateDict();
|
||||
|
||||
if (stateDict.found(objectName))
|
||||
{
|
||||
const dictionary& baseDict = stateDict_.subDict(objectName);
|
||||
const dictionary& baseDict = stateDict.subDict(objectName);
|
||||
if (baseDict.found(entryName))
|
||||
{
|
||||
if (baseDict.isDict(entryName))
|
||||
@ -126,12 +128,14 @@ void Foam::functionObjectState::setObjectProperty
|
||||
const Type& value
|
||||
)
|
||||
{
|
||||
if (!stateDict_.found(objectName))
|
||||
IOdictionary& stateDict = this->stateDict();
|
||||
|
||||
if (!stateDict.found(objectName))
|
||||
{
|
||||
stateDict_.add(objectName, dictionary());
|
||||
stateDict.add(objectName, dictionary());
|
||||
}
|
||||
|
||||
dictionary& baseDict = stateDict_.subDict(objectName);
|
||||
dictionary& baseDict = stateDict.subDict(objectName);
|
||||
baseDict.add(entryName, value, true);
|
||||
}
|
||||
|
||||
@ -155,12 +159,14 @@ void Foam::functionObjectState::setObjectResult
|
||||
const Type& value
|
||||
)
|
||||
{
|
||||
if (!stateDict_.found(resultsName_))
|
||||
IOdictionary& stateDict = this->stateDict();
|
||||
|
||||
if (!stateDict.found(resultsName_))
|
||||
{
|
||||
stateDict_.add(resultsName_, dictionary());
|
||||
stateDict.add(resultsName_, dictionary());
|
||||
}
|
||||
|
||||
dictionary& resultsDict = stateDict_.subDict(resultsName_);
|
||||
dictionary& resultsDict = stateDict.subDict(resultsName_);
|
||||
|
||||
if (!resultsDict.found(objectName))
|
||||
{
|
||||
@ -215,9 +221,11 @@ void Foam::functionObjectState::getObjectResult
|
||||
Type& value
|
||||
) const
|
||||
{
|
||||
if (stateDict_.found(resultsName_))
|
||||
const IOdictionary& stateDict = this->stateDict();
|
||||
|
||||
if (stateDict.found(resultsName_))
|
||||
{
|
||||
const dictionary& resultsDict = stateDict_.subDict(resultsName_);
|
||||
const dictionary& resultsDict = stateDict.subDict(resultsName_);
|
||||
|
||||
if (resultsDict.found(objectName))
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user