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 1441f8cab0
commit 91aba2db2e
230 changed files with 2731 additions and 8756 deletions

View File

@ -1,4 +1,3 @@
cloudInfo/cloudInfo.C
cloudInfo/cloudInfoFunctionObject.C
LIB = $(FOAM_LIBBIN)/liblagrangianFunctionObjects

View File

@ -24,8 +24,8 @@ License
\*---------------------------------------------------------------------------*/
#include "cloudInfo.H"
#include "dictionary.H"
#include "kinematicCloud.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
@ -34,6 +34,13 @@ namespace Foam
namespace functionObjects
{
defineTypeNameAndDebug(cloudInfo, 0);
addToRunTimeSelectionTable
(
functionObject,
cloudInfo,
dictionary
);
}
}
@ -55,14 +62,11 @@ void Foam::functionObjects::cloudInfo::writeFileHeader(const label i)
Foam::functionObjects::cloudInfo::cloudInfo
(
const word& name,
const objectRegistry& obr,
const dictionary& dict,
const bool loadFromFiles
const Time& runTime,
const dictionary& dict
)
:
functionObjectFiles(obr, name),
name_(name),
obr_(obr)
writeFiles(name, runTime, dict, name)
{
read(dict);
}
@ -76,11 +80,11 @@ Foam::functionObjects::cloudInfo::~cloudInfo()
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::functionObjects::cloudInfo::read(const dictionary& dict)
bool Foam::functionObjects::cloudInfo::read(const dictionary& dict)
{
functionObjectFiles::resetNames(dict.lookup("clouds"));
writeFiles::resetNames(dict.lookup("clouds"));
Info<< type() << " " << name_ << ": ";
Info<< type() << " " << name() << ": ";
if (names().size())
{
Info<< "applying to clouds:" << nl;
@ -94,24 +98,20 @@ void Foam::functionObjects::cloudInfo::read(const dictionary& dict)
{
Info<< "no clouds to be processed" << nl << endl;
}
return true;
}
void Foam::functionObjects::cloudInfo::execute()
{}
void Foam::functionObjects::cloudInfo::end()
{}
void Foam::functionObjects::cloudInfo::timeSet()
{}
void Foam::functionObjects::cloudInfo::write()
bool Foam::functionObjects::cloudInfo::execute(const bool postProcess)
{
functionObjectFiles::write();
return true;
}
bool Foam::functionObjects::cloudInfo::write(const bool postProcess)
{
writeFiles::write();
forAll(names(), i)
{
@ -133,6 +133,8 @@ void Foam::functionObjects::cloudInfo::write()
<< massInSystem << endl;
}
}
return true;
}

View File

@ -61,7 +61,7 @@ Description
SeeAlso
Foam::functionObject
Foam::OutputFilterFunctionObject
Foam::functionObjects::writeFiles
SourceFiles
cloudInfo.C
@ -71,22 +71,12 @@ SourceFiles
#ifndef functionObjects_cloudInfo_H
#define functionObjects_cloudInfo_H
#include "functionObjectFiles.H"
#include "PtrList.H"
#include "pointFieldFwd.H"
#include "volFields.H"
#include "surfaceFields.H"
#include "writeFiles.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// Forward declaration of classes
class objectRegistry;
class dictionary;
class mapPolyMesh;
namespace functionObjects
{
@ -96,19 +86,10 @@ namespace functionObjects
class cloudInfo
:
public functionObjectFiles
public writeFiles
{
protected:
// Protected data
//- Name of this set of cloudInfo object
word name_;
//- Reference to the database
const objectRegistry& obr_;
// Protected Member Functions
//- File header information
@ -134,14 +115,12 @@ public:
// Constructors
//- Construct for given objectRegistry and dictionary.
// Allow the possibility to load fields from files
//- Construct from Time and dictionary
cloudInfo
(
const word& name,
const objectRegistry&,
const dictionary&,
const bool loadFromFiles = false
const Time& runTime,
const dictionary&
);
@ -151,34 +130,14 @@ public:
// Member Functions
//- Return name of the cloudInfo object
virtual const word& name() const
{
return name_;
}
//- Read the controls
virtual void read(const dictionary&);
virtual bool read(const dictionary&);
//- Execute, currently does nothing
virtual void execute();
//- Execute at the final time-loop, currently does nothing
virtual void end();
//- Called when time was set at the end of the Time::operator++
virtual void timeSet();
virtual bool execute(const bool postProcess = false);
//- Write
virtual void write();
//- Update for changes of mesh
virtual void updateMesh(const mapPolyMesh&)
{}
//- Update for changes of mesh
virtual void movePoints(const polyMesh&)
{}
virtual bool write(const bool postProcess = false);
};

View File

@ -1,42 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2012-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/>.
\*---------------------------------------------------------------------------*/
#include "cloudInfoFunctionObject.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineNamedTemplateTypeNameAndDebug(cloudInfoFunctionObject, 0);
addToRunTimeSelectionTable
(
functionObject,
cloudInfoFunctionObject,
dictionary
);
}
// ************************************************************************* //

View File

@ -1,54 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2012-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::cloudInfoFunctionObject
Description
FunctionObject wrapper around cloudInfo to allow them to be created via
the functions entry within controlDict.
SourceFiles
cloudInfoFunctionObject.C
\*---------------------------------------------------------------------------*/
#ifndef cloudInfoFunctionObject_H
#define cloudInfoFunctionObject_H
#include "cloudInfo.H"
#include "OutputFilterFunctionObject.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
typedef OutputFilterFunctionObject<functionObjects::cloudInfo>
cloudInfoFunctionObject;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //