Skip to content
Snippets Groups Projects
Commit 339844e1 authored by mattijs's avatar mattijs
Browse files

BUG: DimensionSets: stored reference instead of dictionary

parent 57a0dd6f
Branches
Tags
No related merge requests found
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
========= | ========= |
\\ / 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-2012 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
...@@ -35,15 +35,29 @@ namespace Foam ...@@ -35,15 +35,29 @@ namespace Foam
/* * * * * * * * * * * * * * * Static Member Data * * * * * * * * * * * * * */ /* * * * * * * * * * * * * * * Static Member Data * * * * * * * * * * * * * */
dictionary* dimensionSystemsPtr_(NULL); //- Since dimensionSystems() can be reread we actually store a copy of
// the controlDict subDict (v.s. a reference to the subDict for e.g.
// dimensionedConstants)
autoPtr<dictionary> dimensionSystemsPtr_(NULL);
dictionary& dimensionSystems() dictionary& dimensionSystems()
{ {
return debug::switchSet if (!dimensionSystemsPtr_.valid())
( {
"DimensionSets", dictionary* cachedPtr = NULL;
dimensionSystemsPtr_ dimensionSystemsPtr_.reset
); (
new dictionary
(
debug::switchSet
(
"DimensionSets",
cachedPtr
)
)
);
}
return dimensionSystemsPtr_();
} }
...@@ -63,10 +77,9 @@ public: ...@@ -63,10 +77,9 @@ public:
{} {}
virtual void readData(Foam::Istream& is) virtual void readData(Foam::Istream& is)
{ {
deleteDemandDrivenData(dimensionSystemsPtr_);
unitSetPtr_.clear(); unitSetPtr_.clear();
writeUnitSetPtr_.clear(); writeUnitSetPtr_.clear();
dimensionSystemsPtr_ = new dictionary(is); dimensionSystemsPtr_.reset(new dictionary(is));
} }
virtual void writeData(Foam::Ostream& os) const virtual void writeData(Foam::Ostream& os) const
{ {
......
...@@ -47,47 +47,38 @@ dictionary* debugSwitchesPtr_(NULL); ...@@ -47,47 +47,38 @@ dictionary* debugSwitchesPtr_(NULL);
dictionary* infoSwitchesPtr_(NULL); dictionary* infoSwitchesPtr_(NULL);
dictionary* optimisationSwitchesPtr_(NULL); dictionary* optimisationSwitchesPtr_(NULL);
// to ensure controlDictPtr_ is deleted at the end of the run
class deleteControlDictPtr
{
public:
deleteControlDictPtr()
{}
~deleteControlDictPtr()
{
deleteDemandDrivenData(controlDictPtr_);
}
};
deleteControlDictPtr deleteControlDictPtr_;
// Debug switch read and write callback tables. // Debug switch read and write callback tables.
simpleObjectRegistry* debugObjectsPtr_(NULL); simpleObjectRegistry* debugObjectsPtr_(NULL);
simpleObjectRegistry* infoObjectsPtr_(NULL); simpleObjectRegistry* infoObjectsPtr_(NULL);
simpleObjectRegistry* optimisationObjectsPtr_(NULL); simpleObjectRegistry* optimisationObjectsPtr_(NULL);
simpleObjectRegistry* dimensionSetObjectsPtr_(NULL); simpleObjectRegistry* dimensionSetObjectsPtr_(NULL);
simpleObjectRegistry* dimensionedConstantObjectsPtr_(NULL); simpleObjectRegistry* dimensionedConstantObjectsPtr_(NULL);
class deleteDebugSwitchPtr
// to ensure controlDictPtr_ is deleted at the end of the run
class deleteControlDictPtr
{ {
public: public:
deleteDebugSwitchPtr() deleteControlDictPtr()
{} {}
~deleteDebugSwitchPtr() ~deleteControlDictPtr()
{ {
deleteDemandDrivenData(debugObjectsPtr_); deleteDemandDrivenData(debugObjectsPtr_);
deleteDemandDrivenData(infoObjectsPtr_); deleteDemandDrivenData(infoObjectsPtr_);
deleteDemandDrivenData(optimisationObjectsPtr_); deleteDemandDrivenData(optimisationObjectsPtr_);
deleteDemandDrivenData(dimensionSetObjectsPtr_); deleteDemandDrivenData(dimensionSetObjectsPtr_);
deleteDemandDrivenData(dimensionedConstantObjectsPtr_); deleteDemandDrivenData(dimensionedConstantObjectsPtr_);
debugSwitchesPtr_ = NULL;
infoSwitchesPtr_ = NULL;
optimisationSwitchesPtr_ = NULL;
deleteDemandDrivenData(controlDictPtr_);
} }
}; };
deleteDebugSwitchPtr deleteDebugSwitchPtr_; deleteControlDictPtr deleteControlDictPtr_;
//! \endcond //! \endcond
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment