diff --git a/src/OpenFOAM/Make/files b/src/OpenFOAM/Make/files index 7fbff70da6..cb62163050 100644 --- a/src/OpenFOAM/Make/files +++ b/src/OpenFOAM/Make/files @@ -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 diff --git a/src/OpenFOAM/db/functionObjects/OutputFilterFunctionObject/OutputFilterFunctionObject.C b/src/OpenFOAM/db/functionObjects/OutputFilterFunctionObject/OutputFilterFunctionObject.C index 7e01bb9cf5..459bc5492d 100644 --- a/src/OpenFOAM/db/functionObjects/OutputFilterFunctionObject/OutputFilterFunctionObject.C +++ b/src/OpenFOAM/db/functionObjects/OutputFilterFunctionObject/OutputFilterFunctionObject.C @@ -88,17 +88,30 @@ Foam::OutputFilterFunctionObject::OutputFilterFunctionObject template bool Foam::OutputFilterFunctionObject::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 +bool Foam::OutputFilterFunctionObject::write +( + const bool postProcess +) +{ + if (active()) + { + if (postProcess || writeControl_.execute()) { filter_.write(); } @@ -141,7 +154,7 @@ bool Foam::OutputFilterFunctionObject::adjustTimeStep() ( active() && writeControl_.control() - == outputFilterControl::ocAdjustableRunTime + == timeControl::ocAdjustableRunTime ) { const label writeTimeIndex = writeControl_.executionIndex(); diff --git a/src/OpenFOAM/db/functionObjects/OutputFilterFunctionObject/OutputFilterFunctionObject.H b/src/OpenFOAM/db/functionObjects/OutputFilterFunctionObject/OutputFilterFunctionObject.H index e0cd4e8c36..6aa998052f 100644 --- a/src/OpenFOAM/db/functionObjects/OutputFilterFunctionObject/OutputFilterFunctionObject.H +++ b/src/OpenFOAM/db/functionObjects/OutputFilterFunctionObject/OutputFilterFunctionObject.H @@ -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(); diff --git a/src/OpenFOAM/db/functionObjects/OutputFilterFunctionObject/OutputFilterFunctionObjectI.H b/src/OpenFOAM/db/functionObjects/OutputFilterFunctionObject/OutputFilterFunctionObjectI.H index 502c701c0d..42ea890c80 100644 --- a/src/OpenFOAM/db/functionObjects/OutputFilterFunctionObject/OutputFilterFunctionObjectI.H +++ b/src/OpenFOAM/db/functionObjects/OutputFilterFunctionObject/OutputFilterFunctionObjectI.H @@ -42,7 +42,7 @@ Foam::OutputFilterFunctionObject::dict() const template -inline const Foam::outputFilterControl& +inline const Foam::timeControl& Foam::OutputFilterFunctionObject::writeControl() const { return writeControl_; diff --git a/src/OpenFOAM/db/functionObjects/functionObject/functionObject.C b/src/OpenFOAM/db/functionObjects/functionObject/functionObject.C index 9bcdd6cda0..07ad55ad9a 100644 --- a/src/OpenFOAM/db/functionObjects/functionObject/functionObject.C +++ b/src/OpenFOAM/db/functionObjects/functionObject/functionObject.C @@ -110,7 +110,7 @@ const Foam::word& Foam::functionObject::name() const bool Foam::functionObject::end() { - return execute(false); + return execute(); } diff --git a/src/OpenFOAM/db/functionObjects/functionObject/functionObject.H b/src/OpenFOAM/db/functionObjects/functionObject/functionObject.H index 40d03a60be..2b2a0c94d0 100644 --- a/src/OpenFOAM/db/functionObjects/functionObject/functionObject.H +++ b/src/OpenFOAM/db/functionObjects/functionObject/functionObject.H @@ -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(). diff --git a/src/OpenFOAM/db/functionObjects/functionObjectFile/functionObjectFile.H b/src/OpenFOAM/db/functionObjects/functionObjectFile/functionObjectFile.H index 7a3ad27390..a48747452d 100644 --- a/src/OpenFOAM/db/functionObjects/functionObjectFile/functionObjectFile.H +++ b/src/OpenFOAM/db/functionObjects/functionObjectFile/functionObjectFile.H @@ -47,7 +47,6 @@ SourceFiles namespace Foam { - /*---------------------------------------------------------------------------*\ Class functionObjectFile Declaration \*---------------------------------------------------------------------------*/ diff --git a/src/OpenFOAM/db/functionObjects/functionObjectList/functionObjectList.C b/src/OpenFOAM/db/functionObjects/functionObjectList/functionObjectList.C index 0685f099c7..606ce67eb4 100644 --- a/src/OpenFOAM/db/functionObjects/functionObjectList/functionObjectList.C +++ b/src/OpenFOAM/db/functionObjects/functionObjectList/functionObjectList.C @@ -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; } } diff --git a/src/OpenFOAM/db/functionObjects/functionObjectList/functionObjectList.H b/src/OpenFOAM/db/functionObjects/functionObjectList/functionObjectList.H index ca373b0c11..686b5d2393 100644 --- a/src/OpenFOAM/db/functionObjects/functionObjectList/functionObjectList.H +++ b/src/OpenFOAM/db/functionObjects/functionObjectList/functionObjectList.H @@ -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(); diff --git a/src/OpenFOAM/db/functionObjects/outputFilterControl/outputFilterControl.C b/src/OpenFOAM/db/functionObjects/timeControl/timeControl.C similarity index 93% rename from src/OpenFOAM/db/functionObjects/outputFilterControl/outputFilterControl.C rename to src/OpenFOAM/db/functionObjects/timeControl/timeControl.C index d09b004058..88eac71200 100644 --- a/src/OpenFOAM/db/functionObjects/outputFilterControl/outputFilterControl.C +++ b/src/OpenFOAM/db/functionObjects/timeControl/timeControl.C @@ -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:: + const char* NamedEnum:: names[] = { "timeStep", @@ -45,13 +45,13 @@ namespace Foam }; } -const Foam::NamedEnum - Foam::outputFilterControl::timeControlNames_; +const Foam::NamedEnum + 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_) { diff --git a/src/OpenFOAM/db/functionObjects/outputFilterControl/outputFilterControl.H b/src/OpenFOAM/db/functionObjects/timeControl/timeControl.H similarity index 85% rename from src/OpenFOAM/db/functionObjects/outputFilterControl/outputFilterControl.H rename to src/OpenFOAM/db/functionObjects/timeControl/timeControl.H index 016922f862..c7dc723128 100644 --- a/src/OpenFOAM/db/functionObjects/outputFilterControl/outputFilterControl.H +++ b/src/OpenFOAM/db/functionObjects/timeControl/timeControl.H @@ -22,23 +22,21 @@ License along with OpenFOAM. If not, see . 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 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" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/OpenFOAM/db/functionObjects/timeControl/timeControlFunctionObject.C b/src/OpenFOAM/db/functionObjects/timeControl/timeControlFunctionObject.C new file mode 100644 index 0000000000..0d73f0b611 --- /dev/null +++ b/src/OpenFOAM/db/functionObjects/timeControl/timeControlFunctionObject.C @@ -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 . + +\*---------------------------------------------------------------------------*/ + +#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_).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); + } +} + + +// ************************************************************************* // diff --git a/src/OpenFOAM/db/functionObjects/timeControl/timeControlFunctionObject.H b/src/OpenFOAM/db/functionObjects/timeControl/timeControlFunctionObject.H new file mode 100644 index 0000000000..b1cba3b6b0 --- /dev/null +++ b/src/OpenFOAM/db/functionObjects/timeControl/timeControlFunctionObject.H @@ -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 . + +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 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 + +// ************************************************************************* // diff --git a/src/OpenFOAM/db/functionObjects/timeControl/timeControlFunctionObjectI.H b/src/OpenFOAM/db/functionObjects/timeControl/timeControlFunctionObjectI.H new file mode 100644 index 0000000000..e759243b5c --- /dev/null +++ b/src/OpenFOAM/db/functionObjects/timeControl/timeControlFunctionObjectI.H @@ -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 . + +\*---------------------------------------------------------------------------*/ + +// * * * * * * * * * * * * * * * 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_(); +} + + +// ************************************************************************* // diff --git a/src/OpenFOAM/db/functionObjects/outputFilterControl/outputFilterControlI.H b/src/OpenFOAM/db/functionObjects/timeControl/timeControlI.H similarity index 83% rename from src/OpenFOAM/db/functionObjects/outputFilterControl/outputFilterControlI.H rename to src/OpenFOAM/db/functionObjects/timeControl/timeControlI.H index 0469dac296..1a50592d89 100644 --- a/src/OpenFOAM/db/functionObjects/outputFilterControl/outputFilterControlI.H +++ b/src/OpenFOAM/db/functionObjects/timeControl/timeControlI.H @@ -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_; } diff --git a/src/postProcessing/functionObjects/utilities/codedFunctionObject/codedFunctionObject.C b/src/postProcessing/functionObjects/utilities/codedFunctionObject/codedFunctionObject.C index 8ae77458b0..2e1c78dd6a 100644 --- a/src/postProcessing/functionObjects/utilities/codedFunctionObject/codedFunctionObject.C +++ b/src/postProcessing/functionObjects/utilities/codedFunctionObject/codedFunctionObject.C @@ -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); } diff --git a/src/postProcessing/functionObjects/utilities/codedFunctionObject/codedFunctionObject.H b/src/postProcessing/functionObjects/utilities/codedFunctionObject/codedFunctionObject.H index 7ceff81034..b5a1ec3637 100644 --- a/src/postProcessing/functionObjects/utilities/codedFunctionObject/codedFunctionObject.H +++ b/src/postProcessing/functionObjects/utilities/codedFunctionObject/codedFunctionObject.H @@ -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(). diff --git a/src/postProcessing/functionObjects/utilities/setTimeStep/setTimeStepFunctionObject.C b/src/postProcessing/functionObjects/utilities/setTimeStep/setTimeStepFunctionObject.C index c8ab617c0a..760db856d7 100644 --- a/src/postProcessing/functionObjects/utilities/setTimeStep/setTimeStepFunctionObject.C +++ b/src/postProcessing/functionObjects/utilities/setTimeStep/setTimeStepFunctionObject.C @@ -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; diff --git a/src/postProcessing/functionObjects/utilities/setTimeStep/setTimeStepFunctionObject.H b/src/postProcessing/functionObjects/utilities/setTimeStep/setTimeStepFunctionObject.H index 84477be426..6a31dedbc8 100644 --- a/src/postProcessing/functionObjects/utilities/setTimeStep/setTimeStepFunctionObject.H +++ b/src/postProcessing/functionObjects/utilities/setTimeStep/setTimeStepFunctionObject.H @@ -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();