mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
BUG: dimensionSets: do not use autoPtr in static construction/destruction
This commit is contained in:
@ -38,32 +38,13 @@ namespace Foam
|
|||||||
//- Since dimensionSystems() can be reread we actually store a copy of
|
//- Since dimensionSystems() can be reread we actually store a copy of
|
||||||
// the controlDict subDict (v.s. a reference to the subDict for e.g.
|
// the controlDict subDict (v.s. a reference to the subDict for e.g.
|
||||||
// dimensionedConstants)
|
// dimensionedConstants)
|
||||||
autoPtr<dictionary> dimensionSystemsPtr_(NULL);
|
dictionary* dimensionSystemsPtr_(NULL);
|
||||||
|
HashTable<dimensionedScalar>* unitSetPtr_(NULL);
|
||||||
dictionary& dimensionSystems()
|
dimensionSets* writeUnitSetPtr_(NULL);
|
||||||
{
|
|
||||||
if (!dimensionSystemsPtr_.valid())
|
|
||||||
{
|
|
||||||
dictionary* cachedPtr = NULL;
|
|
||||||
dimensionSystemsPtr_.reset
|
|
||||||
(
|
|
||||||
new dictionary
|
|
||||||
(
|
|
||||||
debug::switchSet
|
|
||||||
(
|
|
||||||
"DimensionSets",
|
|
||||||
cachedPtr
|
|
||||||
)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return dimensionSystemsPtr_();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
autoPtr<HashTable<dimensionedScalar> > unitSetPtr_;
|
|
||||||
autoPtr<dimensionSets> writeUnitSetPtr_;
|
|
||||||
|
|
||||||
|
//- Helper class to
|
||||||
|
// - register re-reader
|
||||||
|
// - deallocate demand-driven data
|
||||||
class addDimensionSetsToDebug
|
class addDimensionSetsToDebug
|
||||||
:
|
:
|
||||||
public ::Foam::simpleRegIOobject
|
public ::Foam::simpleRegIOobject
|
||||||
@ -74,12 +55,18 @@ public:
|
|||||||
::Foam::simpleRegIOobject(Foam::debug::addDimensionSetObject, name)
|
::Foam::simpleRegIOobject(Foam::debug::addDimensionSetObject, name)
|
||||||
{}
|
{}
|
||||||
virtual ~addDimensionSetsToDebug()
|
virtual ~addDimensionSetsToDebug()
|
||||||
{}
|
{
|
||||||
|
deleteDemandDrivenData(dimensionSystemsPtr_);
|
||||||
|
deleteDemandDrivenData(unitSetPtr_);
|
||||||
|
deleteDemandDrivenData(writeUnitSetPtr_);
|
||||||
|
|
||||||
|
}
|
||||||
virtual void readData(Foam::Istream& is)
|
virtual void readData(Foam::Istream& is)
|
||||||
{
|
{
|
||||||
unitSetPtr_.clear();
|
deleteDemandDrivenData(dimensionSystemsPtr_);
|
||||||
writeUnitSetPtr_.clear();
|
deleteDemandDrivenData(unitSetPtr_);
|
||||||
dimensionSystemsPtr_.reset(new dictionary(is));
|
deleteDemandDrivenData(writeUnitSetPtr_);
|
||||||
|
dimensionSystemsPtr_ = new dictionary(is);
|
||||||
}
|
}
|
||||||
virtual void writeData(Foam::Ostream& os) const
|
virtual void writeData(Foam::Ostream& os) const
|
||||||
{
|
{
|
||||||
@ -89,10 +76,27 @@ public:
|
|||||||
addDimensionSetsToDebug addDimensionSetsToDebug_("DimensionSets");
|
addDimensionSetsToDebug addDimensionSetsToDebug_("DimensionSets");
|
||||||
|
|
||||||
|
|
||||||
|
dictionary& dimensionSystems()
|
||||||
|
{
|
||||||
|
if (!dimensionSystemsPtr_)
|
||||||
|
{
|
||||||
|
dictionary* cachedPtr = NULL;
|
||||||
|
dimensionSystemsPtr_ = new dictionary
|
||||||
|
(
|
||||||
|
debug::switchSet
|
||||||
|
(
|
||||||
|
"DimensionSets",
|
||||||
|
cachedPtr
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return *dimensionSystemsPtr_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
const HashTable<dimensionedScalar>& unitSet()
|
const HashTable<dimensionedScalar>& unitSet()
|
||||||
{
|
{
|
||||||
if (!unitSetPtr_.valid())
|
if (!unitSetPtr_)
|
||||||
{
|
{
|
||||||
const dictionary& dict = dimensionSystems();
|
const dictionary& dict = dimensionSystems();
|
||||||
|
|
||||||
@ -114,10 +118,7 @@ const HashTable<dimensionedScalar>& unitSet()
|
|||||||
|
|
||||||
const dictionary& unitDict = dict.subDict(unitSetCoeffs);
|
const dictionary& unitDict = dict.subDict(unitSetCoeffs);
|
||||||
|
|
||||||
unitSetPtr_.reset
|
unitSetPtr_ = new HashTable<dimensionedScalar>(unitDict.size());
|
||||||
(
|
|
||||||
new HashTable<dimensionedScalar>(unitDict.size())
|
|
||||||
);
|
|
||||||
|
|
||||||
forAllConstIter(dictionary, unitDict, iter)
|
forAllConstIter(dictionary, unitDict, iter)
|
||||||
{
|
{
|
||||||
@ -145,14 +146,7 @@ const HashTable<dimensionedScalar>& unitSet()
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
writeUnitSetPtr_.reset
|
writeUnitSetPtr_ = new dimensionSets(*unitSetPtr_, writeUnitNames);
|
||||||
(
|
|
||||||
new dimensionSets
|
|
||||||
(
|
|
||||||
unitSetPtr_(),
|
|
||||||
writeUnitNames
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
if (writeUnitNames.size() != 0 && writeUnitNames.size() != 7)
|
if (writeUnitNames.size() != 0 && writeUnitNames.size() != 7)
|
||||||
{
|
{
|
||||||
@ -162,17 +156,17 @@ const HashTable<dimensionedScalar>& unitSet()
|
|||||||
<< exit(FatalIOError);
|
<< exit(FatalIOError);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return unitSetPtr_();
|
return *unitSetPtr_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const dimensionSets& writeUnitSet()
|
const dimensionSets& writeUnitSet()
|
||||||
{
|
{
|
||||||
if (!writeUnitSetPtr_.valid())
|
if (!writeUnitSetPtr_)
|
||||||
{
|
{
|
||||||
(void)unitSet();
|
(void)unitSet();
|
||||||
}
|
}
|
||||||
return writeUnitSetPtr_();
|
return *writeUnitSetPtr_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user