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 ce0cd35185
commit 78d2971b21
230 changed files with 2731 additions and 8756 deletions

View File

@ -1,65 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "FilterFunctionObjectTemplate.H"
// * * * * * * * * * * * * * * * 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
}
}
}
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineNamedTemplateTypeNameAndDebug(${typeName}FilterFunctionObject, 0);
//addToRunTimeSelectionTable
addRemovableToRunTimeSelectionTable
(
functionObject,
${typeName}FilterFunctionObject,
dictionary
);
}
// ************************************************************************* //

View File

@ -1,51 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Description
FunctionObject wrapper around functionObjectTemplate to allow them
to be created via the functions entry within controlDict.
SourceFiles
FilterFunctionObject.C
\*---------------------------------------------------------------------------*/
#ifndef FilterFunctionObject_H
#define FilterFunctionObject_H
#include "functionObjectTemplate.H"
#include "OutputFilterFunctionObject.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
typedef OutputFilterFunctionObject<${typeName}FunctionObject>
${typeName}FilterFunctionObject;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -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
// ************************************************************************* //

View File

@ -33,8 +33,7 @@ SourceFiles
#ifndef functionObjectTemplate_H
#define functionObjectTemplate_H
#include "stringList.H"
#include "pointField.H"
#include "functionObject.H"
//{{{ begin codeInclude
${codeInclude}
@ -47,9 +46,6 @@ namespace Foam
// Forward declaration of classes
class objectRegistry;
class dictionary;
class polyMesh;
class mapPolyMesh;
class fvMesh;
/*---------------------------------------------------------------------------*\
@ -57,13 +53,12 @@ class fvMesh;
\*---------------------------------------------------------------------------*/
class ${typeName}FunctionObject
:
public functionObject
{
// Private data
//- Name of this set of system calls
word name_;
//- Registry
//- Reference to the objectRegistry
const objectRegistry& obr_;
//{{{ begin codeData
@ -92,14 +87,12 @@ public:
// Constructors
//- Construct for given objectRegistry and dictionary.
// Allow the possibility to load fields from files
//- Construct from Time and dictionary
${typeName}FunctionObject
(
const word& name,
const objectRegistry& unused,
const dictionary&,
const bool loadFromFilesUnused = false
const Time& runTime,
const dictionary&
);
@ -109,34 +102,20 @@ public:
// Member Functions
//- Return name of the system call set
virtual const word& name() const
{
return name_;
}
//- Read the system calls
virtual void read(const dictionary&);
virtual bool read(const dictionary&);
//- Execute the "executeCalls" at each time-step
virtual void execute();
virtual bool execute(const bool postProcess = false);
//- Execute the "endCalls" at the final time-loop
virtual void end();
virtual bool end();
//- Write, execute the "writeCalls"
virtual void write();
virtual bool write(const bool postProcess = false);
//- Called when time was set at the end of the Time::operator++
virtual void timeSet();
//- Update for changes of mesh
virtual void updateMesh(const mapPolyMesh&)
{}
//- Update for changes of mesh
virtual void movePoints(const polyMesh&)
{}
virtual bool timeSet();
};

View File

@ -1,54 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2016 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Typedef
Foam::FUNCTIONOBJECTFunctionObject
Description
FunctionObject wrapper around FUNCTIONOBJECT to allow them to be
created via the functions entry within controlDict.
SourceFiles
FUNCTIONOBJECTFunctionObject.C
\*---------------------------------------------------------------------------*/
#ifndef FUNCTIONOBJECTFunctionObject_H
#define FUNCTIONOBJECTFunctionObject_H
#include "FUNCTIONOBJECT.H"
#include "OutputFilterFunctionObject.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
typedef OutputFilterFunctionObject<FUNCTIONOBJECT>
FUNCTIONOBJECTFunctionObject;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //