mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
functionObjectList added manualStart()/manualExecute()
- can call start()/execute() manually regardless of the execution status
This commit is contained in:
@ -373,7 +373,6 @@ Foam::word Foam::Time::timeName(const scalar t)
|
||||
Foam::word Foam::Time::timeName() const
|
||||
{
|
||||
return dimensionedScalar::name();
|
||||
//return timeName(timeOutputValue());
|
||||
}
|
||||
|
||||
|
||||
@ -435,7 +434,7 @@ Foam::instant Foam::Time::findClosestTime(const scalar t) const
|
||||
return times[nearestIndex];
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
// This should work too,
|
||||
// if we don't worry about checking "constant" explicitly
|
||||
//
|
||||
@ -493,11 +492,13 @@ bool Foam::Time::run() const
|
||||
{
|
||||
bool running = value() < (endTime_ - 0.5*deltaT_);
|
||||
|
||||
if (!running && !subCycling_)
|
||||
if (!subCycling_)
|
||||
{
|
||||
// only execute when the condition is no longer true
|
||||
// ie, when exiting the control loop
|
||||
if (!running && timeIndex_ != startTimeIndex_)
|
||||
{
|
||||
// Note, the execute() also calls an indirect start() if required
|
||||
if (timeIndex_ != startTimeIndex_)
|
||||
{
|
||||
functionObjects_.execute();
|
||||
}
|
||||
}
|
||||
@ -508,7 +509,8 @@ bool Foam::Time::run() const
|
||||
|
||||
bool Foam::Time::end() const
|
||||
{
|
||||
return (value() > (endTime_ + 0.5*deltaT_));
|
||||
bool done = value() > (endTime_ + 0.5*deltaT_);
|
||||
return done;
|
||||
}
|
||||
|
||||
|
||||
@ -701,8 +703,9 @@ Foam::Time& Foam::Time::operator++()
|
||||
}
|
||||
}
|
||||
break;
|
||||
};
|
||||
}
|
||||
|
||||
// see if endTime needs adjustment to stop at the next run()/end() check
|
||||
if (!end())
|
||||
{
|
||||
if (stopAt_ == saNoWriteNow)
|
||||
|
||||
@ -349,9 +349,15 @@ public:
|
||||
// Check
|
||||
|
||||
//- Return true if run should continue
|
||||
// @sa end()
|
||||
// @note
|
||||
// the rounding heuristics near endTime mean that
|
||||
// @code run() @endcode and @code !end() @endcode may
|
||||
// not yield the same result
|
||||
virtual bool run() const;
|
||||
|
||||
//- Return true if end of run
|
||||
// @sa run()
|
||||
virtual bool end() const;
|
||||
|
||||
|
||||
|
||||
@ -44,7 +44,7 @@ namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class subCycleTimeTime Declaration
|
||||
Class subCycleTime Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class subCycleTime
|
||||
@ -62,7 +62,7 @@ public:
|
||||
// Constructors
|
||||
|
||||
//- Construct from original time and number of sub-cycles
|
||||
subCycleTime(Time& t, const label nSubCycles);
|
||||
subCycleTime(Time&, const label nSubCycles);
|
||||
|
||||
|
||||
// Destructor
|
||||
@ -72,6 +72,7 @@ public:
|
||||
|
||||
// Member functions
|
||||
|
||||
//- Return true if the number of sub-cycles has been reached
|
||||
bool end() const;
|
||||
|
||||
//- End the sub-cycling and reset the time-state
|
||||
|
||||
@ -30,11 +30,8 @@ License
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
defineRunTimeSelectionTable(functionObject, dictionary);
|
||||
int functionObject::debug(::Foam::debug::debugSwitch("functionObject", 0));
|
||||
}
|
||||
defineRunTimeSelectionTable(Foam::functionObject, dictionary);
|
||||
int Foam::functionObject::debug(Foam::debug::debugSwitch("functionObject", 0));
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
@ -144,7 +144,7 @@ public:
|
||||
virtual bool execute() = 0;
|
||||
|
||||
//- Read and set the function object if its data have changed
|
||||
virtual bool read(const dictionary& dict) = 0;
|
||||
virtual bool read(const dictionary&) = 0;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -106,6 +106,25 @@ void Foam::functionObjectList::clear()
|
||||
}
|
||||
|
||||
|
||||
void Foam::functionObjectList::on()
|
||||
{
|
||||
execution_ = true;
|
||||
}
|
||||
|
||||
|
||||
void Foam::functionObjectList::off()
|
||||
{
|
||||
// for safety, also force a read() when execution is turned back on
|
||||
updated_ = execution_ = false;
|
||||
}
|
||||
|
||||
|
||||
bool Foam::functionObjectList::status() const
|
||||
{
|
||||
return execution_;
|
||||
}
|
||||
|
||||
|
||||
bool Foam::functionObjectList::start()
|
||||
{
|
||||
return read();
|
||||
@ -133,19 +152,6 @@ bool Foam::functionObjectList::execute()
|
||||
}
|
||||
|
||||
|
||||
void Foam::functionObjectList::on()
|
||||
{
|
||||
execution_ = true;
|
||||
}
|
||||
|
||||
|
||||
void Foam::functionObjectList::off()
|
||||
{
|
||||
// for safety, also force a read() when execution is turned back on
|
||||
updated_ = execution_ = false;
|
||||
}
|
||||
|
||||
|
||||
bool Foam::functionObjectList::read()
|
||||
{
|
||||
bool ok = true;
|
||||
@ -273,4 +279,28 @@ bool Foam::functionObjectList::read()
|
||||
}
|
||||
|
||||
|
||||
bool Foam::functionObjectList::manualStart()
|
||||
{
|
||||
bool state = execution_;
|
||||
execution_ = true;
|
||||
|
||||
bool ret = start();
|
||||
|
||||
execution_ = state;
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
bool Foam::functionObjectList::manualExecute()
|
||||
{
|
||||
bool state = execution_;
|
||||
execution_ = true;
|
||||
|
||||
bool ret = execute();
|
||||
|
||||
execution_ = state;
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -40,10 +40,10 @@ SourceFiles
|
||||
#ifndef functionObjectList_H
|
||||
#define functionObjectList_H
|
||||
|
||||
#include "functionObject.H"
|
||||
#include "HashTable.H"
|
||||
#include "PtrList.H"
|
||||
#include "functionObject.H"
|
||||
#include "SHA1Digest.H"
|
||||
#include "HashTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -137,20 +137,32 @@ public:
|
||||
virtual void clear();
|
||||
|
||||
|
||||
//- Start is called at the start of the time-loop
|
||||
virtual bool start();
|
||||
|
||||
//- Execute is called at each ++ or += of the time-loop
|
||||
virtual bool execute();
|
||||
|
||||
//- Switch the function objects on
|
||||
virtual void on();
|
||||
|
||||
//- Switch the function objects off
|
||||
virtual void off();
|
||||
|
||||
//- Return the execution status (on/off) of the function objects
|
||||
virtual bool status() const;
|
||||
|
||||
|
||||
//- Start is called at the start of the time-loop
|
||||
virtual bool start();
|
||||
|
||||
//- Execute is called at each ++ or += of the time-loop
|
||||
virtual bool execute();
|
||||
|
||||
//- Read and set the function objects if their data have changed
|
||||
virtual bool read();
|
||||
|
||||
|
||||
//- Call start() manually regardless of the execution status
|
||||
virtual bool manualStart();
|
||||
|
||||
//- Call execute() manually regardless of the execution status
|
||||
virtual bool manualExecute();
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -31,25 +31,20 @@ Description
|
||||
#include "Time.H"
|
||||
#include "polyMesh.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
defineTypeNameAndDebug(regIOobject, 0);
|
||||
defineTypeNameAndDebug(Foam::regIOobject, 0);
|
||||
|
||||
int regIOobject::fileModificationSkew
|
||||
int Foam::regIOobject::fileModificationSkew
|
||||
(
|
||||
debug::optimisationSwitch("fileModificationSkew", 30)
|
||||
Foam::debug::optimisationSwitch("fileModificationSkew", 30)
|
||||
);
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
// Construct from IOobject
|
||||
regIOobject::regIOobject(const IOobject& io)
|
||||
Foam::regIOobject::regIOobject(const IOobject& io)
|
||||
:
|
||||
IOobject(io),
|
||||
registered_(false),
|
||||
@ -66,7 +61,7 @@ regIOobject::regIOobject(const IOobject& io)
|
||||
|
||||
|
||||
// Construct as copy
|
||||
regIOobject::regIOobject(const regIOobject& rio)
|
||||
Foam::regIOobject::regIOobject(const regIOobject& rio)
|
||||
:
|
||||
IOobject(rio),
|
||||
registered_(false),
|
||||
@ -80,7 +75,7 @@ regIOobject::regIOobject(const regIOobject& rio)
|
||||
|
||||
// Construct as copy, and transfering objectRegistry registration to copy
|
||||
// if registerCopy is true
|
||||
regIOobject::regIOobject(const regIOobject& rio, bool registerCopy)
|
||||
Foam::regIOobject::regIOobject(const regIOobject& rio, bool registerCopy)
|
||||
:
|
||||
IOobject(rio),
|
||||
registered_(false),
|
||||
@ -99,7 +94,7 @@ regIOobject::regIOobject(const regIOobject& rio, bool registerCopy)
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
// Delete read stream, checkout from objectRegistry and destroy
|
||||
regIOobject::~regIOobject()
|
||||
Foam::regIOobject::~regIOobject()
|
||||
{
|
||||
if (objectRegistry::debug)
|
||||
{
|
||||
@ -125,7 +120,7 @@ regIOobject::~regIOobject()
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
void regIOobject::checkIn()
|
||||
void Foam::regIOobject::checkIn()
|
||||
{
|
||||
if (!registered_)
|
||||
{
|
||||
@ -153,7 +148,7 @@ void regIOobject::checkIn()
|
||||
}
|
||||
|
||||
|
||||
void regIOobject::checkOut()
|
||||
void Foam::regIOobject::checkOut()
|
||||
{
|
||||
if (registered_)
|
||||
{
|
||||
@ -164,7 +159,7 @@ void regIOobject::checkOut()
|
||||
|
||||
|
||||
// Rename object and re-register with objectRegistry under new name
|
||||
void regIOobject::rename(const word& newName)
|
||||
void Foam::regIOobject::rename(const word& newName)
|
||||
{
|
||||
// Check out of objectRegistry
|
||||
checkOut();
|
||||
@ -177,7 +172,7 @@ void regIOobject::rename(const word& newName)
|
||||
|
||||
|
||||
// Assign to IOobject
|
||||
void regIOobject::operator=(const IOobject& io)
|
||||
void Foam::regIOobject::operator=(const IOobject& io)
|
||||
{
|
||||
if (isPtr_)
|
||||
{
|
||||
@ -195,8 +190,4 @@ void regIOobject::operator=(const IOobject& io)
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -126,8 +126,8 @@ public:
|
||||
//- Switch the function object off
|
||||
virtual void off();
|
||||
|
||||
//- Read and set the function object if its data has changed
|
||||
virtual bool read(const dictionary& dict);
|
||||
//- Read and set the function object if its data have changed
|
||||
virtual bool read(const dictionary&);
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user