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

@ -25,8 +25,7 @@ License
#include "div.H"
#include "volFields.H"
#include "dictionary.H"
#include "div.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
@ -35,6 +34,7 @@ namespace Foam
namespace functionObjects
{
defineTypeNameAndDebug(div, 0);
addToRunTimeSelectionTable(functionObject, div, dictionary);
}
}
@ -82,17 +82,22 @@ Foam::volScalarField& Foam::functionObjects::div::divField
Foam::functionObjects::div::div
(
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)
)
),
fieldName_("undefined-fieldName"),
resultName_("undefined-resultName")
{
if (!isA<fvMesh>(obr))
if (!isA<fvMesh>(obr_))
{
FatalErrorInFunction
<< "objectRegistry is not an fvMesh" << exit(FatalError);
@ -110,7 +115,7 @@ Foam::functionObjects::div::~div()
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::functionObjects::div::read(const dictionary& dict)
bool Foam::functionObjects::div::read(const dictionary& dict)
{
dict.lookup("fieldName") >> fieldName_;
dict.lookup("resultName") >> resultName_;
@ -119,10 +124,12 @@ void Foam::functionObjects::div::read(const dictionary& dict)
{
resultName_ = "fvc::div(" + fieldName_ + ")";
}
return true;
}
void Foam::functionObjects::div::execute()
bool Foam::functionObjects::div::execute(const bool postProcess)
{
bool processed = false;
@ -134,31 +141,25 @@ void Foam::functionObjects::div::execute()
WarningInFunction
<< "Unprocessed field " << fieldName_ << endl;
}
return true;
}
void Foam::functionObjects::div::end()
{
execute();
}
void Foam::functionObjects::div::timeSet()
{}
void Foam::functionObjects::div::write()
bool Foam::functionObjects::div::write(const bool postProcess)
{
if (obr_.foundObject<regIOobject>(resultName_))
{
const regIOobject& field =
obr_.lookupObject<regIOobject>(resultName_);
Info<< type() << " " << name_ << " output:" << nl
Info<< type() << " " << name() << " output:" << nl
<< " writing field " << field.name() << nl << endl;
field.write();
}
return true;
}