Commit 339844e1 authored by mattijs's avatar mattijs
Browse files

BUG: DimensionSets: stored reference instead of dictionary

parent 57a0dd6f
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -35,15 +35,29 @@ namespace Foam
/* * * * * * * * * * * * * * * 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()
{
return debug::switchSet
(
"DimensionSets",
dimensionSystemsPtr_
);
if (!dimensionSystemsPtr_.valid())
{
dictionary* cachedPtr = NULL;
dimensionSystemsPtr_.reset
(
new dictionary
(
debug::switchSet
(
"DimensionSets",
cachedPtr
)
)
);
}
return dimensionSystemsPtr_();
}
......@@ -63,10 +77,9 @@ public:
{}
virtual void readData(Foam::Istream& is)
{
deleteDemandDrivenData(dimensionSystemsPtr_);
unitSetPtr_.clear();
writeUnitSetPtr_.clear();
dimensionSystemsPtr_ = new dictionary(is);
dimensionSystemsPtr_.reset(new dictionary(is));
}
virtual void writeData(Foam::Ostream& os) const
{
......
......@@ -47,47 +47,38 @@ dictionary* debugSwitchesPtr_(NULL);
dictionary* infoSwitchesPtr_(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.
simpleObjectRegistry* debugObjectsPtr_(NULL);
simpleObjectRegistry* infoObjectsPtr_(NULL);
simpleObjectRegistry* optimisationObjectsPtr_(NULL);
simpleObjectRegistry* dimensionSetObjectsPtr_(NULL);
simpleObjectRegistry* dimensionedConstantObjectsPtr_(NULL);
class deleteDebugSwitchPtr
// to ensure controlDictPtr_ is deleted at the end of the run
class deleteControlDictPtr
{
public:
deleteDebugSwitchPtr()
deleteControlDictPtr()
{}
~deleteDebugSwitchPtr()
~deleteControlDictPtr()
{
deleteDemandDrivenData(debugObjectsPtr_);
deleteDemandDrivenData(infoObjectsPtr_);
deleteDemandDrivenData(optimisationObjectsPtr_);
deleteDemandDrivenData(dimensionSetObjectsPtr_);
deleteDemandDrivenData(dimensionedConstantObjectsPtr_);
debugSwitchesPtr_ = NULL;
infoSwitchesPtr_ = NULL;
optimisationSwitchesPtr_ = NULL;
deleteDemandDrivenData(controlDictPtr_);
}
};
deleteDebugSwitchPtr deleteDebugSwitchPtr_;
deleteControlDictPtr deleteControlDictPtr_;
//! \endcond
......
Supports Markdown
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