mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
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:
@ -24,8 +24,8 @@ License
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "processorField.H"
|
||||
#include "dictionary.H"
|
||||
#include "Pstream.H"
|
||||
#include "volFields.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
@ -34,6 +34,7 @@ namespace Foam
|
||||
namespace functionObjects
|
||||
{
|
||||
defineTypeNameAndDebug(processorField, 0);
|
||||
addToRunTimeSelectionTable(functionObject, processorField, dictionary);
|
||||
}
|
||||
}
|
||||
|
||||
@ -43,15 +44,20 @@ namespace functionObjects
|
||||
Foam::functionObjects::processorField::processorField
|
||||
(
|
||||
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)
|
||||
)
|
||||
)
|
||||
{
|
||||
if (!isA<fvMesh>(obr))
|
||||
if (!isA<fvMesh>(obr_))
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "objectRegistry is not an fvMesh" << exit(FatalError);
|
||||
@ -90,36 +96,32 @@ Foam::functionObjects::processorField::~processorField()
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::functionObjects::processorField::read(const dictionary& dict)
|
||||
{}
|
||||
bool Foam::functionObjects::processorField::read(const dictionary& dict)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void Foam::functionObjects::processorField::execute()
|
||||
bool Foam::functionObjects::processorField::execute(const bool postProcess)
|
||||
{
|
||||
const volScalarField& procField =
|
||||
obr_.lookupObject<volScalarField>("processorID");
|
||||
|
||||
const_cast<volScalarField&>(procField) ==
|
||||
dimensionedScalar("proci", dimless, Pstream::myProcNo());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void Foam::functionObjects::processorField::end()
|
||||
{
|
||||
execute();
|
||||
}
|
||||
|
||||
|
||||
void Foam::functionObjects::processorField::timeSet()
|
||||
{}
|
||||
|
||||
|
||||
void Foam::functionObjects::processorField::write()
|
||||
bool Foam::functionObjects::processorField::write(const bool postProcess)
|
||||
{
|
||||
const volScalarField& procField =
|
||||
obr_.lookupObject<volScalarField>("processorID");
|
||||
|
||||
procField.write();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user