mirror of
https://github.com/OpenFOAM/OpenFOAM-6.git
synced 2025-12-08 06:57:46 +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,6 +24,8 @@ License
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "surfaceInterpolateFields.H"
|
||||
#include "surfaceFields.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
@ -32,6 +34,13 @@ namespace Foam
|
||||
namespace functionObjects
|
||||
{
|
||||
defineTypeNameAndDebug(surfaceInterpolateFields, 0);
|
||||
|
||||
addToRunTimeSelectionTable
|
||||
(
|
||||
functionObject,
|
||||
surfaceInterpolateFields,
|
||||
dictionary
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -41,16 +50,21 @@ namespace functionObjects
|
||||
Foam::functionObjects::surfaceInterpolateFields::surfaceInterpolateFields
|
||||
(
|
||||
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)
|
||||
)
|
||||
),
|
||||
fieldSet_()
|
||||
{
|
||||
if (!isA<fvMesh>(obr))
|
||||
if (!isA<fvMesh>(obr_))
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "objectRegistry is not an fvMesh" << exit(FatalError);
|
||||
@ -68,18 +82,23 @@ Foam::functionObjects::surfaceInterpolateFields::~surfaceInterpolateFields()
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::functionObjects::surfaceInterpolateFields::read
|
||||
bool Foam::functionObjects::surfaceInterpolateFields::read
|
||||
(
|
||||
const dictionary& dict
|
||||
)
|
||||
{
|
||||
dict.lookup("fields") >> fieldSet_;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void Foam::functionObjects::surfaceInterpolateFields::execute()
|
||||
bool Foam::functionObjects::surfaceInterpolateFields::execute
|
||||
(
|
||||
const bool postProcess
|
||||
)
|
||||
{
|
||||
Info<< type() << " " << name_ << " output:" << nl;
|
||||
Info<< type() << " " << name() << " output:" << nl;
|
||||
|
||||
// Clear out any previously loaded fields
|
||||
ssf_.clear();
|
||||
@ -95,22 +114,17 @@ void Foam::functionObjects::surfaceInterpolateFields::execute()
|
||||
interpolateFields<tensor>(stf_);
|
||||
|
||||
Info<< endl;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void Foam::functionObjects::surfaceInterpolateFields::end()
|
||||
bool Foam::functionObjects::surfaceInterpolateFields::write
|
||||
(
|
||||
const bool postProcess
|
||||
)
|
||||
{
|
||||
execute();
|
||||
}
|
||||
|
||||
|
||||
void Foam::functionObjects::surfaceInterpolateFields::timeSet()
|
||||
{}
|
||||
|
||||
|
||||
void Foam::functionObjects::surfaceInterpolateFields::write()
|
||||
{
|
||||
Info<< type() << " " << name_ << " output:" << nl;
|
||||
Info<< type() << " " << name() << " output:" << nl;
|
||||
|
||||
Info<< " Writing interpolated surface fields to "
|
||||
<< obr_.time().timeName() << endl;
|
||||
@ -135,6 +149,8 @@ void Foam::functionObjects::surfaceInterpolateFields::write()
|
||||
{
|
||||
stf_[i].write();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user