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:
@ -25,7 +25,7 @@ License
|
||||
|
||||
#include "pressureTools.H"
|
||||
#include "volFields.H"
|
||||
#include "dictionary.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
@ -34,6 +34,7 @@ namespace Foam
|
||||
namespace functionObjects
|
||||
{
|
||||
defineTypeNameAndDebug(pressureTools, 0);
|
||||
addToRunTimeSelectionTable(functionObject, pressureTools, dictionary);
|
||||
}
|
||||
}
|
||||
|
||||
@ -186,13 +187,18 @@ Foam::functionObjects::pressureTools::convertToCoeff
|
||||
Foam::functionObjects::pressureTools::pressureTools
|
||||
(
|
||||
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)
|
||||
)
|
||||
),
|
||||
pName_("p"),
|
||||
UName_("U"),
|
||||
rhoName_("rho"),
|
||||
@ -203,7 +209,7 @@ Foam::functionObjects::pressureTools::pressureTools
|
||||
UInf_(Zero),
|
||||
rhoInf_(0.0)
|
||||
{
|
||||
if (!isA<fvMesh>(obr))
|
||||
if (!isA<fvMesh>(obr_))
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "objectRegistry is not an fvMesh" << exit(FatalError);
|
||||
@ -249,7 +255,7 @@ Foam::functionObjects::pressureTools::~pressureTools()
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::functionObjects::pressureTools::read(const dictionary& dict)
|
||||
bool Foam::functionObjects::pressureTools::read(const dictionary& dict)
|
||||
{
|
||||
dict.readIfPresent("pName", pName_);
|
||||
dict.readIfPresent("UName", UName_);
|
||||
@ -278,16 +284,18 @@ void Foam::functionObjects::pressureTools::read(const dictionary& dict)
|
||||
if (mag(zeroCheck) < ROOTVSMALL)
|
||||
{
|
||||
WarningInFunction
|
||||
<< type() << " " << name_ << ": "
|
||||
<< type() << " " << name() << ": "
|
||||
<< "Coefficient calculation requested, but reference "
|
||||
<< "pressure level is zero. Please check the supplied "
|
||||
<< "values of pInf, UInf and rhoInf" << endl;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void Foam::functionObjects::pressureTools::execute()
|
||||
bool Foam::functionObjects::pressureTools::execute(const bool postProcess)
|
||||
{
|
||||
const volScalarField& p = obr_.lookupObject<volScalarField>(pName_);
|
||||
|
||||
@ -297,29 +305,23 @@ void Foam::functionObjects::pressureTools::execute()
|
||||
);
|
||||
|
||||
pResult == convertToCoeff(rhoScale(p)*p + pDyn(p) + pRef());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void Foam::functionObjects::pressureTools::end()
|
||||
{
|
||||
execute();
|
||||
}
|
||||
|
||||
|
||||
void Foam::functionObjects::pressureTools::timeSet()
|
||||
{}
|
||||
|
||||
|
||||
void Foam::functionObjects::pressureTools::write()
|
||||
bool Foam::functionObjects::pressureTools::write(const bool postProcess)
|
||||
{
|
||||
const volScalarField& pResult =
|
||||
obr_.lookupObject<volScalarField>(pName());
|
||||
|
||||
Info<< type() << " " << name_ << " output:" << nl
|
||||
Info<< type() << " " << name() << " output:" << nl
|
||||
<< " writing field " << pResult.name() << nl
|
||||
<< endl;
|
||||
|
||||
pResult.write();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user