mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
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:
@ -2,11 +2,11 @@ EXE_INC = \
|
||||
-IfoamToVTK/lnInclude \
|
||||
-I$(LIB_SRC)/lagrangian/basic/lnInclude \
|
||||
-I$(LIB_SRC)/finiteVolume/lnInclude \
|
||||
-I$(LIB_SRC)/dynamicMesh/lnInclude \
|
||||
-I$(LIB_SRC)/meshTools/lnInclude
|
||||
|
||||
EXE_LIBS = \
|
||||
-lfoamToVTK \
|
||||
-lfiniteVolume \
|
||||
-ldynamicMesh \
|
||||
-llagrangian \
|
||||
-lgenericPatchFields \
|
||||
-lmeshTools
|
||||
-lgenericPatchFields
|
||||
|
||||
@ -10,6 +10,5 @@ vtkMesh.C
|
||||
vtkTopo.C
|
||||
|
||||
writeVTK/writeVTK.C
|
||||
writeVTK/writeVTKFunctionObject.C
|
||||
|
||||
LIB = $(FOAM_LIBBIN)/libfoamToVTK
|
||||
|
||||
@ -1,10 +1,10 @@
|
||||
EXE_INC = \
|
||||
-I$(LIB_SRC)/lagrangian/basic/lnInclude \
|
||||
-I$(LIB_SRC)/finiteVolume/lnInclude \
|
||||
-I$(LIB_SRC)/dynamicMesh/lnInclude \
|
||||
-I$(LIB_SRC)/meshTools/lnInclude
|
||||
|
||||
LIB_LIBS = \
|
||||
-lfiniteVolume \
|
||||
-ldynamicMesh \
|
||||
-llagrangian \
|
||||
-lgenericPatchFields \
|
||||
-lmeshTools
|
||||
-lgenericPatchFields
|
||||
|
||||
@ -28,6 +28,7 @@ License
|
||||
#include "Time.H"
|
||||
#include "vtkMesh.H"
|
||||
#include "internalWriter.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
@ -36,6 +37,7 @@ namespace Foam
|
||||
namespace functionObjects
|
||||
{
|
||||
defineTypeNameAndDebug(writeVTK, 0);
|
||||
addToRunTimeSelectionTable(functionObject, writeVTK, dictionary);
|
||||
}
|
||||
}
|
||||
|
||||
@ -45,16 +47,22 @@ namespace functionObjects
|
||||
Foam::functionObjects::writeVTK::writeVTK
|
||||
(
|
||||
const word& name,
|
||||
const objectRegistry& obr,
|
||||
const dictionary& dict,
|
||||
const bool loadFromFiles
|
||||
const Time& t,
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
name_(name),
|
||||
obr_(obr),
|
||||
functionObject(name),
|
||||
time_(t),
|
||||
obr_
|
||||
(
|
||||
time_.lookupObject<objectRegistry>
|
||||
(
|
||||
dict.lookupOrDefault("region", polyMesh::defaultRegion)
|
||||
)
|
||||
),
|
||||
objectNames_()
|
||||
{
|
||||
if (!isA<fvMesh>(obr))
|
||||
if (!isA<fvMesh>(obr_))
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "objectRegistry is not an fvMesh" << exit(FatalError);
|
||||
@ -72,27 +80,23 @@ Foam::functionObjects::writeVTK::~writeVTK()
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::functionObjects::writeVTK::read(const dictionary& dict)
|
||||
bool Foam::functionObjects::writeVTK::read(const dictionary& dict)
|
||||
{
|
||||
dict.lookup("objectNames") >> objectNames_;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void Foam::functionObjects::writeVTK::execute()
|
||||
{}
|
||||
|
||||
|
||||
void Foam::functionObjects::writeVTK::end()
|
||||
{}
|
||||
|
||||
|
||||
void Foam::functionObjects::writeVTK::timeSet()
|
||||
{}
|
||||
|
||||
|
||||
void Foam::functionObjects::writeVTK::write()
|
||||
bool Foam::functionObjects::writeVTK::execute(const bool postProcess)
|
||||
{
|
||||
Info<< type() << " " << name_ << " output:" << nl;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool Foam::functionObjects::writeVTK::write(const bool postProcess)
|
||||
{
|
||||
Info<< type() << " " << name() << " output:" << nl;
|
||||
|
||||
fvMesh& mesh = const_cast<fvMesh&>(refCast<const fvMesh>(obr_));
|
||||
|
||||
@ -162,6 +166,8 @@ void Foam::functionObjects::writeVTK::write()
|
||||
writer.write(vsptf);
|
||||
writer.write(vstf);
|
||||
writer.write(vtf);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -55,7 +55,7 @@ Description
|
||||
|
||||
SeeAlso
|
||||
Foam::functionObject
|
||||
Foam::OutputFilterFunctionObject
|
||||
Foam::functionObjects::timeControl
|
||||
|
||||
SourceFiles
|
||||
writeVTK.C
|
||||
@ -66,8 +66,8 @@ SourceFiles
|
||||
#ifndef functionObjects_writeVTK_H
|
||||
#define functionObjects_writeVTK_H
|
||||
|
||||
#include "functionObject.H"
|
||||
#include "wordReList.H"
|
||||
#include "runTimeSelectionTables.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -75,10 +75,8 @@ namespace Foam
|
||||
{
|
||||
|
||||
// Forward declaration of classes
|
||||
class Time;
|
||||
class objectRegistry;
|
||||
class dictionary;
|
||||
class polyMesh;
|
||||
class mapPolyMesh;
|
||||
|
||||
namespace functionObjects
|
||||
{
|
||||
@ -88,13 +86,15 @@ namespace functionObjects
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class writeVTK
|
||||
:
|
||||
public functionObject
|
||||
{
|
||||
// Private data
|
||||
|
||||
//- Name of this set of writeVTK
|
||||
word name_;
|
||||
//- Reference to the Time
|
||||
const Time& time_;
|
||||
|
||||
//- Refererence to Db
|
||||
//- Refererence to objectRegistry
|
||||
const objectRegistry& obr_;
|
||||
|
||||
//- Names of objects
|
||||
@ -121,14 +121,12 @@ public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct for given objectRegistry and dictionary.
|
||||
// Allow the possibility to load fields from files
|
||||
//- Construct from Time and dictionary
|
||||
writeVTK
|
||||
(
|
||||
const word& name,
|
||||
const objectRegistry&,
|
||||
const dictionary&,
|
||||
const bool loadFromFiles = false
|
||||
const Time& t,
|
||||
const dictionary&
|
||||
);
|
||||
|
||||
|
||||
@ -138,34 +136,14 @@ public:
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Return name of the writeVTK
|
||||
virtual const word& name() const
|
||||
{
|
||||
return name_;
|
||||
}
|
||||
|
||||
//- Read the writeVTK data
|
||||
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 the writeVTK
|
||||
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);
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -1,46 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 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 "writeVTKFunctionObject.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
defineNamedTemplateTypeNameAndDebug
|
||||
(
|
||||
writeVTKFunctionObject,
|
||||
0
|
||||
);
|
||||
|
||||
addToRunTimeSelectionTable
|
||||
(
|
||||
functionObject,
|
||||
writeVTKFunctionObject,
|
||||
dictionary
|
||||
);
|
||||
}
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,54 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 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::writeVTKFunctionObject
|
||||
|
||||
Description
|
||||
FunctionObject wrapper around writeVTK to allow them to be
|
||||
created via the functions entry within controlDict.
|
||||
|
||||
SourceFiles
|
||||
writeVTKFunctionObject.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef writeVTKFunctionObject_H
|
||||
#define writeVTKFunctionObject_H
|
||||
|
||||
#include "writeVTK.H"
|
||||
#include "OutputFilterFunctionObject.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
typedef OutputFilterFunctionObject<functionObjects::writeVTK>
|
||||
writeVTKFunctionObject;
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
Reference in New Issue
Block a user