Commit 932f710d authored by Mark Olesen's avatar Mark Olesen
Browse files

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
parent 868e991f
......@@ -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
......
......@@ -102,12 +102,6 @@ Foam::functionObjects::logFiles::logFiles
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::functionObjects::logFiles::~logFiles()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
const Foam::wordList& Foam::functionObjects::logFiles::names() const
......
......@@ -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
......
......@@ -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;
......
......@@ -52,14 +52,7 @@ Foam::functionObjects::stateFunctionObject::stateFunctionObject
const Time& runTime
)
:
functionObject(name),
time_(runTime)
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::functionObjects::stateFunctionObject::~stateFunctionObject()
timeFunctionObject(name, runTime)
{}
......
......@@ -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 <http://www.gnu.org/licenses/>.
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
......
......@@ -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);
}
......
......@@ -116,7 +116,7 @@ public:
//- Destructor
~timeControl();
~timeControl() = default;
// Member Functions
......
......@@ -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)
......
......@@ -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;
......
......@@ -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_;
......
/*---------------------------------------------------------------------------*\
========= |
\\ / 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 <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "timeFunctionObject.H"
#include "Time.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::functionObjects::timeFunctionObject::timeFunctionObject
(
const word& name,
const Time& runTime
)
:
functionObject(name),
time_(runTime)
{}
// ************************************************************************* //
/*---------------------------------------------------------------------------*\
========= |
\\ / 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 <http://www.gnu.org/licenses/>.
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
// ************************************************************************* //
......@@ -51,7 +51,7 @@ namespace functionObjects
{
/*---------------------------------------------------------------------------*\
Class writeFile Declaration
Class functionObjects::writeFile Declaration
\*---------------------------------------------------------------------------*/
class writeFile
......@@ -121,10 +121,6 @@ protected:
Omanip<int> valueWidth(const label offset = 0) const;
private:
// Private Member Functions
//- No copy construct
writeFile(const writeFile&) = delete;
......
......@@ -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)
......
......@@ -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<stateEnd> stateEndNames_;
// Private data
//- Reference to the time database
const Time& time_;
// Private Member Data
//- Calculation frequency
label calcFrequency_;
......
......@@ -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)
......
......@@ -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_;
......
......@@ -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
)