functionObjects: rewritten to all be derived from 'functionObject'

- Avoids the need for the 'OutputFilterFunctionObject' wrapper
  - Time-control for execution and writing is now provided by the
    'timeControlFunctionObject' which instantiates the processing
    'functionObject' and controls its operation.
  - Alternative time-control functionObjects can now be written and
    selected at run-time without the need to compile wrapped version of
    EVERY existing functionObject which would have been required in the
    old structure.
  - The separation of 'execute' and 'write' functions is now formalized in the
    'functionObject' base-class and all derived classes implement the
    two functions.
  - Unnecessary implementations of functions with appropriate defaults
    in the 'functionObject' base-class have been removed reducing
    clutter and simplifying implementation of new functionObjects.
  - The 'coded' 'functionObject' has also been updated, simplified and tested.
  - Further simplification is now possible by creating some general
    intermediate classes derived from 'functionObject'.
This commit is contained in:
Henry Weller
2016-05-15 16:40:01 +01:00
parent 1441f8cab0
commit 91aba2db2e
230 changed files with 2731 additions and 8756 deletions

View File

@ -36,6 +36,7 @@ License
#include "fvmSup.H"
#include "turbulentTransportModel.H"
#include "turbulentFluidThermoModel.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
@ -44,6 +45,13 @@ namespace Foam
namespace functionObjects
{
defineTypeNameAndDebug(scalarTransport, 0);
addToRunTimeSelectionTable
(
functionObject,
scalarTransport,
dictionary
);
}
}
@ -145,13 +153,21 @@ Foam::tmp<Foam::volScalarField> Foam::functionObjects::scalarTransport::DT
Foam::functionObjects::scalarTransport::scalarTransport
(
const word& name,
const objectRegistry& obr,
const dictionary& dict,
const bool loadFromFiles
const Time& runTime,
const dictionary& dict
)
:
name_(name),
mesh_(refCast<const fvMesh>(obr)),
functionObject(name),
mesh_
(
refCast<const fvMesh>
(
runTime.lookupObject<objectRegistry>
(
dict.lookupOrDefault("region", polyMesh::defaultRegion)
)
)
),
phiName_(dict.lookupOrDefault<word>("phiName", "phi")),
UName_(dict.lookupOrDefault<word>("UName", "U")),
rhoName_(dict.lookupOrDefault<word>("rhoName", "rho")),
@ -176,12 +192,6 @@ Foam::functionObjects::scalarTransport::scalarTransport
boundaryTypes()
)
{
if (!isA<fvMesh>(obr))
{
FatalErrorInFunction
<< "objectRegistry is not an fvMesh" << exit(FatalError);
}
read(dict);
if (resetOnStartUp_)
@ -199,7 +209,7 @@ Foam::functionObjects::scalarTransport::~scalarTransport()
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::functionObjects::scalarTransport::read(const dictionary& dict)
bool Foam::functionObjects::scalarTransport::read(const dictionary& dict)
{
Info<< type() << ":" << nl;
@ -220,10 +230,12 @@ void Foam::functionObjects::scalarTransport::read(const dictionary& dict)
dict.lookup("autoSchemes") >> autoSchemes_;
fvOptions_.reset(dict.subDict("fvOptions"));
return true;
}
void Foam::functionObjects::scalarTransport::execute()
bool Foam::functionObjects::scalarTransport::execute(const bool postProcess)
{
Info<< type() << " output:" << endl;
@ -304,21 +316,15 @@ void Foam::functionObjects::scalarTransport::execute()
}
Info<< endl;
return true;
}
void Foam::functionObjects::scalarTransport::end()
bool Foam::functionObjects::scalarTransport::write(const bool postProcess)
{
execute();
return true;
}
void Foam::functionObjects::scalarTransport::timeSet()
{}
void Foam::functionObjects::scalarTransport::write()
{}
// ************************************************************************* //

View File

@ -47,10 +47,9 @@ SourceFiles
#ifndef functionObjects_scalarTransport_H
#define functionObjects_scalarTransport_H
#include "functionObject.H"
#include "volFields.H"
#include "surfaceFieldsFwd.H"
#include "pointFieldFwd.H"
#include "fvMatricesFwd.H"
#include "fvOptionList.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -60,8 +59,6 @@ namespace Foam
// Forward declaration of classes
class objectRegistry;
class dictionary;
class mapPolyMesh;
namespace functionObjects
{
@ -71,12 +68,11 @@ namespace functionObjects
\*---------------------------------------------------------------------------*/
class scalarTransport
:
public functionObject
{
// Private data
//- Name of this set of scalarTransport objects
word name_;
//- Reference to the mesh database
const fvMesh& mesh_;
@ -134,14 +130,12 @@ public:
// Constructors
//- Construct for given objectRegistry and dictionary.
// Allow the possibility to load fields from files
//- Construct from Time and dictionary
scalarTransport
(
const word& name,
const objectRegistry&,
const dictionary&,
const bool loadFromFiles = false
const Time& runTime,
const dictionary& dict
);
@ -151,34 +145,15 @@ public:
// Member Functions
//- Return name of the set of scalarTransport
virtual const word& name() const
{
return name_;
}
//- Read the scalarTransport data
virtual void read(const dictionary&);
virtual bool read(const dictionary&);
//- Execute, currently does nothing
virtual void execute();
//- Calculate the scalarTransport
virtual bool execute(const bool postProcess = false);
//- Execute at the final time-loop, currently does nothing
virtual void end();
//- Called when time was set at the end of the Time::operator++
virtual void timeSet();
//- Calculate the scalarTransport and write
virtual void write();
//- Update for changes of mesh
virtual void updateMesh(const mapPolyMesh&)
{}
//- Update for changes of mesh
virtual void movePoints(const polyMesh&)
{}
//- Do nothing.
// The volScalarField is registered and written automatically
virtual bool write(const bool postProcess = false);
};

View File

@ -1,42 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2012 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 "scalarTransportFunctionObject.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineNamedTemplateTypeNameAndDebug(scalarTransportFunctionObject, 0);
addToRunTimeSelectionTable
(
functionObject,
scalarTransportFunctionObject,
dictionary
);
}
// ************************************************************************* //

View File

@ -1,54 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2012-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/>.
Typedef
Foam::scalarTransportFunctionObject
Description
FunctionObject wrapper around scalarTransport to allow it to be
created via the functions entry within controlDict.
SourceFiles
scalarTransportFunctionObject.C
\*---------------------------------------------------------------------------*/
#ifndef scalarTransportFunctionObject_H
#define scalarTransportFunctionObject_H
#include "scalarTransport.H"
#include "OutputFilterFunctionObject.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
typedef OutputFilterFunctionObject<functionObjects::scalarTransport>
scalarTransportFunctionObject;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //