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

@ -27,6 +27,7 @@ License
#include "surfaceFields.H"
#include "fvcSurfaceIntegrate.H"
#include "zeroGradientFvPatchFields.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
@ -35,6 +36,13 @@ namespace Foam
namespace functionObjects
{
defineTypeNameAndDebug(CourantNo, 0);
addToRunTimeSelectionTable
(
functionObject,
CourantNo,
dictionary
);
}
}
@ -63,17 +71,22 @@ Foam::functionObjects::CourantNo::byRho
Foam::functionObjects::CourantNo::CourantNo
(
const word& name,
const objectRegistry& obr,
const dictionary& dict,
const bool loadFromFiles
const Time& runTime,
const dictionary& dict
)
:
name_(name),
obr_(obr),
functionObject(name),
obr_
(
runTime.lookupObject<objectRegistry>
(
dict.lookupOrDefault("region", polyMesh::defaultRegion)
)
),
phiName_("phi"),
rhoName_("rho")
{
if (!isA<fvMesh>(obr))
if (!isA<fvMesh>(obr_))
{
FatalErrorInFunction
<< "objectRegistry is not an fvMesh" << exit(FatalError);
@ -113,14 +126,16 @@ Foam::functionObjects::CourantNo::~CourantNo()
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::functionObjects::CourantNo::read(const dictionary& dict)
bool Foam::functionObjects::CourantNo::read(const dictionary& dict)
{
phiName_ = dict.lookupOrDefault<word>("phiName", "phi");
rhoName_ = dict.lookupOrDefault<word>("rhoName", "rho");
return true;
}
void Foam::functionObjects::CourantNo::execute()
bool Foam::functionObjects::CourantNo::execute(const bool postProcess)
{
const fvMesh& mesh = refCast<const fvMesh>(obr_);
@ -139,29 +154,23 @@ void Foam::functionObjects::CourantNo::execute()
/mesh.V()
);
Co.correctBoundaryConditions();
return true;
}
void Foam::functionObjects::CourantNo::end()
{
execute();
}
void Foam::functionObjects::CourantNo::timeSet()
{}
void Foam::functionObjects::CourantNo::write()
bool Foam::functionObjects::CourantNo::write(const bool postProcess)
{
const volScalarField& CourantNo =
obr_.lookupObject<volScalarField>(type());
Info<< type() << " " << name_ << " output:" << nl
Info<< type() << " " << name() << " output:" << nl
<< " writing field " << CourantNo.name() << nl
<< endl;
CourantNo.write();
return true;
}

View File

@ -40,19 +40,13 @@ SourceFiles
#ifndef functionObjects_CourantNo_H
#define functionObjects_CourantNo_H
#include "functionObject.H"
#include "volFields.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// Forward declaration of classes
class objectRegistry;
class dictionary;
class polyMesh;
class mapPolyMesh;
namespace functionObjects
{
@ -61,12 +55,11 @@ namespace functionObjects
\*---------------------------------------------------------------------------*/
class CourantNo
:
public functionObject
{
// Private data
//- Name of this set of CourantNo objects
word name_;
//- Reference to the database
const objectRegistry& obr_;
@ -100,14 +93,12 @@ public:
// Constructors
//- Construct for given objectRegistry and dictionary.
// Allow the possibility to load fields from files
//- Construct from Time and dictionary
CourantNo
(
const word& name,
const objectRegistry&,
const dictionary&,
const bool loadFromFiles = false
const Time&,
const dictionary&
);
@ -117,34 +108,14 @@ public:
// Member Functions
//- Return name of the set of CourantNo
virtual const word& name() const
{
return name_;
}
//- Read the CourantNo data
virtual void read(const dictionary&);
virtual bool read(const dictionary&);
//- Execute, currently does nothing
virtual void execute();
//- 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();
virtual bool execute(const bool postProcess = false);
//- Calculate the CourantNo 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&)
{}
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 "CourantNoFunctionObject.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineNamedTemplateTypeNameAndDebug(CourantNoFunctionObject, 0);
addToRunTimeSelectionTable
(
functionObject,
CourantNoFunctionObject,
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::CourantNoFunctionObject
Description
FunctionObject wrapper around CourantNo to allow it to be created
via the functions entry within controlDict.
SourceFiles
CourantNoFunctionObject.C
\*---------------------------------------------------------------------------*/
#ifndef CourantNoFunctionObject_H
#define CourantNoFunctionObject_H
#include "CourantNo.H"
#include "OutputFilterFunctionObject.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
typedef OutputFilterFunctionObject<functionObjects::CourantNo>
CourantNoFunctionObject;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //