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:
@ -31,12 +31,20 @@ License
|
||||
#include "volPointInterpolation.H"
|
||||
#include "PatchTools.H"
|
||||
#include "mapPolyMesh.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
defineTypeNameAndDebug(sampledSurfaces, 0);
|
||||
|
||||
addToRunTimeSelectionTable
|
||||
(
|
||||
functionObject,
|
||||
sampledSurfaces,
|
||||
dictionary
|
||||
);
|
||||
}
|
||||
|
||||
bool Foam::sampledSurfaces::verbose_ = false;
|
||||
@ -85,6 +93,45 @@ void Foam::sampledSurfaces::writeGeometry() const
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::sampledSurfaces::sampledSurfaces
|
||||
(
|
||||
const word& name,
|
||||
const Time& t,
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
functionObject(name),
|
||||
PtrList<sampledSurface>(),
|
||||
mesh_
|
||||
(
|
||||
refCast<const fvMesh>
|
||||
(
|
||||
t.lookupObject<objectRegistry>
|
||||
(
|
||||
dict.lookupOrDefault("region", polyMesh::defaultRegion)
|
||||
)
|
||||
)
|
||||
),
|
||||
loadFromFiles_(false),
|
||||
outputPath_(fileName::null),
|
||||
fieldSelection_(),
|
||||
interpolationScheme_(word::null),
|
||||
mergeList_(),
|
||||
formatter_(NULL)
|
||||
{
|
||||
if (Pstream::parRun())
|
||||
{
|
||||
outputPath_ = mesh_.time().path()/".."/"postProcessing"/name;
|
||||
}
|
||||
else
|
||||
{
|
||||
outputPath_ = mesh_.time().path()/"postProcessing"/name;
|
||||
}
|
||||
|
||||
read(dict);
|
||||
}
|
||||
|
||||
|
||||
Foam::sampledSurfaces::sampledSurfaces
|
||||
(
|
||||
const word& name,
|
||||
@ -93,8 +140,8 @@ Foam::sampledSurfaces::sampledSurfaces
|
||||
const bool loadFromFiles
|
||||
)
|
||||
:
|
||||
functionObject(name),
|
||||
PtrList<sampledSurface>(),
|
||||
name_(name),
|
||||
mesh_(refCast<const fvMesh>(obr)),
|
||||
loadFromFiles_(loadFromFiles),
|
||||
outputPath_(fileName::null),
|
||||
@ -105,11 +152,11 @@ Foam::sampledSurfaces::sampledSurfaces
|
||||
{
|
||||
if (Pstream::parRun())
|
||||
{
|
||||
outputPath_ = mesh_.time().path()/".."/"postProcessing"/name_;
|
||||
outputPath_ = mesh_.time().path()/".."/"postProcessing"/name;
|
||||
}
|
||||
else
|
||||
{
|
||||
outputPath_ = mesh_.time().path()/"postProcessing"/name_;
|
||||
outputPath_ = mesh_.time().path()/"postProcessing"/name;
|
||||
}
|
||||
|
||||
read(dict);
|
||||
@ -130,19 +177,13 @@ void Foam::sampledSurfaces::verbose(const bool verbosity)
|
||||
}
|
||||
|
||||
|
||||
void Foam::sampledSurfaces::execute()
|
||||
{}
|
||||
bool Foam::sampledSurfaces::execute(const bool postProcess)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void Foam::sampledSurfaces::end()
|
||||
{}
|
||||
|
||||
|
||||
void Foam::sampledSurfaces::timeSet()
|
||||
{}
|
||||
|
||||
|
||||
void Foam::sampledSurfaces::write()
|
||||
bool Foam::sampledSurfaces::write(const bool postProcess)
|
||||
{
|
||||
if (size())
|
||||
{
|
||||
@ -184,10 +225,12 @@ void Foam::sampledSurfaces::write()
|
||||
sampleAndWrite<surfaceSymmTensorField>(objects);
|
||||
sampleAndWrite<surfaceTensorField>(objects);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void Foam::sampledSurfaces::read(const dictionary& dict)
|
||||
bool Foam::sampledSurfaces::read(const dictionary& dict)
|
||||
{
|
||||
bool surfacesFound = dict.found("surfaces");
|
||||
|
||||
@ -243,6 +286,8 @@ void Foam::sampledSurfaces::read(const dictionary& dict)
|
||||
}
|
||||
Pout<< ")" << endl;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -37,6 +37,7 @@ SourceFiles
|
||||
#ifndef sampledSurfaces_H
|
||||
#define sampledSurfaces_H
|
||||
|
||||
#include "functionObject.H"
|
||||
#include "sampledSurface.H"
|
||||
#include "surfaceWriter.H"
|
||||
#include "volFieldsFwd.H"
|
||||
@ -49,6 +50,8 @@ SourceFiles
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// Forward declaration of classes
|
||||
class Time;
|
||||
class fvMesh;
|
||||
class dictionary;
|
||||
|
||||
@ -58,11 +61,11 @@ class dictionary;
|
||||
|
||||
class sampledSurfaces
|
||||
:
|
||||
public functionObject,
|
||||
public PtrList<sampledSurface>
|
||||
{
|
||||
// Private classes
|
||||
|
||||
|
||||
//- Class used for surface merging information
|
||||
class mergeInfo
|
||||
{
|
||||
@ -92,10 +95,6 @@ class sampledSurfaces
|
||||
|
||||
// Private data
|
||||
|
||||
//- Name of this set of surfaces,
|
||||
// Also used as the name of the sampledSurfaces directory.
|
||||
const word name_;
|
||||
|
||||
//- Const reference to fvMesh
|
||||
const fvMesh& mesh_;
|
||||
|
||||
@ -176,6 +175,14 @@ public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from Time and dictionary
|
||||
sampledSurfaces
|
||||
(
|
||||
const word& name,
|
||||
const Time& time,
|
||||
const dictionary& dict
|
||||
);
|
||||
|
||||
//- Construct for given objectRegistry and dictionary
|
||||
// allow the possibility to load fields from files
|
||||
sampledSurfaces
|
||||
@ -205,30 +212,17 @@ public:
|
||||
// Return false if no surfaces required an update.
|
||||
virtual bool update();
|
||||
|
||||
|
||||
//- Return name of the set of surfaces
|
||||
virtual const word& name() const
|
||||
{
|
||||
return name_;
|
||||
}
|
||||
|
||||
//- Set verbosity level
|
||||
void verbose(const bool verbosity = true);
|
||||
|
||||
//- Read the sampledSurfaces 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);
|
||||
|
||||
//- Sample and write
|
||||
virtual void write();
|
||||
|
||||
//- Read the sampledSurfaces dictionary
|
||||
virtual void read(const dictionary&);
|
||||
virtual bool write(const bool postProcess = false);
|
||||
|
||||
//- Update for changes of mesh - expires the surfaces
|
||||
virtual void updateMesh(const mapPolyMesh&);
|
||||
|
||||
@ -1,42 +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 "sampledSurfacesFunctionObject.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
defineNamedTemplateTypeNameAndDebug(sampledSurfacesFunctionObject, 0);
|
||||
|
||||
addToRunTimeSelectionTable
|
||||
(
|
||||
functionObject,
|
||||
sampledSurfacesFunctionObject,
|
||||
dictionary
|
||||
);
|
||||
}
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,54 +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/>.
|
||||
|
||||
Typedef
|
||||
Foam::sampledSurfacesFunctionObject
|
||||
|
||||
Description
|
||||
FunctionObject wrapper around surfaces to allow them to be created via the
|
||||
functions entry within controlDict.
|
||||
|
||||
SourceFiles
|
||||
sampledSurfacesFunctionObject.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef sampledSurfacesFunctionObject_H
|
||||
#define sampledSurfacesFunctionObject_H
|
||||
|
||||
#include "sampledSurfaces.H"
|
||||
#include "OutputFilterFunctionObject.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
typedef OutputFilterFunctionObject<sampledSurfaces>
|
||||
sampledSurfacesFunctionObject;
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
Reference in New Issue
Block a user