Commit fafb3e88 authored by Mark Olesen's avatar Mark Olesen
Browse files

functionObjectList and Time modifications

- added clear() method to functionObjectList. It also gets called by ~Time().
  This should destroy function objects before anything else gets
  destroyed (eg, objectRegistry).
parent d8ec3376
......@@ -27,6 +27,8 @@ License
#include "Time.H"
#include "PstreamReduceOps.H"
#include <sstream>
// * * * * * * * * * * * * * Static Member Data * * * * * * * * * * * * * * //
defineTypeNameAndDebug(Foam::Time, 0);
......@@ -350,18 +352,21 @@ Foam::Time::Time
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::Time::~Time()
{}
{
// destroy function objects first
functionObjects_.clear();
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::word Foam::Time::timeName(const scalar t)
{
std::ostringstream osBuffer;
osBuffer.setf(ios_base::fmtflags(format_), ios_base::floatfield);
osBuffer.precision(precision_);
osBuffer << t;
return osBuffer.str();
std::ostringstream buf;
buf.setf(ios_base::fmtflags(format_), ios_base::floatfield);
buf.precision(precision_);
buf << t;
return buf.str();
}
......@@ -643,7 +648,7 @@ Foam::Time& Foam::Time::operator++()
setTime(0.0, timeIndex_);
}
switch(writeControl_)
switch (writeControl_)
{
case wcTimeStep:
outputTime_ = !(timeIndex_ % label(writeInterval_));
......
......@@ -264,19 +264,8 @@ bool Foam::Time::writeObject
timeDict.add("deltaT", deltaT_);
timeDict.add("deltaT0", deltaT0_);
timeDict.regIOobject::writeObject
(
fmt,
ver,
cmp
);
bool writeOK = objectRegistry::writeObject
(
fmt,
ver,
cmp
);
timeDict.regIOobject::writeObject(fmt, ver, cmp);
bool writeOK = objectRegistry::writeObject(fmt, ver, cmp);
if (writeOK && purgeWrite_)
{
......@@ -306,7 +295,7 @@ bool Foam::Time::writeNow()
bool Foam::Time::writeAndEnd()
{
stopAt_ = saWriteNow;
stopAt_ = saWriteNow;
endTime_ = value();
return writeNow();
......
......@@ -97,6 +97,15 @@ Foam::functionObjectList::~functionObjectList()
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::functionObjectList::clear()
{
PtrList<functionObject>::clear();
digests_.clear();
indices_.clear();
updated_ = false;
}
bool Foam::functionObjectList::start()
{
return read();
......@@ -157,7 +166,6 @@ bool Foam::functionObjectList::read()
HashTable<label> newIndices;
label nFunc = 0;
label oldIndex = -1;
if (entryPtr->isDict())
{
......@@ -179,6 +187,7 @@ bool Foam::functionObjectList::read()
newDigs[nFunc] = dict.digest();
label oldIndex;
functionObject* objPtr = remove(key, oldIndex);
if (objPtr)
{
......@@ -220,6 +229,7 @@ bool Foam::functionObjectList::read()
newDigs[nFunc] = dict.digest();
label oldIndex;
functionObject* objPtr = remove(key, oldIndex);
if (objPtr)
{
......@@ -248,13 +258,13 @@ bool Foam::functionObjectList::read()
// updating the PtrList of functionObjects also deletes any existing,
// but unused functionObjects
this->transfer(newPtrs);
PtrList<functionObject>::transfer(newPtrs);
digests_.transfer(newDigs);
indices_.transfer(newIndices);
}
else
{
this->clear();
PtrList<functionObject>::clear();
digests_.clear();
indices_.clear();
}
......
......@@ -127,6 +127,16 @@ public:
// Member Functions
//- Return the number of elements in the List.
using PtrList<functionObject>::size;
//- Return true if the List is empty (ie, size() is zero).
using PtrList<functionObject>::empty;
//- Clear the list of function objects
virtual void clear();
//- Start is called at the start of the time-loop
virtual bool start();
......
......@@ -29,10 +29,7 @@ License
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(objectRegistry, 0);
}
defineTypeNameAndDebug(Foam::objectRegistry, 0);
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
......@@ -86,9 +83,9 @@ Foam::objectRegistry::~objectRegistry()
{
if (iter()->ownedByRegistry())
{
regIOobject* elemPtr = iter();
regIOobject* object = iter();
erase(iter);
delete elemPtr;
delete object;
}
}
}
......@@ -206,18 +203,15 @@ bool Foam::objectRegistry::checkOut(regIOobject& io) const
bool Foam::objectRegistry::modified() const
{
bool anyModified = false;
for (const_iterator iter = begin(); iter != end(); ++iter)
{
if (iter()->modified())
{
anyModified = true;
break;
return true;
}
}
return anyModified;
return false;
}
......
......@@ -5,6 +5,6 @@ set -x
wmake libo postCalc
wmake libso foamCalcFunctions
(cd functionObjects && ./Allwmake)
functionObjects/Allwmake
# ----------------------------------------------------------------- end-of-file
......@@ -47,11 +47,11 @@ const Foam::NamedEnum<Foam::outputFilterOutputControl::outputControls, 2>
Foam::outputFilterOutputControl::outputFilterOutputControl
(
const Time& time,
const Time& t,
const dictionary& dict
)
:
time_(time),
time_(t),
outputControl_(ocTimeStep),
outputInterval_(0)
{
......@@ -93,8 +93,8 @@ bool Foam::outputFilterOutputControl::output() const
{
return
(
!(time_.timeIndex() % outputInterval_)
|| (outputInterval_ <= 1)
(outputInterval_ <= 1)
|| !(time_.timeIndex() % outputInterval_)
);
break;
}
......
......@@ -88,22 +88,18 @@ public:
// Constructors
//- Construct from dictionary and Time object
outputFilterOutputControl
(
const Time& time,
const dictionary& dict
);
//- Construct from Time object and dictionary
outputFilterOutputControl(const Time&, const dictionary&);
// Destructor
~outputFilterOutputControl();
~outputFilterOutputControl();
// Member Functions
//- Read from dictionary
void read(const dictionary& dict);
void read(const dictionary&);
//- Return const access to the Time object
const Time& time() const
......
......@@ -2,8 +2,8 @@
cd ${0%/*} || exit 1 # run from this directory
set -x
(cd LES && ./Allwmake )
(cd incompressible && ./Allwmake )
(cd compressible && ./Allwmake )
LES/Allwmake
incompressible/Allwmake
compressible/Allwmake
# ----------------------------------------------------------------- end-of-file
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