From ad7f29466a9c918b49fe971c7ff3ccaf707c61df Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Fri, 25 Jan 2019 08:56:21 +0100 Subject: [PATCH] ENH: added timeFunctionObject virtual class in inheritance hierarchy - simply a functionObject with an additional Time reference, which is a combination frequently used by concrete functionObjects --- src/OpenFOAM/Make/files | 19 +-- .../db/functionObjects/logFiles/logFiles.C | 6 - .../db/functionObjects/logFiles/logFiles.H | 4 +- .../regionFunctionObject.H | 12 +- .../stateFunctionObject/stateFunctionObject.C | 9 +- .../stateFunctionObject/stateFunctionObject.H | 35 +++--- .../functionObjects/timeControl/timeControl.C | 13 +-- .../functionObjects/timeControl/timeControl.H | 2 +- .../timeControl/timeControlFunctionObject.C | 11 +- .../timeControl/timeControlFunctionObject.H | 16 +-- .../timeControl/timeControlFunctionObjectI.H | 6 - .../timeFunctionObject/timeFunctionObject.C | 42 +++++++ .../timeFunctionObject/timeFunctionObject.H | 108 ++++++++++++++++++ .../db/functionObjects/writeFile/writeFile.H | 6 +- .../field/externalCoupled/externalCoupled.C | 3 +- .../field/externalCoupled/externalCoupled.H | 9 +- src/functionObjects/utilities/abort/abort.C | 3 +- src/functionObjects/utilities/abort/abort.H | 7 +- .../codedFunctionObject/codedFunctionObject.C | 11 +- .../codedFunctionObject/codedFunctionObject.H | 11 +- .../setTimeStep/setTimeStepFunctionObject.C | 16 +-- .../setTimeStep/setTimeStepFunctionObject.H | 18 +-- .../timeActivatedFileUpdate.C | 9 +- .../timeActivatedFileUpdate.H | 13 +-- .../utilities/vtkWrite/vtkWrite.C | 3 +- .../utilities/vtkWrite/vtkWrite.H | 7 +- .../utilities/writeObjects/writeObjects.H | 4 +- 27 files changed, 225 insertions(+), 178 deletions(-) create mode 100644 src/OpenFOAM/db/functionObjects/timeFunctionObject/timeFunctionObject.C create mode 100644 src/OpenFOAM/db/functionObjects/timeFunctionObject/timeFunctionObject.H diff --git a/src/OpenFOAM/Make/files b/src/OpenFOAM/Make/files index b0e2f003e5..8bc7b414da 100644 --- a/src/OpenFOAM/Make/files +++ b/src/OpenFOAM/Make/files @@ -284,14 +284,17 @@ $(dll)/dynamicCode/dynamicCode.C $(dll)/dynamicCode/dynamicCodeContext.C $(dll)/codedBase/codedBase.C -db/functionObjects/functionObject/functionObject.C -db/functionObjects/functionObjectList/functionObjectList.C -db/functionObjects/stateFunctionObject/stateFunctionObject.C -db/functionObjects/writeFile/writeFile.C -db/functionObjects/logFiles/logFiles.C -db/functionObjects/timeControl/timeControl.C -db/functionObjects/timeControl/timeControlFunctionObject.C -db/functionObjects/regionFunctionObject/regionFunctionObject.C +funcObjs = db/functionObjects + +$(funcObjs)/functionObject/functionObject.C +$(funcObjs)/functionObjectList/functionObjectList.C +$(funcObjs)/stateFunctionObject/stateFunctionObject.C +$(funcObjs)/timeFunctionObject/timeFunctionObject.C +$(funcObjs)/writeFile/writeFile.C +$(funcObjs)/logFiles/logFiles.C +$(funcObjs)/timeControl/timeControl.C +$(funcObjs)/timeControl/timeControlFunctionObject.C +$(funcObjs)/regionFunctionObject/regionFunctionObject.C Time = db/Time $(Time)/TimePaths.C diff --git a/src/OpenFOAM/db/functionObjects/logFiles/logFiles.C b/src/OpenFOAM/db/functionObjects/logFiles/logFiles.C index 1281860f07..0fcf85f7a8 100644 --- a/src/OpenFOAM/db/functionObjects/logFiles/logFiles.C +++ b/src/OpenFOAM/db/functionObjects/logFiles/logFiles.C @@ -102,12 +102,6 @@ Foam::functionObjects::logFiles::logFiles } -// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // - -Foam::functionObjects::logFiles::~logFiles() -{} - - // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // const Foam::wordList& Foam::functionObjects::logFiles::names() const diff --git a/src/OpenFOAM/db/functionObjects/logFiles/logFiles.H b/src/OpenFOAM/db/functionObjects/logFiles/logFiles.H index 5ec4e53a63..d802d36dce 100644 --- a/src/OpenFOAM/db/functionObjects/logFiles/logFiles.H +++ b/src/OpenFOAM/db/functionObjects/logFiles/logFiles.H @@ -51,7 +51,7 @@ namespace functionObjects { /*---------------------------------------------------------------------------*\ - Class logFiles Declaration + Class functionObjects::logFiles Declaration \*---------------------------------------------------------------------------*/ class logFiles @@ -116,7 +116,7 @@ public: //- Destructor - virtual ~logFiles(); + virtual ~logFiles() = default; // Member Functions diff --git a/src/OpenFOAM/db/functionObjects/regionFunctionObject/regionFunctionObject.H b/src/OpenFOAM/db/functionObjects/regionFunctionObject/regionFunctionObject.H index 8e67e3cc85..fd0e4b3fa8 100644 --- a/src/OpenFOAM/db/functionObjects/regionFunctionObject/regionFunctionObject.H +++ b/src/OpenFOAM/db/functionObjects/regionFunctionObject/regionFunctionObject.H @@ -48,14 +48,14 @@ SourceFiles namespace Foam { -// Forward declaration of classes +// Forward declarations class objectRegistry; namespace functionObjects { /*---------------------------------------------------------------------------*\ - Class regionFunctionObject Declaration + Class functionObjects::regionFunctionObject Declaration \*---------------------------------------------------------------------------*/ class regionFunctionObject @@ -65,7 +65,7 @@ class regionFunctionObject protected: - // Protected member data + // Protected Member Data //- Reference to the region objectRegistry const objectRegistry& obr_; @@ -76,7 +76,7 @@ protected: const objectRegistry& subObr_; - // Protected member functions + // Protected Member Functions //- Selector for alternative sub-registry, // when the keyword %subRegion is present in the dictionary @@ -148,10 +148,6 @@ protected: bool clearObject(const word& fieldName); -private: - - // Private Member Functions - //- No copy construct regionFunctionObject(const regionFunctionObject&) = delete; diff --git a/src/OpenFOAM/db/functionObjects/stateFunctionObject/stateFunctionObject.C b/src/OpenFOAM/db/functionObjects/stateFunctionObject/stateFunctionObject.C index b716f50af7..62bde8bafe 100644 --- a/src/OpenFOAM/db/functionObjects/stateFunctionObject/stateFunctionObject.C +++ b/src/OpenFOAM/db/functionObjects/stateFunctionObject/stateFunctionObject.C @@ -52,14 +52,7 @@ Foam::functionObjects::stateFunctionObject::stateFunctionObject const Time& runTime ) : - functionObject(name), - time_(runTime) -{} - - -// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // - -Foam::functionObjects::stateFunctionObject::~stateFunctionObject() + timeFunctionObject(name, runTime) {} diff --git a/src/OpenFOAM/db/functionObjects/stateFunctionObject/stateFunctionObject.H b/src/OpenFOAM/db/functionObjects/stateFunctionObject/stateFunctionObject.H index 32e51cd46e..13ce66a852 100644 --- a/src/OpenFOAM/db/functionObjects/stateFunctionObject/stateFunctionObject.H +++ b/src/OpenFOAM/db/functionObjects/stateFunctionObject/stateFunctionObject.H @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2015 OpenFOAM Foundation - \\/ M anipulation | Copyright (C) 2015-2016 OpenCFD Ltd. + \\/ M anipulation | Copyright (C) 2015-2019 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -22,7 +22,7 @@ License along with OpenFOAM. If not, see . Class - Foam::functionObjectState + Foam::functionObjects::stateFunctionObject Description Base class for function objects, adding functionality to read/write state @@ -46,7 +46,7 @@ SourceFiles #ifndef functionObjects_stateFunctionObject_H #define functionObjects_stateFunctionObject_H -#include "functionObject.H" +#include "timeFunctionObject.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -59,12 +59,12 @@ namespace functionObjects { /*---------------------------------------------------------------------------*\ - Class stateFunctionObject Declaration + Class functionObjects::stateFunctionObject Declaration \*---------------------------------------------------------------------------*/ class stateFunctionObject : - public functionObject + public functionObjects::timeFunctionObject { private: @@ -75,24 +75,9 @@ private: static const word resultsName_; - // Private Member Functions - - //- No copy construct - stateFunctionObject(const stateFunctionObject&) = delete; - - //- No copy assignment - void operator=(const stateFunctionObject&) = delete; - - protected: - // Protected Member Data - - //- Reference to the time database - const Time& time_; - - - // Protacted Member Functions + // Protected Member Functions //- Return a const reference to the state dictionary const IOdictionary& stateDict() const; @@ -101,6 +86,12 @@ protected: IOdictionary& stateDict(); + //- No copy construct + stateFunctionObject(const stateFunctionObject&) = delete; + + //- No copy assignment + void operator=(const stateFunctionObject&) = delete; + public: @@ -111,7 +102,7 @@ public: //- Destructor - ~stateFunctionObject(); + virtual ~stateFunctionObject() = default; // Member Functions diff --git a/src/OpenFOAM/db/functionObjects/timeControl/timeControl.C b/src/OpenFOAM/db/functionObjects/timeControl/timeControl.C index 18742f521c..a1bf112d53 100644 --- a/src/OpenFOAM/db/functionObjects/timeControl/timeControl.C +++ b/src/OpenFOAM/db/functionObjects/timeControl/timeControl.C @@ -66,12 +66,6 @@ Foam::timeControl::timeControl } -// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // - -Foam::timeControl::~timeControl() -{} - - // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // bool Foam::timeControl::entriesPresent @@ -82,12 +76,7 @@ bool Foam::timeControl::entriesPresent { const word controlName(prefix + "Control"); - if (dict.found(controlName)) - { - return true; - } - - return false; + return dict.found(controlName); } diff --git a/src/OpenFOAM/db/functionObjects/timeControl/timeControl.H b/src/OpenFOAM/db/functionObjects/timeControl/timeControl.H index d6e9086865..22f251a4b3 100644 --- a/src/OpenFOAM/db/functionObjects/timeControl/timeControl.H +++ b/src/OpenFOAM/db/functionObjects/timeControl/timeControl.H @@ -116,7 +116,7 @@ public: //- Destructor - ~timeControl(); + ~timeControl() = default; // Member Functions diff --git a/src/OpenFOAM/db/functionObjects/timeControl/timeControlFunctionObject.C b/src/OpenFOAM/db/functionObjects/timeControl/timeControlFunctionObject.C index ee16106c4f..d459a9d126 100644 --- a/src/OpenFOAM/db/functionObjects/timeControl/timeControlFunctionObject.C +++ b/src/OpenFOAM/db/functionObjects/timeControl/timeControlFunctionObject.C @@ -442,12 +442,11 @@ void Foam::functionObjects::timeControl::calcDeltaTCoeff Foam::functionObjects::timeControl::timeControl ( const word& name, - const Time& t, + const Time& runTime, const dictionary& dict ) : - functionObject(name), - time_(t), + timeFunctionObject(name, runTime), dict_(dict), controlMode_(controlMode::TIME), timeStart_(-VGREAT), @@ -455,9 +454,9 @@ Foam::functionObjects::timeControl::timeControl triggerStart_(labelMax), triggerEnd_(labelMax), nStepsToStartTimeChange_(labelMax), - executeControl_(t, dict, "execute"), - writeControl_(t, dict, "write"), - foPtr_(functionObject::New(name, t, dict_)), + executeControl_(runTime, dict, "execute"), + writeControl_(runTime, dict, "write"), + foPtr_(functionObject::New(name, runTime, dict_)), executeTimeIndex_(-1), deltaT0_(0), seriesDTCoeff_(GREAT) diff --git a/src/OpenFOAM/db/functionObjects/timeControl/timeControlFunctionObject.H b/src/OpenFOAM/db/functionObjects/timeControl/timeControlFunctionObject.H index 284d73c160..32a4376400 100644 --- a/src/OpenFOAM/db/functionObjects/timeControl/timeControlFunctionObject.H +++ b/src/OpenFOAM/db/functionObjects/timeControl/timeControlFunctionObject.H @@ -56,7 +56,7 @@ SourceFiles #ifndef functionObjects_timeControl_H #define functionObjects_timeControl_H -#include "functionObject.H" +#include "timeFunctionObject.H" #include "dictionary.H" #include "timeControl.H" @@ -68,12 +68,12 @@ namespace functionObjects { /*---------------------------------------------------------------------------*\ - Class timeControl Declaration + Class functionObjects::timeControl Declaration \*---------------------------------------------------------------------------*/ class timeControl : - public functionObject + public functionObjects::timeFunctionObject { public: @@ -96,9 +96,6 @@ private: // Private data - //- Reference to the time database - const Time& time_; - //- Input dictionary dictionary dict_; @@ -198,8 +195,8 @@ public: timeControl ( const word& name, - const Time&, - const dictionary& + const Time& runTime, + const dictionary& dict ); @@ -207,9 +204,6 @@ public: // Access - //- Return time database - inline const Time& time() const; - //- Return the input dictionary inline const dictionary& dict() const; diff --git a/src/OpenFOAM/db/functionObjects/timeControl/timeControlFunctionObjectI.H b/src/OpenFOAM/db/functionObjects/timeControl/timeControlFunctionObjectI.H index 7fddc48b55..a27b9ca613 100644 --- a/src/OpenFOAM/db/functionObjects/timeControl/timeControlFunctionObjectI.H +++ b/src/OpenFOAM/db/functionObjects/timeControl/timeControlFunctionObjectI.H @@ -25,12 +25,6 @@ License // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -inline const Foam::Time& Foam::functionObjects::timeControl::time() const -{ - return time_; -} - - inline const Foam::dictionary& Foam::functionObjects::timeControl::dict() const { return dict_; diff --git a/src/OpenFOAM/db/functionObjects/timeFunctionObject/timeFunctionObject.C b/src/OpenFOAM/db/functionObjects/timeFunctionObject/timeFunctionObject.C new file mode 100644 index 0000000000..cecb3c930e --- /dev/null +++ b/src/OpenFOAM/db/functionObjects/timeFunctionObject/timeFunctionObject.C @@ -0,0 +1,42 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2019 OpenCFD Ltd. + \\/ 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 "timeFunctionObject.H" +#include "Time.H" + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::functionObjects::timeFunctionObject::timeFunctionObject +( + const word& name, + const Time& runTime +) +: + functionObject(name), + time_(runTime) +{} + + +// ************************************************************************* // diff --git a/src/OpenFOAM/db/functionObjects/timeFunctionObject/timeFunctionObject.H b/src/OpenFOAM/db/functionObjects/timeFunctionObject/timeFunctionObject.H new file mode 100644 index 0000000000..1577fb1f9d --- /dev/null +++ b/src/OpenFOAM/db/functionObjects/timeFunctionObject/timeFunctionObject.H @@ -0,0 +1,108 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2019 OpenCFD Ltd. + \\/ 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::timeFunctionObject + +Description + Virtual base class for function objects with a reference to Time. + +See also + Foam::functionObject + +SourceFiles + timeFunctionObject.C + +\*---------------------------------------------------------------------------*/ + +#ifndef functionObjects_timeFunctionObject_H +#define functionObjects_timeFunctionObject_H + +#include "functionObject.H" +#include "Time.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace functionObjects +{ + +/*---------------------------------------------------------------------------*\ + Class functionObjects::timeFunctionObject Declaration +\*---------------------------------------------------------------------------*/ + +class timeFunctionObject +: + public functionObject +{ +protected: + + // Protected Member Data + + //- Reference to the time database + const Time& time_; + + + // Protected Member Functions + + //- No copy construct + timeFunctionObject(const timeFunctionObject&) = delete; + + //- No copy assignment + void operator=(const timeFunctionObject&) = delete; + + +public: + + // Constructors + + //- Construct from components + timeFunctionObject(const word& name, const Time& runTime); + + + //- Destructor + virtual ~timeFunctionObject() = default; + + + // Member Functions + + //- Return time database + const Time& time() const + { + return time_; + } +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace functionObjects +} // End namespace Foam + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/OpenFOAM/db/functionObjects/writeFile/writeFile.H b/src/OpenFOAM/db/functionObjects/writeFile/writeFile.H index d430f0c340..afc1094e0f 100644 --- a/src/OpenFOAM/db/functionObjects/writeFile/writeFile.H +++ b/src/OpenFOAM/db/functionObjects/writeFile/writeFile.H @@ -51,7 +51,7 @@ namespace functionObjects { /*---------------------------------------------------------------------------*\ - Class writeFile Declaration + Class functionObjects::writeFile Declaration \*---------------------------------------------------------------------------*/ class writeFile @@ -121,10 +121,6 @@ protected: Omanip valueWidth(const label offset = 0) const; -private: - - // Private Member Functions - //- No copy construct writeFile(const writeFile&) = delete; diff --git a/src/functionObjects/field/externalCoupled/externalCoupled.C b/src/functionObjects/field/externalCoupled/externalCoupled.C index 8f05a20e29..f9e68db678 100644 --- a/src/functionObjects/field/externalCoupled/externalCoupled.C +++ b/src/functionObjects/field/externalCoupled/externalCoupled.C @@ -508,9 +508,8 @@ Foam::functionObjects::externalCoupled::externalCoupled const dictionary& dict ) : - functionObject(name), + timeFunctionObject(name, runTime), externalFileCoupler(), - time_(runTime), calcFrequency_(-1), lastTrigger_(-1), initialisedCoupling_(false) diff --git a/src/functionObjects/field/externalCoupled/externalCoupled.H b/src/functionObjects/field/externalCoupled/externalCoupled.H index d049aa1f05..596ea5d74c 100644 --- a/src/functionObjects/field/externalCoupled/externalCoupled.H +++ b/src/functionObjects/field/externalCoupled/externalCoupled.H @@ -146,7 +146,7 @@ SourceFiles #ifndef functionObjects_externalCoupled_H #define functionObjects_externalCoupled_H -#include "functionObject.H" +#include "timeFunctionObject.H" #include "externalFileCoupler.H" #include "DynamicList.H" #include "wordReList.H" @@ -173,7 +173,7 @@ namespace functionObjects class externalCoupled : - public functionObject, + public functionObjects::timeFunctionObject, public externalFileCoupler { public: @@ -193,10 +193,7 @@ private: //- State end names (NB, only selectable values itemized) static const Enum stateEndNames_; - // Private data - - //- Reference to the time database - const Time& time_; + // Private Member Data //- Calculation frequency label calcFrequency_; diff --git a/src/functionObjects/utilities/abort/abort.C b/src/functionObjects/utilities/abort/abort.C index 4f480388a3..6ca97de785 100644 --- a/src/functionObjects/utilities/abort/abort.C +++ b/src/functionObjects/utilities/abort/abort.C @@ -138,8 +138,7 @@ Foam::functionObjects::abort::abort const dictionary& dict ) : - functionObject(name), - time_(runTime), + timeFunctionObject(name, runTime), file_(), defaultAction_(Time::stopAtControls::saUnknown), triggered_(false) diff --git a/src/functionObjects/utilities/abort/abort.H b/src/functionObjects/utilities/abort/abort.H index 86a3958649..516047160e 100644 --- a/src/functionObjects/utilities/abort/abort.H +++ b/src/functionObjects/utilities/abort/abort.H @@ -86,7 +86,7 @@ SourceFiles #ifndef functionObjects_abort_H #define functionObjects_abort_H -#include "functionObject.H" +#include "timeFunctionObject.H" #include "Time.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -102,13 +102,10 @@ namespace functionObjects class abort : - public functionObject + public functionObjects::timeFunctionObject { // Private Data - //- Reference to the Time - const Time& time_; - //- The fully-qualified name of the trigger file fileName file_; diff --git a/src/functionObjects/utilities/codedFunctionObject/codedFunctionObject.C b/src/functionObjects/utilities/codedFunctionObject/codedFunctionObject.C index 688bcd2758..7de562059e 100644 --- a/src/functionObjects/utilities/codedFunctionObject/codedFunctionObject.C +++ b/src/functionObjects/utilities/codedFunctionObject/codedFunctionObject.C @@ -124,13 +124,12 @@ Foam::functionObjects::codedFunctionObject::codeDict() const Foam::functionObjects::codedFunctionObject::codedFunctionObject ( const word& name, - const Time& time, + const Time& runTime, const dictionary& dict ) : - functionObject(name), + timeFunctionObject(name, runTime), codedBase(), - time_(time), dict_(dict) { read(dict_); @@ -140,12 +139,6 @@ Foam::functionObjects::codedFunctionObject::codedFunctionObject } -// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // - -Foam::functionObjects::codedFunctionObject::~codedFunctionObject() -{} - - // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // Foam::functionObject& diff --git a/src/functionObjects/utilities/codedFunctionObject/codedFunctionObject.H b/src/functionObjects/utilities/codedFunctionObject/codedFunctionObject.H index 522e940c42..d1fabed1f1 100644 --- a/src/functionObjects/utilities/codedFunctionObject/codedFunctionObject.H +++ b/src/functionObjects/utilities/codedFunctionObject/codedFunctionObject.H @@ -75,7 +75,7 @@ SourceFiles #ifndef functionObjects_codedFunctionObject_H #define functionObjects_codedFunctionObject_H -#include "functionObject.H" +#include "timeFunctionObject.H" #include "codedBase.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -91,16 +91,13 @@ namespace functionObjects class codedFunctionObject : - public functionObject, + public functionObjects::timeFunctionObject, public codedBase { protected: // Protected data - //- Reference to the time database - const Time& time_; - //- Input dictionary dictionary dict_; @@ -153,13 +150,13 @@ public: codedFunctionObject ( const word& name, - const Time& time, + const Time& runTime, const dictionary& dict ); //- Destructor - virtual ~codedFunctionObject(); + virtual ~codedFunctionObject() = default; // Member Functions diff --git a/src/functionObjects/utilities/setTimeStep/setTimeStepFunctionObject.C b/src/functionObjects/utilities/setTimeStep/setTimeStepFunctionObject.C index 4621e2ba95..02c4e98f73 100644 --- a/src/functionObjects/utilities/setTimeStep/setTimeStepFunctionObject.C +++ b/src/functionObjects/utilities/setTimeStep/setTimeStepFunctionObject.C @@ -53,28 +53,14 @@ Foam::functionObjects::setTimeStepFunctionObject::setTimeStepFunctionObject const dictionary& dict ) : - functionObject(name), - time_(runTime) + timeFunctionObject(name, runTime) { read(dict); } -// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // - -Foam::functionObjects::setTimeStepFunctionObject::~setTimeStepFunctionObject() -{} - - // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -const Foam::Time& -Foam::functionObjects::setTimeStepFunctionObject::time() const -{ - return time_; -} - - bool Foam::functionObjects::setTimeStepFunctionObject::adjustTimeStep() { // Wanted timestep diff --git a/src/functionObjects/utilities/setTimeStep/setTimeStepFunctionObject.H b/src/functionObjects/utilities/setTimeStep/setTimeStepFunctionObject.H index ea1c1cd9cc..81b8897062 100644 --- a/src/functionObjects/utilities/setTimeStep/setTimeStepFunctionObject.H +++ b/src/functionObjects/utilities/setTimeStep/setTimeStepFunctionObject.H @@ -69,7 +69,7 @@ SourceFiles #ifndef functionObjects_setTimeStepFunctionObject_H #define functionObjects_setTimeStepFunctionObject_H -#include "functionObject.H" +#include "timeFunctionObject.H" #include "Function1.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -80,23 +80,20 @@ namespace functionObjects { /*---------------------------------------------------------------------------*\ - Class setTimeStepFunctionObject Declaration + Class functionObjects::setTimeStepFunctionObject Declaration \*---------------------------------------------------------------------------*/ class setTimeStepFunctionObject : - public functionObject + public functionObjects::timeFunctionObject { - // Private data - - //- Reference to the time database - const Time& time_; + // Private Member Data //- Time step function/table autoPtr> timeStepPtr_; - // Private member functions + // Private Member Functions //- No copy construct setTimeStepFunctionObject(const setTimeStepFunctionObject&) = delete; @@ -123,14 +120,11 @@ public: // Destructor - virtual ~setTimeStepFunctionObject(); + virtual ~setTimeStepFunctionObject() = default; // Member Functions - //- Return time database - const Time& time() const; - //- Called at the end of Time::adjustDeltaT() if adjustTime is true virtual bool adjustTimeStep(); diff --git a/src/functionObjects/utilities/timeActivatedFileUpdate/timeActivatedFileUpdate.C b/src/functionObjects/utilities/timeActivatedFileUpdate/timeActivatedFileUpdate.C index a45099d328..b2635070c2 100644 --- a/src/functionObjects/utilities/timeActivatedFileUpdate/timeActivatedFileUpdate.C +++ b/src/functionObjects/utilities/timeActivatedFileUpdate/timeActivatedFileUpdate.C @@ -89,8 +89,7 @@ Foam::functionObjects::timeActivatedFileUpdate::timeActivatedFileUpdate const dictionary& dict ) : - functionObject(name), - time_(runTime), + timeFunctionObject(name, runTime), fileToUpdate_("unknown-fileToUpdate"), timeVsFile_(), lastIndex_(-1), @@ -100,12 +99,6 @@ Foam::functionObjects::timeActivatedFileUpdate::timeActivatedFileUpdate } -// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // - -Foam::functionObjects::timeActivatedFileUpdate::~timeActivatedFileUpdate() -{} - - // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // bool Foam::functionObjects::timeActivatedFileUpdate::read diff --git a/src/functionObjects/utilities/timeActivatedFileUpdate/timeActivatedFileUpdate.H b/src/functionObjects/utilities/timeActivatedFileUpdate/timeActivatedFileUpdate.H index 421ee18148..520440f8d3 100644 --- a/src/functionObjects/utilities/timeActivatedFileUpdate/timeActivatedFileUpdate.H +++ b/src/functionObjects/utilities/timeActivatedFileUpdate/timeActivatedFileUpdate.H @@ -69,7 +69,7 @@ SourceFiles #ifndef functionObjects_timeActivatedFileUpdate_H #define functionObjects_timeActivatedFileUpdate_H -#include "functionObject.H" +#include "timeFunctionObject.H" #include "Tuple2.H" #include "Switch.H" @@ -85,17 +85,14 @@ namespace functionObjects { /*---------------------------------------------------------------------------*\ - Class timeActivatedFileUpdate Declaration + Class functionObjects::timeActivatedFileUpdate Declaration \*---------------------------------------------------------------------------*/ class timeActivatedFileUpdate : - public functionObject + public functionObjects::timeFunctionObject { - // Private data - - //- Reference to Time - const Time& time_; + // Private Member Data //- Name of file to update fileName fileToUpdate_; @@ -140,7 +137,7 @@ public: //- Destructor - virtual ~timeActivatedFileUpdate(); + virtual ~timeActivatedFileUpdate() = default; // Member Functions diff --git a/src/functionObjects/utilities/vtkWrite/vtkWrite.C b/src/functionObjects/utilities/vtkWrite/vtkWrite.C index 11aed86354..073873b98d 100644 --- a/src/functionObjects/utilities/vtkWrite/vtkWrite.C +++ b/src/functionObjects/utilities/vtkWrite/vtkWrite.C @@ -122,8 +122,7 @@ Foam::functionObjects::vtkWrite::vtkWrite const dictionary& dict ) : - functionObject(name), - time_(runTime), + timeFunctionObject(name, runTime), outputDir_(), printf_(), writeOpts_(vtk::formatType::INLINE_BASE64), diff --git a/src/functionObjects/utilities/vtkWrite/vtkWrite.H b/src/functionObjects/utilities/vtkWrite/vtkWrite.H index 77110505d1..2b5da87199 100644 --- a/src/functionObjects/utilities/vtkWrite/vtkWrite.H +++ b/src/functionObjects/utilities/vtkWrite/vtkWrite.H @@ -132,7 +132,7 @@ SourceFiles #ifndef functionObjects_vtkWrite_H #define functionObjects_vtkWrite_H -#include "functionObject.H" +#include "timeFunctionObject.H" #include "foamVtkInternalWriter.H" #include "foamVtkPatchWriter.H" #include "foamVtkSeriesWriter.H" @@ -152,13 +152,10 @@ namespace functionObjects class vtkWrite : - public functionObject + public functionObjects::timeFunctionObject { // Private Data - //- Reference to the time database - const Time& time_; - //- The output directory fileName outputDir_; diff --git a/src/functionObjects/utilities/writeObjects/writeObjects.H b/src/functionObjects/utilities/writeObjects/writeObjects.H index ec25a9308a..bb94f5e96f 100644 --- a/src/functionObjects/utilities/writeObjects/writeObjects.H +++ b/src/functionObjects/utilities/writeObjects/writeObjects.H @@ -99,7 +99,7 @@ namespace functionObjects { /*---------------------------------------------------------------------------*\ - Class writeObjects Declaration + Class functionObjects::writeObjects Declaration \*---------------------------------------------------------------------------*/ class writeObjects @@ -125,7 +125,7 @@ private: // Private data - //- Reference to Db + //- Reference to registry const objectRegistry& obr_; //- To only write objects of defined writeOption