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

@ -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;
}

View File

@ -59,7 +59,7 @@ Description
SeeAlso
Foam::functionObject
Foam::OutputFilterFunctionObject
Foam::functionObjects::timeControl
SourceFiles
surfaceInterpolateFields.C
@ -69,8 +69,8 @@ SourceFiles
#ifndef functionObjects_surfaceInterpolateFields_H
#define functionObjects_surfaceInterpolateFields_H
#include "OFstream.H"
#include "surfaceFields.H"
#include "functionObject.H"
#include "surfaceFieldsFwd.H"
#include "Tuple2.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -91,18 +91,17 @@ namespace functionObjects
\*---------------------------------------------------------------------------*/
class surfaceInterpolateFields
:
public functionObject
{
protected:
// Protected data
//- Name of this set of surfaceInterpolateFields object
word name_;
//- Reference to the objectRegistry
const objectRegistry& obr_;
//- Fields to process
//wordList fieldSet_;
List<Tuple2<word, word>> fieldSet_;
//- Locally constructed fields
@ -146,9 +145,8 @@ public:
surfaceInterpolateFields
(
const word& name,
const objectRegistry&,
const dictionary&,
const bool loadFromFiles = false
const Time& runTime,
const dictionary& dict
);
@ -158,34 +156,14 @@ public:
// Member Functions
//- Return name of the surfaceInterpolateFields 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();
//- Calculate the interpolated fields
virtual bool execute(const bool postProcess = false);
//- 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();
//- Write
virtual void write();
//- Update for changes of mesh
virtual void updateMesh(const mapPolyMesh&)
{}
//- Update for changes of mesh
virtual void movePoints(const polyMesh&)
{}
//- Write the interpolated fields
virtual bool write(const bool postProcess = false);
};

View File

@ -1,46 +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 "surfaceInterpolateFieldsFunctionObject.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineNamedTemplateTypeNameAndDebug
(
surfaceInterpolateFieldsFunctionObject,
0
);
addToRunTimeSelectionTable
(
functionObject,
surfaceInterpolateFieldsFunctionObject,
dictionary
);
}
// ************************************************************************* //

View File

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