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,9 +24,9 @@ License
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "functionObjectTemplate.H"
|
||||
#include "Time.H"
|
||||
#include "fvCFD.H"
|
||||
#include "unitConversion.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -37,6 +37,36 @@ namespace Foam
|
||||
|
||||
defineTypeNameAndDebug(${typeName}FunctionObject, 0);
|
||||
|
||||
addRemovableToRunTimeSelectionTable
|
||||
(
|
||||
functionObject,
|
||||
${typeName}FunctionObject,
|
||||
dictionary
|
||||
);
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
|
||||
|
||||
extern "C"
|
||||
{
|
||||
// dynamicCode:
|
||||
// SHA1 = ${SHA1sum}
|
||||
//
|
||||
// unique function name that can be checked if the correct library version
|
||||
// has been loaded
|
||||
void ${typeName}_${SHA1sum}(bool load)
|
||||
{
|
||||
if (load)
|
||||
{
|
||||
// code that can be explicitly executed after loading
|
||||
}
|
||||
else
|
||||
{
|
||||
// code that can be explicitly executed before unloading
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Local Functions * * * * * * * * * * * * * * //
|
||||
|
||||
@ -64,13 +94,18 @@ const fvMesh& ${typeName}FunctionObject::mesh() const
|
||||
${typeName}FunctionObject::${typeName}FunctionObject
|
||||
(
|
||||
const word& name,
|
||||
const objectRegistry& obr,
|
||||
const dictionary& dict,
|
||||
const bool
|
||||
const Time& runTime,
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
name_(name),
|
||||
obr_(obr)
|
||||
functionObject(name),
|
||||
obr_
|
||||
(
|
||||
runTime.lookupObject<objectRegistry>
|
||||
(
|
||||
dict.lookupOrDefault("region", polyMesh::defaultRegion)
|
||||
)
|
||||
)
|
||||
{
|
||||
read(dict);
|
||||
}
|
||||
@ -84,7 +119,7 @@ ${typeName}FunctionObject::~${typeName}FunctionObject()
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
void ${typeName}FunctionObject::read(const dictionary& dict)
|
||||
bool ${typeName}FunctionObject::read(const dictionary& dict)
|
||||
{
|
||||
if (${verbose:-false})
|
||||
{
|
||||
@ -94,10 +129,12 @@ void ${typeName}FunctionObject::read(const dictionary& dict)
|
||||
//{{{ begin code
|
||||
${codeRead}
|
||||
//}}} end code
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void ${typeName}FunctionObject::execute()
|
||||
bool ${typeName}FunctionObject::execute(const bool postProcess)
|
||||
{
|
||||
if (${verbose:-false})
|
||||
{
|
||||
@ -107,10 +144,12 @@ void ${typeName}FunctionObject::execute()
|
||||
//{{{ begin code
|
||||
${codeExecute}
|
||||
//}}} end code
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void ${typeName}FunctionObject::end()
|
||||
bool ${typeName}FunctionObject::end()
|
||||
{
|
||||
if (${verbose:-false})
|
||||
{
|
||||
@ -120,10 +159,12 @@ void ${typeName}FunctionObject::end()
|
||||
//{{{ begin code
|
||||
${codeEnd}
|
||||
//}}} end code
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void ${typeName}FunctionObject::timeSet()
|
||||
bool ${typeName}FunctionObject::timeSet()
|
||||
{
|
||||
if (${verbose:-false})
|
||||
{
|
||||
@ -133,10 +174,12 @@ void ${typeName}FunctionObject::timeSet()
|
||||
//{{{ begin codeTime
|
||||
${codeTimeSet}
|
||||
//}}} end code
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void ${typeName}FunctionObject::write()
|
||||
bool ${typeName}FunctionObject::write(const bool postProcess)
|
||||
{
|
||||
if (${verbose:-false})
|
||||
{
|
||||
@ -146,11 +189,13 @@ void ${typeName}FunctionObject::write()
|
||||
//{{{ begin code
|
||||
${code}
|
||||
//}}} end code
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
Reference in New Issue
Block a user