mirror of
https://github.com/OpenFOAM/OpenFOAM-6.git
synced 2025-12-08 06:57:46 +00:00
functionObjects: Separated 'execute' and 'write' functions to simplify support for post-processing
This commit is contained in:
@ -218,8 +218,8 @@ db/functionObjects/functionObject/functionObject.C
|
||||
db/functionObjects/functionObjectList/functionObjectList.C
|
||||
db/functionObjects/functionObjectFile/functionObjectFile.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)/TimePaths.C
|
||||
|
||||
@ -88,17 +88,30 @@ Foam::OutputFilterFunctionObject<OutputFilter>::OutputFilterFunctionObject
|
||||
template<class OutputFilter>
|
||||
bool Foam::OutputFilterFunctionObject<OutputFilter>::execute
|
||||
(
|
||||
const bool forceWrite
|
||||
const bool postProcess
|
||||
)
|
||||
{
|
||||
if (active())
|
||||
{
|
||||
if (evaluateControl_.execute())
|
||||
if (postProcess || evaluateControl_.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();
|
||||
}
|
||||
@ -141,7 +154,7 @@ bool Foam::OutputFilterFunctionObject<OutputFilter>::adjustTimeStep()
|
||||
(
|
||||
active()
|
||||
&& writeControl_.control()
|
||||
== outputFilterControl::ocAdjustableRunTime
|
||||
== timeControl::ocAdjustableRunTime
|
||||
)
|
||||
{
|
||||
const label writeTimeIndex = writeControl_.executionIndex();
|
||||
|
||||
@ -44,7 +44,7 @@ SourceFiles
|
||||
|
||||
#include "functionObject.H"
|
||||
#include "dictionary.H"
|
||||
#include "outputFilterControl.H"
|
||||
#include "timeControl.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -83,10 +83,10 @@ class OutputFilterFunctionObject
|
||||
|
||||
|
||||
//- Output controls
|
||||
outputFilterControl writeControl_;
|
||||
timeControl writeControl_;
|
||||
|
||||
//- Evaluate controls
|
||||
outputFilterControl evaluateControl_;
|
||||
timeControl evaluateControl_;
|
||||
|
||||
//- The output filter
|
||||
OutputFilter filter_;
|
||||
@ -138,7 +138,7 @@ public:
|
||||
inline const word& regionName() const;
|
||||
|
||||
//- Return the output control object
|
||||
inline const outputFilterControl& writeControl() const;
|
||||
inline const timeControl& writeControl() const;
|
||||
|
||||
//- Return the output filter
|
||||
inline const OutputFilter& outputFilter() const;
|
||||
@ -147,9 +147,14 @@ public:
|
||||
// Function object control
|
||||
|
||||
//- 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)
|
||||
virtual bool execute(const bool forceWrite = false);
|
||||
virtual bool write(const bool postProcess = false);
|
||||
|
||||
//- Called when Time::run() determines that the time-loop exits
|
||||
virtual bool end();
|
||||
|
||||
@ -42,7 +42,7 @@ Foam::OutputFilterFunctionObject<OutputFilter>::dict() const
|
||||
|
||||
|
||||
template<class OutputFilter>
|
||||
inline const Foam::outputFilterControl&
|
||||
inline const Foam::timeControl&
|
||||
Foam::OutputFilterFunctionObject<OutputFilter>::writeControl() const
|
||||
{
|
||||
return writeControl_;
|
||||
|
||||
@ -110,7 +110,7 @@ const Foam::word& Foam::functionObject::name() const
|
||||
|
||||
bool Foam::functionObject::end()
|
||||
{
|
||||
return execute(false);
|
||||
return execute();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -197,10 +197,15 @@ public:
|
||||
//- Name
|
||||
virtual const word& name() const;
|
||||
|
||||
//- Called at each ++ or += of the time-loop. forceWrite overrides
|
||||
// the usual writeControl behaviour and forces writing always
|
||||
// (used in post-processing mode)
|
||||
virtual bool execute(const bool forceWrite) = 0;
|
||||
//- 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) = 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.
|
||||
// By default it simply calls execute().
|
||||
|
||||
@ -47,7 +47,6 @@ SourceFiles
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class functionObjectFile Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -198,7 +198,8 @@ bool Foam::functionObjectList::execute(const bool forceWrite)
|
||||
|
||||
forAll(*this, objectI)
|
||||
{
|
||||
ok = operator[](objectI).execute(forceWrite) && ok;
|
||||
ok = operator[](objectI).execute(postProcess) && ok;
|
||||
ok = operator[](objectI).write(postProcess) && ok;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -170,10 +170,10 @@ public:
|
||||
//- Called at the start of the time-loop
|
||||
bool start();
|
||||
|
||||
//- Called at each ++ or += of the time-loop. forceWrite overrides
|
||||
// the usual writeControl behaviour and forces writing always
|
||||
// (used in post-processing mode)
|
||||
bool execute(const bool forceWrite = false);
|
||||
//- Called at each ++ or += of the time-loop.
|
||||
// postProcess overrides the usual executeControl behaviour and
|
||||
// forces execution (used in post-processing mode)
|
||||
bool execute(const bool postProcess = false);
|
||||
|
||||
//- Called when Time::run() determines that the time-loop exits
|
||||
bool end();
|
||||
|
||||
@ -23,7 +23,7 @@ License
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "outputFilterControl.H"
|
||||
#include "timeControl.H"
|
||||
#include "PstreamReduceOps.H"
|
||||
|
||||
// * * * * * * * * * * * * * Static Member Data * * * * * * * * * * * * * * //
|
||||
@ -31,7 +31,7 @@ License
|
||||
namespace Foam
|
||||
{
|
||||
template<>
|
||||
const char* NamedEnum<outputFilterControl::timeControls, 8>::
|
||||
const char* NamedEnum<timeControl::timeControls, 8>::
|
||||
names[] =
|
||||
{
|
||||
"timeStep",
|
||||
@ -45,13 +45,13 @@ namespace Foam
|
||||
};
|
||||
}
|
||||
|
||||
const Foam::NamedEnum<Foam::outputFilterControl::timeControls, 8>
|
||||
Foam::outputFilterControl::timeControlNames_;
|
||||
const Foam::NamedEnum<Foam::timeControl::timeControls, 8>
|
||||
Foam::timeControl::timeControlNames_;
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::outputFilterControl::outputFilterControl
|
||||
Foam::timeControl::timeControl
|
||||
(
|
||||
const Time& t,
|
||||
const dictionary& dict,
|
||||
@ -71,13 +71,13 @@ Foam::outputFilterControl::outputFilterControl
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::outputFilterControl::~outputFilterControl()
|
||||
Foam::timeControl::~timeControl()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::outputFilterControl::read(const dictionary& dict)
|
||||
void Foam::timeControl::read(const dictionary& dict)
|
||||
{
|
||||
word controlName(prefix_ + "Control");
|
||||
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_)
|
||||
{
|
||||
@ -22,23 +22,21 @@ License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
Foam::outputFilterControl
|
||||
Foam::timeControl
|
||||
|
||||
Description
|
||||
An output control for function objects.
|
||||
The default is time-step execution at every interval.
|
||||
General time dependent execution controller.
|
||||
The default to execute every time-step.
|
||||
|
||||
SourceFiles
|
||||
outputFilterControl.C
|
||||
timeControl.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef outputFilterControl_H
|
||||
#define outputFilterControl_H
|
||||
#ifndef timeControl_H
|
||||
#define timeControl_H
|
||||
|
||||
#include "dictionary.H"
|
||||
#include "Time.H"
|
||||
#include "NamedEnum.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -46,14 +44,14 @@ namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class outputFilterControl Declaration
|
||||
Class timeControl Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class outputFilterControl
|
||||
class timeControl
|
||||
{
|
||||
public:
|
||||
|
||||
//- The output control options
|
||||
//- The time control options
|
||||
enum timeControls
|
||||
{
|
||||
ocTimeStep, //!< execution is coupled to the time-step
|
||||
@ -63,7 +61,7 @@ public:
|
||||
ocRunTime, //!< run time for execution
|
||||
ocClockTime, //!< clock time for execution
|
||||
ocCpuTime, //!< cpu time for execution
|
||||
ocNone //!< no output
|
||||
ocNone //!< no execution
|
||||
};
|
||||
|
||||
|
||||
@ -80,7 +78,7 @@ private:
|
||||
//- String representation of timeControls enums
|
||||
static const NamedEnum<timeControls, 8> timeControlNames_;
|
||||
|
||||
//- Type of output
|
||||
//- Type of time control
|
||||
timeControls timeControl_;
|
||||
|
||||
//- Execution interval steps for timeStep mode
|
||||
@ -97,10 +95,10 @@ private:
|
||||
// Private Member Functions
|
||||
|
||||
//- Disallow default bitwise copy construct and assignment
|
||||
outputFilterControl(const outputFilterControl&);
|
||||
timeControl(const timeControl&);
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const outputFilterControl&);
|
||||
void operator=(const timeControl&);
|
||||
|
||||
|
||||
public:
|
||||
@ -108,7 +106,7 @@ public:
|
||||
// Constructors
|
||||
|
||||
//- Construct from Time object and dictionary
|
||||
outputFilterControl
|
||||
timeControl
|
||||
(
|
||||
const Time&,
|
||||
const dictionary&,
|
||||
@ -117,7 +115,7 @@ public:
|
||||
|
||||
|
||||
//- Destructor
|
||||
~outputFilterControl();
|
||||
~timeControl();
|
||||
|
||||
|
||||
// Member Functions
|
||||
@ -148,7 +146,7 @@ public:
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#include "outputFilterControlI.H"
|
||||
#include "timeControlI.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -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
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -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_();
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -25,26 +25,25 @@ License
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
inline const Foam::Time& Foam::outputFilterControl::time() const
|
||||
inline const Foam::Time& Foam::timeControl::time() const
|
||||
{
|
||||
return time_;
|
||||
}
|
||||
|
||||
|
||||
inline Foam::outputFilterControl::timeControls
|
||||
Foam::outputFilterControl::control() const
|
||||
inline Foam::timeControl::timeControls Foam::timeControl::control() const
|
||||
{
|
||||
return timeControl_;
|
||||
}
|
||||
|
||||
|
||||
inline Foam::scalar Foam::outputFilterControl::interval() const
|
||||
inline Foam::scalar Foam::timeControl::interval() const
|
||||
{
|
||||
return interval_;
|
||||
}
|
||||
|
||||
|
||||
inline Foam::label Foam::outputFilterControl::executionIndex() const
|
||||
inline Foam::label Foam::timeControl::executionIndex() const
|
||||
{
|
||||
return executionIndex_;
|
||||
}
|
||||
@ -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_);
|
||||
return redirectFunctionObject().execute(forceWrite);
|
||||
return redirectFunctionObject().execute(postProcess);
|
||||
}
|
||||
|
||||
|
||||
bool Foam::codedFunctionObject::write(const bool postProcess)
|
||||
{
|
||||
updateLibrary(redirectType_);
|
||||
return redirectFunctionObject().write(postProcess);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -171,9 +171,15 @@ public:
|
||||
//- Dynamically compiled functionObject
|
||||
functionObject& redirectFunctionObject() const;
|
||||
|
||||
//- Called at each ++ or += of the time-loop. forceWrite overrides the
|
||||
// writeControl behaviour.
|
||||
virtual bool execute(const bool forceWrite);
|
||||
//- 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 always (used in post-processing mode)
|
||||
virtual bool write(const bool postProcess = false);
|
||||
|
||||
//- Called when Time::run() determines that the time-loop exits.
|
||||
// By default it simply calls execute().
|
||||
|
||||
@ -77,7 +77,16 @@ Foam::functionObjects::setTimeStepFunctionObject::time() const
|
||||
|
||||
bool Foam::functionObjects::setTimeStepFunctionObject::execute
|
||||
(
|
||||
const bool forceWrite
|
||||
const bool postProcess
|
||||
)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool Foam::functionObjects::setTimeStepFunctionObject::write
|
||||
(
|
||||
const bool postProcess
|
||||
)
|
||||
{
|
||||
return true;
|
||||
|
||||
@ -109,8 +109,15 @@ public:
|
||||
|
||||
// Function object control
|
||||
|
||||
//- Called at each ++ or += of the time-loop
|
||||
virtual bool execute(const bool forceWrite);
|
||||
//- 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 always (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();
|
||||
|
||||
Reference in New Issue
Block a user