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:
@ -24,9 +24,9 @@ License
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "turbulenceFields.H"
|
||||
#include "dictionary.H"
|
||||
#include "turbulentTransportModel.H"
|
||||
#include "turbulentFluidThermoModel.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
@ -35,6 +35,13 @@ namespace Foam
|
||||
namespace functionObjects
|
||||
{
|
||||
defineTypeNameAndDebug(turbulenceFields, 0);
|
||||
|
||||
addToRunTimeSelectionTable
|
||||
(
|
||||
functionObject,
|
||||
turbulenceFields,
|
||||
dictionary
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -116,16 +123,21 @@ bool Foam::functionObjects::turbulenceFields::compressible()
|
||||
Foam::functionObjects::turbulenceFields::turbulenceFields
|
||||
(
|
||||
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);
|
||||
@ -133,8 +145,8 @@ Foam::functionObjects::turbulenceFields::turbulenceFields
|
||||
|
||||
if
|
||||
(
|
||||
!obr.foundObject<compressible::turbulenceModel>(modelName)
|
||||
&& !obr.foundObject<incompressible::turbulenceModel>(modelName)
|
||||
!obr_.foundObject<compressible::turbulenceModel>(modelName)
|
||||
&& !obr_.foundObject<incompressible::turbulenceModel>(modelName)
|
||||
)
|
||||
{
|
||||
FatalErrorInFunction
|
||||
@ -154,11 +166,11 @@ Foam::functionObjects::turbulenceFields::~turbulenceFields()
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::functionObjects::turbulenceFields::read(const dictionary& dict)
|
||||
bool Foam::functionObjects::turbulenceFields::read(const dictionary& dict)
|
||||
{
|
||||
fieldSet_.insert(wordList(dict.lookup("fields")));
|
||||
|
||||
Info<< type() << " " << name_ << ": ";
|
||||
Info<< type() << " " << name() << ": ";
|
||||
if (fieldSet_.size())
|
||||
{
|
||||
Info<< "storing fields:" << nl;
|
||||
@ -172,10 +184,12 @@ void Foam::functionObjects::turbulenceFields::read(const dictionary& dict)
|
||||
{
|
||||
Info<< "no fields requested to be stored" << nl << endl;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void Foam::functionObjects::turbulenceFields::execute()
|
||||
bool Foam::functionObjects::turbulenceFields::execute(const bool postProcess)
|
||||
{
|
||||
bool comp = compressible();
|
||||
|
||||
@ -285,21 +299,15 @@ void Foam::functionObjects::turbulenceFields::execute()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void Foam::functionObjects::turbulenceFields::end()
|
||||
bool Foam::functionObjects::turbulenceFields::write(const bool postProcess)
|
||||
{
|
||||
execute();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void Foam::functionObjects::turbulenceFields::timeSet()
|
||||
{}
|
||||
|
||||
|
||||
void Foam::functionObjects::turbulenceFields::write()
|
||||
{}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -77,7 +77,7 @@ Description
|
||||
|
||||
SeeAlso
|
||||
Foam::functionObject
|
||||
Foam::OutputFilterFunctionObject
|
||||
Foam::functionObjects::timeControl
|
||||
|
||||
SourceFiles
|
||||
turbulenceFields.C
|
||||
@ -87,6 +87,7 @@ SourceFiles
|
||||
#ifndef functionObjects_turbulenceFields_H
|
||||
#define functionObjects_turbulenceFields_H
|
||||
|
||||
#include "functionObject.H"
|
||||
#include "HashSet.H"
|
||||
#include "NamedEnum.H"
|
||||
#include "volFieldsFwd.H"
|
||||
@ -98,9 +99,6 @@ namespace Foam
|
||||
|
||||
// Forward declaration of classes
|
||||
class objectRegistry;
|
||||
class dictionary;
|
||||
class polyMesh;
|
||||
class mapPolyMesh;
|
||||
|
||||
namespace functionObjects
|
||||
{
|
||||
@ -110,6 +108,8 @@ namespace functionObjects
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class turbulenceFields
|
||||
:
|
||||
public functionObject
|
||||
{
|
||||
public:
|
||||
|
||||
@ -144,9 +144,7 @@ protected:
|
||||
|
||||
// Protected data
|
||||
|
||||
//- Name of this set of turbulenceFields object
|
||||
word name_;
|
||||
|
||||
//- Reference to the objectRegistry
|
||||
const objectRegistry& obr_;
|
||||
|
||||
//- Fields to load
|
||||
@ -186,14 +184,12 @@ public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct for given objectRegistry and dictionary.
|
||||
// Allow the possibility to load fields from files
|
||||
//- Construct from Time and dictionary
|
||||
turbulenceFields
|
||||
(
|
||||
const word& name,
|
||||
const objectRegistry&,
|
||||
const dictionary&,
|
||||
const bool loadFromFiles = false
|
||||
const Time& runTime,
|
||||
const dictionary& dict
|
||||
);
|
||||
|
||||
|
||||
@ -203,34 +199,15 @@ public:
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Return name of the turbulenceFields 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 turbulence 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&)
|
||||
{}
|
||||
//- Do nothing.
|
||||
// The turbulence fields are registered and written automatically
|
||||
virtual bool write(const bool postProcess = false);
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -1,42 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2012-2014 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 "turbulenceFieldsFunctionObject.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
defineNamedTemplateTypeNameAndDebug(turbulenceFieldsFunctionObject, 0);
|
||||
|
||||
addToRunTimeSelectionTable
|
||||
(
|
||||
functionObject,
|
||||
turbulenceFieldsFunctionObject,
|
||||
dictionary
|
||||
);
|
||||
}
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -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::turbulenceFieldsFunctionObject
|
||||
|
||||
Description
|
||||
FunctionObject wrapper around turbulenceFields to allow them to be created
|
||||
via the functions entry within controlDict.
|
||||
|
||||
SourceFiles
|
||||
turbulenceFieldsFunctionObject.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef turbulenceFieldsFunctionObject_H
|
||||
#define turbulenceFieldsFunctionObject_H
|
||||
|
||||
#include "turbulenceFields.H"
|
||||
#include "OutputFilterFunctionObject.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
typedef OutputFilterFunctionObject<functionObjects::turbulenceFields>
|
||||
turbulenceFieldsFunctionObject;
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
Reference in New Issue
Block a user