Time and functionObject updated for end()

- added end() method to functionObject, functionObjectList & associated classes
- moved outputFilters from src/sampling -> src/OpenFOAM/db/functionObjects
This commit is contained in:
Mark Olesen
2009-02-17 12:48:10 +01:00
parent c2256e51f3
commit fee6e312b9
35 changed files with 255 additions and 114 deletions

View File

@ -48,8 +48,6 @@ graphField/writePatchGraph.C
graphField/writeCellGraph.C
graphField/makeGraph.C
outputFilters/outputFilterOutputControl/outputFilterOutputControl.C
meshToMesh = meshToMeshInterpolation/meshToMesh
$(meshToMesh)/meshToMesh.C
$(meshToMesh)/calculateMeshToMeshAddressing.C

View File

@ -1,88 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
\\/ 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 2 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, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
#include "IOOutputFilter.H"
#include "Time.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class OutputFilter>
Foam::IOOutputFilter<OutputFilter>::IOOutputFilter
(
const word& outputFilterName,
const objectRegistry& obr,
const fileName& dictName,
const IOobject::readOption rOpt,
const bool readFromFiles
)
:
IOdictionary
(
IOobject
(
dictName,
obr.time().system(),
obr,
rOpt,
IOobject::NO_WRITE
)
),
OutputFilter(outputFilterName, obr, *this, readFromFiles)
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
template<class OutputFilter>
Foam::IOOutputFilter<OutputFilter>::~IOOutputFilter()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class OutputFilter>
bool Foam::IOOutputFilter<OutputFilter>::read()
{
if (regIOobject::read())
{
OutputFilter::read(*this);
return true;
}
else
{
return false;
}
}
template<class OutputFilter>
void Foam::IOOutputFilter<OutputFilter>::write()
{
OutputFilter::write();
}
// ************************************************************************* //

View File

@ -1,133 +0,0 @@
/*---------------------------------------------------------------------------* \
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
\\/ 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 2 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, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class
Foam::IOOutputFilter
Description
IOdictionary wrapper around OutputFilter to allow them to read from
their associated dictionaries.
SourceFiles
IOOutputFilter.C
\*---------------------------------------------------------------------------*/
#ifndef IOOutputFilter_H
#define IOOutputFilter_H
#include "IOdictionary.H"
#include "pointFieldFwd.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// Forward declaration of classes
class mapPolyMesh;
/*---------------------------------------------------------------------------*\
Class IOOutputFilter Declaration
\*---------------------------------------------------------------------------*/
template<class OutputFilter>
class IOOutputFilter
:
public IOdictionary,
public OutputFilter
{
// Private Member Functions
// Disallow default bitwise copy construct and assignment
IOOutputFilter(const IOOutputFilter&);
void operator=(const IOOutputFilter&);
public:
// Constructors
//- Construct for given objectRegistry and dictionary
// Allow dictionary to be optional
// Allow the possibility to load fields from files
IOOutputFilter
(
const word& outputFilterName,
const objectRegistry&,
const fileName& dictName = OutputFilter::typeName() + "Dict",
const IOobject::readOption rOpt = IOobject::MUST_READ,
const bool loadFromFile = false
);
//- Destructor
virtual ~IOOutputFilter();
// Member Functions
//- Return name
virtual const word& name() const
{
return IOdictionary::name();
}
//- Read the probes
virtual bool read();
//- Sample and write
virtual void write();
//- Update for changes of mesh
virtual void updateMesh(const mapPolyMesh& mpm)
{
read();
OutputFilter::updateMesh(mpm);
}
//- Update for changes of mesh
virtual void movePoints(const pointField& points)
{
read();
OutputFilter::movePoints(points);
}
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
# include "IOOutputFilter.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -1,156 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
\\/ 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 2 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, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
#include "OutputFilterFunctionObject.H"
#include "IOOutputFilter.H"
#include "polyMesh.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * * Private Members * * * * * * * * * * * * * * //
template<class OutputFilter>
void Foam::OutputFilterFunctionObject<OutputFilter>::readDict()
{
dict_.readIfPresent("region", regionName_);
dict_.readIfPresent("dictionary", dictName_);
dict_.readIfPresent("enabled", enabled_);
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class OutputFilter>
Foam::OutputFilterFunctionObject<OutputFilter>::OutputFilterFunctionObject
(
const word& name,
const Time& t,
const dictionary& dict
)
:
functionObject(),
name_(name),
time_(t),
dict_(dict),
regionName_(polyMesh::defaultRegion),
dictName_(),
enabled_(true),
outputControl_(t, dict)
{
readDict();
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class OutputFilter>
bool Foam::OutputFilterFunctionObject<OutputFilter>::start()
{
readDict();
if (enabled_)
{
if (dictName_.size())
{
ptr_.reset
(
new IOOutputFilter<OutputFilter>
(
name_,
time_.lookupObject<objectRegistry>(regionName_),
dictName_
)
);
}
else
{
ptr_.reset
(
new OutputFilter
(
name_,
time_.lookupObject<objectRegistry>(regionName_),
dict_
)
);
}
}
return true;
}
template<class OutputFilter>
bool Foam::OutputFilterFunctionObject<OutputFilter>::execute()
{
if (enabled_)
{
ptr_->execute();
if (enabled_ && outputControl_.output())
{
ptr_->write();
}
}
return true;
}
template<class OutputFilter>
void Foam::OutputFilterFunctionObject<OutputFilter>::on()
{
enabled_ = true;
}
template<class OutputFilter>
void Foam::OutputFilterFunctionObject<OutputFilter>::off()
{
enabled_ = false;
}
template<class OutputFilter>
bool Foam::OutputFilterFunctionObject<OutputFilter>::read
(
const dictionary& dict
)
{
if (dict != dict_)
{
dict_ = dict;
outputControl_.read(dict);
return start();
}
else
{
return false;
}
}
// ************************************************************************* //

View File

@ -1,148 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
\\/ 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 2 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, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class
Foam::OutputFilterFunctionObject
Description
A functionObject wrapper around OutputFilter to allow them to be
created via the functions list within controlDict.
Note
Since the timeIndex is used directly from Foam::Time, it is unaffected
by user-time conversions. For example, Foam::engineTime might cause @a
writeInterval to be degrees crank angle, but the functionObject
execution @a interval would still be in timestep.
SourceFiles
OutputFilterFunctionObject.C
\*---------------------------------------------------------------------------*/
#ifndef OutputFilterFunctionObject_H
#define OutputFilterFunctionObject_H
#include "functionObject.H"
#include "dictionary.H"
#include "outputFilterOutputControl.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class OutputFilterFunctionObject Declaration
\*---------------------------------------------------------------------------*/
template<class OutputFilter>
class OutputFilterFunctionObject
:
public functionObject
{
// Private data
word name_;
const Time& time_;
dictionary dict_;
word regionName_;
word dictName_;
//- Switch for the execution of the functionObjects
bool enabled_;
outputFilterOutputControl outputControl_;
autoPtr<OutputFilter> ptr_;
// Private Member Functions
//- Read relevant dictionary entries
void readDict();
//- Disallow default bitwise copy construct
OutputFilterFunctionObject(const OutputFilterFunctionObject&);
//- Disallow default bitwise assignment
void operator=(const OutputFilterFunctionObject&);
public:
//- Runtime type information
TypeName(OutputFilter::typeName_());
// Constructors
//- Construct from components
OutputFilterFunctionObject
(
const word& name,
const Time&,
const dictionary&
);
// Member Functions
//- Return name
virtual const word& name() const
{
return name_;
}
//- start is called at the start of the time-loop
virtual bool start();
//- execute is called at each ++ or += of the time-loop
virtual bool execute();
//- Switch the function object on
virtual void on();
//- Switch the function object off
virtual void off();
//- Read and set the function object if its data have changed
virtual bool read(const dictionary&);
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
# include "OutputFilterFunctionObject.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -1,119 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
\\/ 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 2 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, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
#include "outputFilterOutputControl.H"
// * * * * * * * * * * * * * Static Member Data * * * * * * * * * * * * * * //
template<>
const char* Foam::NamedEnum
<
Foam::outputFilterOutputControl::outputControls,
2
>::names[] =
{
"timeStep",
"outputTime"
};
const Foam::NamedEnum<Foam::outputFilterOutputControl::outputControls, 2>
Foam::outputFilterOutputControl::outputControlNames_;
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::outputFilterOutputControl::outputFilterOutputControl
(
const Time& t,
const dictionary& dict
)
:
time_(t),
outputControl_(ocTimeStep),
outputInterval_(0)
{
read(dict);
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::outputFilterOutputControl::~outputFilterOutputControl()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::outputFilterOutputControl::read(const dictionary& dict)
{
outputControl_ = outputControlNames_.read(dict.lookup("outputControl"));
switch (outputControl_)
{
case ocTimeStep:
{
dict.lookup("outputInterval") >> outputInterval_;
}
default:
{
// do nothing
}
}
}
bool Foam::outputFilterOutputControl::output() const
{
switch (outputControl_)
{
case ocTimeStep:
{
return
(
(outputInterval_ <= 1)
|| !(time_.timeIndex() % outputInterval_)
);
break;
}
case ocOutputTime:
{
return time_.outputTime();
break;
}
default:
{
FatalErrorIn("bool Foam::outputFilterOutputControl::output()")
<< "Unknown output control: "
<< outputControlNames_[outputControl_] << nl
<< abort(FatalError);
}
}
return false;
}
// ************************************************************************* //

View File

@ -1,123 +0,0 @@
/*---------------------------------------------------------------------------* \
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
\\/ 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 2 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, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class
Foam::outputFilterOutputControl
Description
SourceFiles
outputFilterOutputControl.C
\*---------------------------------------------------------------------------*/
#ifndef outputFilterOutputControl_H
#define outputFilterOutputControl_H
#include "dictionary.H"
#include "Time.H"
#include "NamedEnum.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class outputFilterOutputControl Declaration
\*---------------------------------------------------------------------------*/
class outputFilterOutputControl
{
public:
enum outputControls
{
ocTimeStep,
ocOutputTime
};
private:
// Private data
//- Time object
const Time& time_;
//- String representation of outputControls enums
static const NamedEnum<outputControls, 2> outputControlNames_;
//- Type of output
outputControls outputControl_;
//- The execution interval (in time steps) when using TIMESTEP mode
// a value <= 1 means execute at every time step
label outputInterval_;
// Private Member Functions
//- Disallow default bitwise copy construct and assignment
outputFilterOutputControl(const outputFilterOutputControl&);
void operator=(const outputFilterOutputControl&);
public:
// Constructors
//- Construct from Time object and dictionary
outputFilterOutputControl(const Time&, const dictionary&);
// Destructor
~outputFilterOutputControl();
// Member Functions
//- Read from dictionary
void read(const dictionary&);
//- Return const access to the Time object
const Time& time() const
{
return time_;
}
//- Flag to indicate whether to output
bool output() const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -304,6 +304,12 @@ void Foam::probes::execute()
}
void Foam::probes::end()
{
// Do nothing - only valid on write
}
void Foam::probes::write()
{
if (probeLocations_.size() && checkFieldTypes())

View File

@ -194,15 +194,18 @@ public:
return cellList_;
}
//- Execute, currently does nothing
virtual void execute();
//- Execute at the final time-loop, currently does nothing
virtual void end();
//- Sample and write
virtual void write();
//- Read the probes
virtual void read(const dictionary&);
//- Execute
virtual void execute();
//- Update for changes of mesh
virtual void updateMesh(const mapPolyMesh&)
{}

View File

@ -275,6 +275,12 @@ void Foam::sampledSets::execute()
}
void Foam::sampledSets::end()
{
// Do nothing - only valid on write
}
void Foam::sampledSets::write()
{
if (size() && checkFieldTypes())

View File

@ -270,9 +270,12 @@ public:
//- set verbosity level
void verbose(const bool verbosity = true);
//- Execute
//- Execute, currently does nothing
virtual void execute();
//- Execute at the final time-loop, currently does nothing
virtual void end();
//- Sample and write
virtual void write();

View File

@ -335,7 +335,7 @@ bool Foam::sampledIsoSurface::updateGeometry() const
subMeshPtr_.reset
(
new fvMeshSubset(static_cast<const fvMesh&>(mesh()))
new fvMeshSubset(fvm)
);
subMeshPtr_().setLargeCellSubset
(

View File

@ -87,7 +87,7 @@ class sampledIsoSurface
// Recreated for every isoSurface
//- Time at last call, also track it surface needs an update
//- Time at last call, also track if surface needs an update
mutable label prevTimeIndex_;
//- Cached volfield

View File

@ -203,7 +203,6 @@ Foam::sampledSurfaces::~sampledSurfaces()
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::sampledSurfaces::verbose(const bool verbosity)
{
verbose_ = verbosity;
@ -216,6 +215,12 @@ void Foam::sampledSurfaces::execute()
}
void Foam::sampledSurfaces::end()
{
// Do nothing - only valid on write
}
void Foam::sampledSurfaces::write()
{
if (size() && checkFieldTypes())

View File

@ -257,9 +257,12 @@ public:
//- set verbosity level
void verbose(const bool verbosity = true);
//- Execute
//- Execute, currently does nothing
virtual void execute();
//- Execute at the final time-loop, currently does nothing
virtual void end();
//- Sample and write
virtual void write();