functionObjects: Separated 'execute' and 'write' functions to simplify support for post-processing

This commit is contained in:
Henry Weller
2016-05-13 09:05:29 +01:00
parent 758dfc2c1f
commit 3c272484c5
19 changed files with 599 additions and 64 deletions

View File

@ -218,8 +218,8 @@ db/functionObjects/functionObject/functionObject.C
db/functionObjects/functionObjectList/functionObjectList.C db/functionObjects/functionObjectList/functionObjectList.C
db/functionObjects/functionObjectFile/functionObjectFile.C db/functionObjects/functionObjectFile/functionObjectFile.C
db/functionObjects/functionObjectFiles/functionObjectFiles.C db/functionObjects/functionObjectFiles/functionObjectFiles.C
db/functionObjects/outputFilterControl/outputFilterControl.C db/functionObjects/timeControl/timeControl.C
db/functionObjects/timeControl/timeControlFunctionObject.C
Time = db/Time Time = db/Time
$(Time)/TimePaths.C $(Time)/TimePaths.C

View File

@ -88,17 +88,30 @@ Foam::OutputFilterFunctionObject<OutputFilter>::OutputFilterFunctionObject
template<class OutputFilter> template<class OutputFilter>
bool Foam::OutputFilterFunctionObject<OutputFilter>::execute bool Foam::OutputFilterFunctionObject<OutputFilter>::execute
( (
const bool forceWrite const bool postProcess
) )
{ {
if (active()) if (active())
{ {
if (evaluateControl_.execute()) if (postProcess || evaluateControl_.execute())
{ {
filter_.execute(); filter_.execute();
} }
}
if (forceWrite || writeControl_.execute()) return true;
}
template<class OutputFilter>
bool Foam::OutputFilterFunctionObject<OutputFilter>::write
(
const bool postProcess
)
{
if (active())
{
if (postProcess || writeControl_.execute())
{ {
filter_.write(); filter_.write();
} }
@ -141,7 +154,7 @@ bool Foam::OutputFilterFunctionObject<OutputFilter>::adjustTimeStep()
( (
active() active()
&& writeControl_.control() && writeControl_.control()
== outputFilterControl::ocAdjustableRunTime == timeControl::ocAdjustableRunTime
) )
{ {
const label writeTimeIndex = writeControl_.executionIndex(); const label writeTimeIndex = writeControl_.executionIndex();

View File

@ -44,7 +44,7 @@ SourceFiles
#include "functionObject.H" #include "functionObject.H"
#include "dictionary.H" #include "dictionary.H"
#include "outputFilterControl.H" #include "timeControl.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -83,10 +83,10 @@ class OutputFilterFunctionObject
//- Output controls //- Output controls
outputFilterControl writeControl_; timeControl writeControl_;
//- Evaluate controls //- Evaluate controls
outputFilterControl evaluateControl_; timeControl evaluateControl_;
//- The output filter //- The output filter
OutputFilter filter_; OutputFilter filter_;
@ -138,7 +138,7 @@ public:
inline const word& regionName() const; inline const word& regionName() const;
//- Return the output control object //- Return the output control object
inline const outputFilterControl& writeControl() const; inline const timeControl& writeControl() const;
//- Return the output filter //- Return the output filter
inline const OutputFilter& outputFilter() const; inline const OutputFilter& outputFilter() const;
@ -147,9 +147,14 @@ public:
// Function object control // Function object control
//- Called at each ++ or += of the time-loop. //- Called at each ++ or += of the time-loop.
// forceWrite overrides the usual writeControl behaviour and // postProcess overrides the usual executeControl behaviour and
// forces execution (used in post-processing mode)
virtual bool execute(const bool postProcess = false);
//- Called at each ++ or += of the time-loop.
// postProcess overrides the usual writeControl behaviour and
// forces writing (used in post-processing mode) // forces writing (used in post-processing mode)
virtual bool execute(const bool forceWrite = false); virtual bool write(const bool postProcess = false);
//- Called when Time::run() determines that the time-loop exits //- Called when Time::run() determines that the time-loop exits
virtual bool end(); virtual bool end();

View File

@ -42,7 +42,7 @@ Foam::OutputFilterFunctionObject<OutputFilter>::dict() const
template<class OutputFilter> template<class OutputFilter>
inline const Foam::outputFilterControl& inline const Foam::timeControl&
Foam::OutputFilterFunctionObject<OutputFilter>::writeControl() const Foam::OutputFilterFunctionObject<OutputFilter>::writeControl() const
{ {
return writeControl_; return writeControl_;

View File

@ -110,7 +110,7 @@ const Foam::word& Foam::functionObject::name() const
bool Foam::functionObject::end() bool Foam::functionObject::end()
{ {
return execute(false); return execute();
} }

View File

@ -197,10 +197,15 @@ public:
//- Name //- Name
virtual const word& name() const; virtual const word& name() const;
//- Called at each ++ or += of the time-loop. forceWrite overrides //- Called at each ++ or += of the time-loop.
// the usual writeControl behaviour and forces writing always // postProcess overrides the usual executeControl behaviour and
// (used in post-processing mode) // forces execution (used in post-processing mode)
virtual bool execute(const bool forceWrite) = 0; virtual bool execute(const bool postProcess = false) = 0;
//- Called at each ++ or += of the time-loop.
// postProcess overrides the usual writeControl behaviour and
// forces writing always (used in post-processing mode)
virtual bool write(const bool postProcess = false) = 0;
//- Called when Time::run() determines that the time-loop exits. //- Called when Time::run() determines that the time-loop exits.
// By default it simply calls execute(). // By default it simply calls execute().

View File

@ -47,7 +47,6 @@ SourceFiles
namespace Foam namespace Foam
{ {
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
Class functionObjectFile Declaration Class functionObjectFile Declaration
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/

View File

@ -185,7 +185,7 @@ bool Foam::functionObjectList::start()
} }
bool Foam::functionObjectList::execute(const bool forceWrite) bool Foam::functionObjectList::execute(const bool postProcess)
{ {
bool ok = true; bool ok = true;
@ -198,7 +198,8 @@ bool Foam::functionObjectList::execute(const bool forceWrite)
forAll(*this, objectI) forAll(*this, objectI)
{ {
ok = operator[](objectI).execute(forceWrite) && ok; ok = operator[](objectI).execute(postProcess) && ok;
ok = operator[](objectI).write(postProcess) && ok;
} }
} }

View File

@ -170,10 +170,10 @@ public:
//- Called at the start of the time-loop //- Called at the start of the time-loop
bool start(); bool start();
//- Called at each ++ or += of the time-loop. forceWrite overrides //- Called at each ++ or += of the time-loop.
// the usual writeControl behaviour and forces writing always // postProcess overrides the usual executeControl behaviour and
// (used in post-processing mode) // forces execution (used in post-processing mode)
bool execute(const bool forceWrite = false); bool execute(const bool postProcess = false);
//- Called when Time::run() determines that the time-loop exits //- Called when Time::run() determines that the time-loop exits
bool end(); bool end();

View File

@ -23,7 +23,7 @@ License
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "outputFilterControl.H" #include "timeControl.H"
#include "PstreamReduceOps.H" #include "PstreamReduceOps.H"
// * * * * * * * * * * * * * Static Member Data * * * * * * * * * * * * * * // // * * * * * * * * * * * * * Static Member Data * * * * * * * * * * * * * * //
@ -31,7 +31,7 @@ License
namespace Foam namespace Foam
{ {
template<> template<>
const char* NamedEnum<outputFilterControl::timeControls, 8>:: const char* NamedEnum<timeControl::timeControls, 8>::
names[] = names[] =
{ {
"timeStep", "timeStep",
@ -45,13 +45,13 @@ namespace Foam
}; };
} }
const Foam::NamedEnum<Foam::outputFilterControl::timeControls, 8> const Foam::NamedEnum<Foam::timeControl::timeControls, 8>
Foam::outputFilterControl::timeControlNames_; Foam::timeControl::timeControlNames_;
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::outputFilterControl::outputFilterControl Foam::timeControl::timeControl
( (
const Time& t, const Time& t,
const dictionary& dict, const dictionary& dict,
@ -71,13 +71,13 @@ Foam::outputFilterControl::outputFilterControl
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::outputFilterControl::~outputFilterControl() Foam::timeControl::~timeControl()
{} {}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::outputFilterControl::read(const dictionary& dict) void Foam::timeControl::read(const dictionary& dict)
{ {
word controlName(prefix_ + "Control"); word controlName(prefix_ + "Control");
word intervalName(prefix_ + "Interval"); word intervalName(prefix_ + "Interval");
@ -137,7 +137,7 @@ void Foam::outputFilterControl::read(const dictionary& dict)
} }
bool Foam::outputFilterControl::execute() bool Foam::timeControl::execute()
{ {
switch (timeControl_) switch (timeControl_)
{ {

View File

@ -22,23 +22,21 @@ License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class Class
Foam::outputFilterControl Foam::timeControl
Description Description
An output control for function objects. General time dependent execution controller.
The default is time-step execution at every interval. The default to execute every time-step.
SourceFiles SourceFiles
outputFilterControl.C timeControl.C
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#ifndef outputFilterControl_H #ifndef timeControl_H
#define outputFilterControl_H #define timeControl_H
#include "dictionary.H"
#include "Time.H" #include "Time.H"
#include "NamedEnum.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -46,14 +44,14 @@ namespace Foam
{ {
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
Class outputFilterControl Declaration Class timeControl Declaration
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
class outputFilterControl class timeControl
{ {
public: public:
//- The output control options //- The time control options
enum timeControls enum timeControls
{ {
ocTimeStep, //!< execution is coupled to the time-step ocTimeStep, //!< execution is coupled to the time-step
@ -63,7 +61,7 @@ public:
ocRunTime, //!< run time for execution ocRunTime, //!< run time for execution
ocClockTime, //!< clock time for execution ocClockTime, //!< clock time for execution
ocCpuTime, //!< cpu time for execution ocCpuTime, //!< cpu time for execution
ocNone //!< no output ocNone //!< no execution
}; };
@ -80,7 +78,7 @@ private:
//- String representation of timeControls enums //- String representation of timeControls enums
static const NamedEnum<timeControls, 8> timeControlNames_; static const NamedEnum<timeControls, 8> timeControlNames_;
//- Type of output //- Type of time control
timeControls timeControl_; timeControls timeControl_;
//- Execution interval steps for timeStep mode //- Execution interval steps for timeStep mode
@ -97,10 +95,10 @@ private:
// Private Member Functions // Private Member Functions
//- Disallow default bitwise copy construct and assignment //- Disallow default bitwise copy construct and assignment
outputFilterControl(const outputFilterControl&); timeControl(const timeControl&);
//- Disallow default bitwise assignment //- Disallow default bitwise assignment
void operator=(const outputFilterControl&); void operator=(const timeControl&);
public: public:
@ -108,7 +106,7 @@ public:
// Constructors // Constructors
//- Construct from Time object and dictionary //- Construct from Time object and dictionary
outputFilterControl timeControl
( (
const Time&, const Time&,
const dictionary&, const dictionary&,
@ -117,7 +115,7 @@ public:
//- Destructor //- Destructor
~outputFilterControl(); ~timeControl();
// Member Functions // Member Functions
@ -148,7 +146,7 @@ public:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#include "outputFilterControlI.H" #include "timeControlI.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -0,0 +1,231 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2016 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "timeControlFunctionObject.H"
#include "polyMesh.H"
#include "mapPolyMesh.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
namespace functionObjects
{
defineTypeNameAndDebug(timeControl, 0);
}
}
// * * * * * * * * * * * * * * * Private Members * * * * * * * * * * * * * * //
void Foam::functionObjects::timeControl::readControls()
{
dict_.readIfPresent("timeStart", timeStart_);
dict_.readIfPresent("timeEnd", timeEnd_);
dict_.readIfPresent("nStepsToStartTimeChange", nStepsToStartTimeChange_);
}
bool Foam::functionObjects::timeControl::active() const
{
return
time_.value() >= timeStart_
&& time_.value() <= timeEnd_;
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::functionObjects::timeControl::timeControl
(
const word& name,
const Time& t,
const dictionary& dict
)
:
functionObject(name),
time_(t),
dict_(dict),
timeStart_(-VGREAT),
timeEnd_(VGREAT),
nStepsToStartTimeChange_
(
dict.lookupOrDefault("nStepsToStartTimeChange", 3)
),
executeControl_(t, dict, "execute"),
writeControl_(t, dict, "write"),
foPtr_(functionObject::New(name, t, dict_))
{
readControls();
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::functionObjects::timeControl::execute(const bool postProcess)
{
if (active())
{
if (postProcess || executeControl_.execute())
{
foPtr_->execute();
}
}
return true;
}
bool Foam::functionObjects::timeControl::write(const bool postProcess)
{
if (active())
{
if (postProcess || writeControl_.execute())
{
foPtr_->write();
}
}
return true;
}
bool Foam::functionObjects::timeControl::end()
{
foPtr_->end();
if (writeControl_.execute())
{
foPtr_->write();
}
return true;
}
bool Foam::functionObjects::timeControl::timeSet()
{
if (active())
{
foPtr_->timeSet();
}
return true;
}
bool Foam::functionObjects::timeControl::adjustTimeStep()
{
if
(
active()
&& writeControl_.control()
== Foam::timeControl::ocAdjustableRunTime
)
{
const label writeTimeIndex = writeControl_.executionIndex();
const scalar writeInterval = writeControl_.interval();
scalar timeToNextWrite = max
(
0.0,
(writeTimeIndex + 1)*writeInterval
- (time_.value() - time_.startTime().value())
);
scalar deltaT = time_.deltaTValue();
scalar nSteps = timeToNextWrite/deltaT - SMALL;
// functionObjects modify deltaT within nStepsToStartTimeChange
// NOTE: Potential problems arise if two function objects dump within
// the same interval
if (nSteps < nStepsToStartTimeChange_)
{
label nStepsToNextWrite = label(nSteps) + 1;
scalar newDeltaT = timeToNextWrite/nStepsToNextWrite;
// Adjust time step
if (newDeltaT < deltaT)
{
deltaT = max(newDeltaT, 0.2*deltaT);
const_cast<Time&>(time_).setDeltaT(deltaT, false);
}
}
}
return true;
}
bool Foam::functionObjects::timeControl::read
(
const dictionary& dict
)
{
if (dict != dict_)
{
dict_ = dict;
writeControl_.read(dict);
executeControl_.read(dict);
readControls();
return true;
}
else
{
return false;
}
}
void Foam::functionObjects::timeControl::updateMesh
(
const mapPolyMesh& mpm
)
{
if (active())
{
foPtr_->updateMesh(mpm);
}
}
void Foam::functionObjects::timeControl::movePoints
(
const polyMesh& mesh
)
{
if (active())
{
foPtr_->movePoints(mesh);
}
}
// ************************************************************************* //

View File

@ -0,0 +1,194 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2016 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::functionObjects::timeControl
Description
Note
Since the timeIndex is used directly from Foam::Time, it is unaffected
by user-time conversions. For example, Foam::engineTime might cause \a
writeInterval to be degrees crank angle, but the functionObject
execution \a interval would still be in timestep.
SourceFiles
timeControlFunctionObject.C
\*---------------------------------------------------------------------------*/
#ifndef functionObjects_timeControl_H
#define functionObjects_timeControl_H
#include "functionObject.H"
#include "dictionary.H"
#include "timeControl.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
namespace functionObjects
{
/*---------------------------------------------------------------------------*\
Class timeControl Declaration
\*---------------------------------------------------------------------------*/
class timeControl
:
public functionObject
{
// Private data
//- Reference to the time database
const Time& time_;
//- Input dictionary
dictionary dict_;
// Optional user inputs
//- Activation time - defaults to -VGREAT
scalar timeStart_;
//- De-activation time - defaults to VGREAT
scalar timeEnd_;
//- Number of steps before the dump-time during which deltaT
// may be changed (valid for adjustableRunTime)
label nStepsToStartTimeChange_;
//- Execute controls
Foam::timeControl executeControl_;
//- Write controls
Foam::timeControl writeControl_;
//- The functionObject to execute
autoPtr<functionObject> foPtr_;
// Private Member Functions
//- Read relevant dictionary entries
void readControls();
//- Returns true if within time bounds
bool active() const;
//- Disallow default bitwise copy construct
timeControl(const timeControl&);
//- Disallow default bitwise assignment
void operator=(const timeControl&);
public:
//- Runtime type information
TypeName("timeControl");
// Constructors
//- Construct from components
timeControl
(
const word& name,
const Time&,
const dictionary&
);
// Member Functions
// Access
//- Return time database
inline const Time& time() const;
//- Return the input dictionary
inline const dictionary& dict() const;
//- Return the region name
inline const word& regionName() const;
//- Return the execute control object
inline const Foam::timeControl& executeControl() const;
//- Return the write control object
inline const Foam::timeControl& writeControl() const;
//- Return the functionObject filter
inline const functionObject& filter() const;
// Function object control
//- Called at each ++ or += of the time-loop.
// postProcess overrides the usual executeControl behaviour and
// forces execution (used in post-processing mode)
virtual bool execute(const bool postProcess = false);
//- Called at each ++ or += of the time-loop.
// postProcess overrides the usual writeControl behaviour and
// forces writing (used in post-processing mode)
virtual bool write(const bool postProcess = false);
//- Called when Time::run() determines that the time-loop exits
virtual bool end();
//- Called when time was set at the end of the Time::operator++
virtual bool timeSet();
//- Called at the end of Time::adjustDeltaT() if adjustTime is true
virtual bool adjustTimeStep();
//- Read and set the function object if its data have changed
virtual bool read(const dictionary&);
//- Update for changes of mesh
virtual void updateMesh(const mapPolyMesh& mpm);
//- Update for changes of mesh
virtual void movePoints(const polyMesh& mesh);
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace functionObjects
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#include "timeControlFunctionObjectI.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,61 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2016 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
inline const Foam::Time& Foam::functionObjects::timeControl::time() const
{
return time_;
}
inline const Foam::dictionary& Foam::functionObjects::timeControl::dict() const
{
return dict_;
}
inline const Foam::timeControl&
Foam::functionObjects::timeControl::executeControl() const
{
return executeControl_;
}
inline const Foam::timeControl&
Foam::functionObjects::timeControl::writeControl() const
{
return writeControl_;
}
inline const Foam::functionObject&
Foam::functionObjects::timeControl::filter() const
{
return foPtr_();
}
// ************************************************************************* //

View File

@ -25,26 +25,25 @@ License
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
inline const Foam::Time& Foam::outputFilterControl::time() const inline const Foam::Time& Foam::timeControl::time() const
{ {
return time_; return time_;
} }
inline Foam::outputFilterControl::timeControls inline Foam::timeControl::timeControls Foam::timeControl::control() const
Foam::outputFilterControl::control() const
{ {
return timeControl_; return timeControl_;
} }
inline Foam::scalar Foam::outputFilterControl::interval() const inline Foam::scalar Foam::timeControl::interval() const
{ {
return interval_; return interval_;
} }
inline Foam::label Foam::outputFilterControl::executionIndex() const inline Foam::label Foam::timeControl::executionIndex() const
{ {
return executionIndex_; return executionIndex_;
} }

View File

@ -168,10 +168,17 @@ Foam::functionObject& Foam::codedFunctionObject::redirectFunctionObject() const
} }
bool Foam::codedFunctionObject::execute(const bool forceWrite) bool Foam::codedFunctionObject::execute(const bool postProcess)
{ {
updateLibrary(redirectType_); updateLibrary(redirectType_);
return redirectFunctionObject().execute(forceWrite); return redirectFunctionObject().execute(postProcess);
}
bool Foam::codedFunctionObject::write(const bool postProcess)
{
updateLibrary(redirectType_);
return redirectFunctionObject().write(postProcess);
} }

View File

@ -171,9 +171,15 @@ public:
//- Dynamically compiled functionObject //- Dynamically compiled functionObject
functionObject& redirectFunctionObject() const; functionObject& redirectFunctionObject() const;
//- Called at each ++ or += of the time-loop. forceWrite overrides the //- Called at each ++ or += of the time-loop.
// writeControl behaviour. // postProcess overrides the usual executeControl behaviour and
virtual bool execute(const bool forceWrite); // forces execution (used in post-processing mode)
virtual bool execute(const bool postProcess = false);
//- Called at each ++ or += of the time-loop.
// postProcess overrides the usual writeControl behaviour and
// forces writing always (used in post-processing mode)
virtual bool write(const bool postProcess = false);
//- Called when Time::run() determines that the time-loop exits. //- Called when Time::run() determines that the time-loop exits.
// By default it simply calls execute(). // By default it simply calls execute().

View File

@ -77,7 +77,16 @@ Foam::functionObjects::setTimeStepFunctionObject::time() const
bool Foam::functionObjects::setTimeStepFunctionObject::execute bool Foam::functionObjects::setTimeStepFunctionObject::execute
( (
const bool forceWrite const bool postProcess
)
{
return true;
}
bool Foam::functionObjects::setTimeStepFunctionObject::write
(
const bool postProcess
) )
{ {
return true; return true;

View File

@ -109,8 +109,15 @@ public:
// Function object control // Function object control
//- Called at each ++ or += of the time-loop //- Called at each ++ or += of the time-loop.
virtual bool execute(const bool forceWrite); // postProcess overrides the usual executeControl behaviour and
// forces execution (used in post-processing mode)
virtual bool execute(const bool postProcess = false);
//- Called at each ++ or += of the time-loop.
// postProcess overrides the usual writeControl behaviour and
// forces writing always (used in post-processing mode)
virtual bool write(const bool postProcess = false);
//- Called when Time::run() determines that the time-loop exits //- Called when Time::run() determines that the time-loop exits
virtual bool end(); virtual bool end();