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

@ -31,6 +31,7 @@ License
#include "SortableList.H"
#include "volPointInterpolation.H"
#include "mapPolyMesh.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
@ -38,9 +39,16 @@ namespace Foam
{
defineTypeNameAndDebug(sampledSets, 0);
bool sampledSets::verbose_ = false;
addToRunTimeSelectionTable
(
functionObject,
sampledSets,
dictionary
);
}
bool Foam::sampledSets::verbose_ = false;
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
@ -130,6 +138,48 @@ void Foam::sampledSets::combineSampledSets
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::sampledSets::sampledSets
(
const word& name,
const Time& t,
const dictionary& dict
)
:
functionObject(name),
PtrList<sampledSet>(),
mesh_
(
refCast<const fvMesh>
(
t.lookupObject<objectRegistry>
(
dict.lookupOrDefault("region", polyMesh::defaultRegion)
)
)
),
loadFromFiles_(false),
outputPath_(fileName::null),
searchEngine_(mesh_),
interpolationScheme_(word::null),
writeFormat_(word::null)
{
if (Pstream::parRun())
{
outputPath_ = mesh_.time().path()/".."/"postProcessing"/name;
}
else
{
outputPath_ = mesh_.time().path()/"postProcessing"/name;
}
if (mesh_.name() != fvMesh::defaultRegion)
{
outputPath_ = outputPath_/mesh_.name();
}
read(dict);
}
Foam::sampledSets::sampledSets
(
const word& name,
@ -138,8 +188,8 @@ Foam::sampledSets::sampledSets
const bool loadFromFiles
)
:
functionObject(name),
PtrList<sampledSet>(),
name_(name),
mesh_(refCast<const fvMesh>(obr)),
loadFromFiles_(loadFromFiles),
outputPath_(fileName::null),
@ -149,11 +199,11 @@ Foam::sampledSets::sampledSets
{
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;
}
if (mesh_.name() != fvMesh::defaultRegion)
{
@ -178,19 +228,13 @@ void Foam::sampledSets::verbose(const bool verbosity)
}
void Foam::sampledSets::execute()
{}
bool Foam::sampledSets::execute(const bool postProcess)
{
return true;
}
void Foam::sampledSets::end()
{}
void Foam::sampledSets::timeSet()
{}
void Foam::sampledSets::write()
bool Foam::sampledSets::write(const bool postProcess)
{
if (size())
{
@ -230,10 +274,12 @@ void Foam::sampledSets::write()
sampleAndWrite(tensorFields_);
}
}
return true;
}
void Foam::sampledSets::read(const dictionary& dict)
bool Foam::sampledSets::read(const dictionary& dict)
{
dict_ = dict;
@ -276,6 +322,8 @@ void Foam::sampledSets::read(const dictionary& dict)
}
Pout<< ")" << endl;
}
return true;
}

View File

@ -36,6 +36,7 @@ SourceFiles
#ifndef sampledSets_H
#define sampledSets_H
#include "functionObject.H"
#include "sampledSet.H"
#include "volFieldsFwd.H"
#include "meshSearch.H"
@ -49,6 +50,8 @@ SourceFiles
namespace Foam
{
// Forward declaration of classes
class Time;
class objectRegistry;
class dictionary;
class fvMesh;
@ -59,6 +62,7 @@ class fvMesh;
class sampledSets
:
public functionObject,
public PtrList<sampledSet>
{
// Private classes
@ -153,10 +157,6 @@ class sampledSets
// Private data
//- Name of this set of sets,
// Also used as the name of the sampledSets directory.
word name_;
//- Const reference to fvMesh
const fvMesh& mesh_;
@ -256,6 +256,14 @@ public:
// Constructors
//- Construct from Time and dictionary
sampledSets
(
const word& name,
const Time& time,
const dictionary& dict
);
//- Construct for given objectRegistry and dictionary
// allow the possibility to load fields from files
sampledSets
@ -273,29 +281,17 @@ public:
// Member Functions
//- Return name of the set of probes
virtual const word& name() const
{
return name_;
}
//- Set verbosity level
void verbose(const bool verbosity = true);
//- Read the sampledSets
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 sampledSets
virtual void read(const dictionary&);
virtual bool write(const bool postProcess = false);
//- Correct for mesh changes
void correct();

View File

@ -1,34 +0,0 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: dev |
| \\ / A nd | Web: www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
functions
{
// Example of sampling on a line
lines
{
type sets;
functionObjectLibs ("libsampling.so");
writeControl writeTime;
setFormat gnuplot;
fields (p U);
interpolationScheme cellPoint;
sets
(
diagonal
{
type midPoint;
axis x;
start (-0.0206 -0.0254 -0.0005);
end (0.29 0.0254 0.0005);
}
);
}
}

View File

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

View File

@ -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::sampledSetsFunctionObject
Description
FunctionObject wrapper around sets to allow them to be created via the
functions entry within controlDict.
SourceFiles
sampledSetsFunctionObject.C
\*---------------------------------------------------------------------------*/
#ifndef sampledSetsFunctionObject_H
#define sampledSetsFunctionObject_H
#include "sampledSets.H"
#include "OutputFilterFunctionObject.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
typedef OutputFilterFunctionObject<sampledSets>
sampledSetsFunctionObject;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //