functionObjects::partialWrite: Redundant and removed

the equivalent functionality is provided by the writeRegisteredObject
   functionObject in a MUCH simpler, easier and extensible manner.

functionObject: Removed the now redundant 'timeSet' function.
This commit is contained in:
Henry Weller 2016-05-18 12:23:29 +01:00
parent 354bc8bdcb
commit 5af1a7e4f3
19 changed files with 5 additions and 731 deletions

View File

@ -40,7 +40,7 @@ Description
writeVTK1
{
type writeVTK;
libs ("libIOFunctionObjects.so");
libs ("libutilityFunctionObjects.so");
...
objectNames (obj1 obj2);
}

View File

@ -88,12 +88,6 @@ bool Foam::functionObjects::FUNCTIONOBJECT::end()
}
bool Foam::functionObjects::FUNCTIONOBJECT::timeSet()
{
return true;
}
bool Foam::functionObjects::FUNCTIONOBJECT::write(const bool postProcess)
{
return true;

View File

@ -130,9 +130,6 @@ public:
//- Execute at the final time-loop, currently does nothing
virtual bool end();
//- Called when time was set at the end of the Time::operator++
virtual bool timeSet();
//- Write the FUNCTIONOBJECT
virtual bool write(const bool postProcess = false);
};

View File

@ -1248,8 +1248,6 @@ Foam::Time& Foam::Time::operator++()
}
}
}
functionObjects_.timeSet();
}
return *this;

View File

@ -126,12 +126,6 @@ bool Foam::functionObject::end()
}
bool Foam::functionObject::timeSet()
{
return false;
}
bool Foam::functionObject::adjustTimeStep()
{
return false;

View File

@ -215,9 +215,6 @@ public:
// By default it simply calls execute().
virtual bool end();
//- Called when time was set at the end of the Time::operator++
virtual bool timeSet();
//- Called at the end of Time::adjustDeltaT() if adjustTime is true
virtual bool adjustTimeStep();

View File

@ -229,27 +229,6 @@ bool Foam::functionObjectList::end()
}
bool Foam::functionObjectList::timeSet()
{
bool ok = true;
if (execution_)
{
if (!updated_)
{
read();
}
forAll(*this, objectI)
{
ok = operator[](objectI).timeSet() && ok;
}
}
return ok;
}
bool Foam::functionObjectList::adjustTimeStep()
{
bool ok = true;

View File

@ -182,9 +182,6 @@ public:
//- Called when Time::run() determines that the time-loop exits
bool end();
//- Called when time was set at the end of the Time::operator++
bool timeSet();
//- Called at the end of Time::adjustDeltaT() if adjustTime is true
bool adjustTimeStep();

View File

@ -118,16 +118,6 @@ bool Foam::functionObjects::timeControl::end()
}
bool Foam::functionObjects::timeControl::timeSet()
{
if (active())
{
foPtr_->timeSet();
}
return true;
}
bool Foam::functionObjects::timeControl::adjustTimeStep()
{

View File

@ -161,9 +161,6 @@ public:
//- Called when Time::run() determines that the time-loop exits
virtual bool end();
//- Called when time was set at the end of the Time::operator++
virtual bool timeSet();
//- Called at the end of Time::adjustDeltaT() if adjustTime is true
virtual bool adjustTimeStep();

View File

@ -14,7 +14,6 @@ yPlus/yPlus.C
setTimeStep/setTimeStepFunctionObject.C
systemCall/systemCall.C
abort/abort.C
partialWrite/partialWrite.C
removeRegisteredObject/removeRegisteredObject.C
writeDictionary/writeDictionary.C
writeRegisteredObject/writeRegisteredObject.C

View File

@ -1,122 +0,0 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: dev |
| \\ / A nd | Web: www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object controlDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// So we get a decent warning if we have multiple functionObject entries
// with the same name.
#inputMode error;
application icoFoam;
startFrom startTime;
startTime 0;
stopAt endTime;
endTime 0.5;
deltaT 0.005;
writeControl timeStep;
writeInterval 20;
purgeWrite 0;
writeFormat ascii;
writePrecision 6;
writeCompression uncompressed;
timeFormat general;
timePrecision 6;
runTimeModifiable yes;
functions
{
partialWrite
{
// Write some registered objects more often than others.
// Above writeControl determines most frequent dump.
type partialWrite;
// Where to load it from
libs ("libIOFunctionObjects.so");
// Optional mesh region to operate on. Only one partialWrite per
// region allowed.
region wallFilmRegion;
// Execute upon options:
// timeStep
// writeTime
// adjustableRunTime
// runTime
// clockTime
// cpuTime
writeControl writeTime;
// Objects (fields or lagrangian fields in any of the clouds)
// to write every writeTime
objectNames (p positions nParticle);
// Write as normal every writeInterval'th writeTime.
writeInterval 1; // (timeStep, writeTime)
// Interval of time (sec) to write down(
writeInterval 10.5 //(adjustableRunTime, runTime, clockTime, cpuTime)
}
dumpObjects
{
// Forcibly write registered objects
type writeRegisteredObject;
// Where to load it from
libs ("libIOFunctionObjects.so");
// When to write:
// timeStep (with optional writeInterval)
// writeTime (with optional writeInterval)
// adjustableRunTime
// runTime
// clockTime
// cpuTime
writeControl writeTime;
// Write every writeInterval (only valid for timeStemp, writeTime)
writeInterval 1;
// Interval of time (valid for adjustableRunTime, runTime, clockTime,
// cpuTime)
writeInterval 10.5;
// Objects to write
objectNames ();
// Is the object written by this function Object alone
// (default is false)
//exclusiveWriting true;
}
}
// ************************************************************************* //

View File

@ -1,192 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2014-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 "partialWrite.H"
#include "Time.H"
#include "polyMesh.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
namespace functionObjects
{
defineTypeNameAndDebug(partialWrite, 0);
addToRunTimeSelectionTable
(
functionObject,
partialWrite,
dictionary
);
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::functionObjects::partialWrite::partialWrite
(
const word& name,
const Time& runTime,
const dictionary& dict
)
:
functionObject(name),
obr_
(
runTime.lookupObject<objectRegistry>
(
dict.lookupOrDefault("region", polyMesh::defaultRegion)
)
)
{
read(dict);
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::functionObjects::partialWrite::~partialWrite()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::functionObjects::partialWrite::read(const dictionary& dict)
{
dict.lookup("objectNames") >> objectNames_;
dict.lookup("writeInterval") >> writeInterval_;
writeInstance_ = 0;
Info<< type() << " " << name() << ":" << nl
<< " dumping every " << writeInterval_
<< " th writeTime : " << nl << endl ;
forAllConstIter(HashSet<word>, objectNames_, iter)
{
Info<< ' ' << iter.key();
}
if (writeInterval_ < 1)
{
FatalIOErrorInFunction(dict)
<< "Illegal value for writeInterval " << writeInterval_
<< ". It should be >= 1."
<< exit(FatalIOError);
}
// Clear out any previously loaded fields
vsf_.clear();
vvf_.clear();
vSpheretf_.clear();
vSymmtf_.clear();
vtf_.clear();
ssf_.clear();
svf_.clear();
sSpheretf_.clear();
sSymmtf_.clear();
stf_.clear();
forAllConstIter(HashSet<word>, objectNames_, iter)
{
loadField<scalar>(iter.key(), vsf_, ssf_);
loadField<vector>(iter.key(), vvf_, svf_);
loadField<sphericalTensor>(iter.key(), vSpheretf_, sSpheretf_);
loadField<symmTensor>(iter.key(), vSymmtf_, sSymmtf_);
loadField<tensor>(iter.key(), vtf_, stf_);
}
return true;
}
bool Foam::functionObjects::partialWrite::execute(const bool postProcess)
{
return true;
}
bool Foam::functionObjects::partialWrite::timeSet()
{
if (obr_.time().writeTime())
{
writeInstance_++;
if (writeInstance_ == writeInterval_)
{
// Next overall dump corresponds to partial write. Change
// write options to AUTO_WRITE
writeInstance_ = 0;
changeWriteOptions<scalar>(vsf_, ssf_, IOobject::AUTO_WRITE);
changeWriteOptions<vector>(vvf_, svf_, IOobject::AUTO_WRITE);
changeWriteOptions<sphericalTensor>
(
vSpheretf_,
sSpheretf_,
IOobject::AUTO_WRITE
);
changeWriteOptions<symmTensor>
(
vSymmtf_,
sSymmtf_,
IOobject::AUTO_WRITE
);
changeWriteOptions<tensor>(vtf_, stf_, IOobject::AUTO_WRITE);
}
else
{
changeWriteOptions<scalar>(vsf_, ssf_, IOobject::NO_WRITE);
changeWriteOptions<vector>(vvf_, svf_, IOobject::NO_WRITE);
changeWriteOptions<sphericalTensor>
(
vSpheretf_,
sSpheretf_,
IOobject::NO_WRITE
);
changeWriteOptions<symmTensor>
(
vSymmtf_,
sSymmtf_,
IOobject::NO_WRITE
);
changeWriteOptions<tensor>(vtf_, stf_, IOobject::NO_WRITE);
}
}
return true;
}
bool Foam::functionObjects::partialWrite::write(const bool postProcess)
{
return true;
}
// ************************************************************************* //

View File

@ -1,203 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-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/>.
Class
Foam::functionObjects::partialWrite
Group
grpUtilitiesFunctionObjects
Description
This function object allows user-selected fields/registered objects to be
written at a custom write interval. The interval is given in terms of
number of overall dumps
Example of function object specification:
\verbatim
partialWrite1
{
type partialWrite;
libs ("libIOFunctionObjects.so");
...
objectNames (p U T);
writeInterval 100;
}
\endverbatim
\heading Function object usage
\table
Property | Description | Required | Default value
type | type name: partialWrite | yes |
objectNames | objects to write | yes |
writeInterval | write interval | yes |
\endtable
SeeAlso
Foam::functionObject
Foam::functionObjects::timeControl
SourceFiles
partialWrite.C
\*---------------------------------------------------------------------------*/
#ifndef functionObjects_partialWrite_H
#define functionObjects_partialWrite_H
#include "functionObject.H"
#include "HashSet.H"
#include "volFields.H"
#include "surfaceFields.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
namespace functionObjects
{
/*---------------------------------------------------------------------------*\
Class partialWrite Declaration
\*---------------------------------------------------------------------------*/
class partialWrite
:
public functionObject
{
protected:
// Protected data
//- Reference to the objectRegistry
const objectRegistry& obr_;
//- Loaded fields
UPtrList<volScalarField> vsf_;
UPtrList<volVectorField> vvf_;
UPtrList<volSphericalTensorField> vSpheretf_;
UPtrList<volSymmTensorField> vSymmtf_;
UPtrList<volTensorField> vtf_;
UPtrList<surfaceScalarField> ssf_;
UPtrList<surfaceVectorField> svf_;
UPtrList<surfaceSphericalTensorField> sSpheretf_;
UPtrList<surfaceSymmTensorField> sSymmtf_;
UPtrList<surfaceTensorField> stf_;
// Read from dictionary
//- Names of objects to dump always
HashSet<word> objectNames_;
//- Write interval for restart dump
label writeInterval_;
//- Current dump instance. If reaches writeInterval do a full write.
label writeInstance_;
private:
// Private Member Functions
//- Disallow default bitwise copy construct
partialWrite(const partialWrite&);
//- Disallow default bitwise assignment
void operator=(const partialWrite&);
//- Load objects in the objectNames
template<class Type>
void loadField
(
const word&,
UPtrList<GeometricField<Type, fvPatchField, volMesh>>&,
UPtrList<GeometricField<Type, fvsPatchField, surfaceMesh>>&
) const;
template<class Type>
void changeWriteOptions
(
UPtrList<GeometricField<Type, fvPatchField, volMesh>>&,
UPtrList<GeometricField<Type, fvsPatchField, surfaceMesh>>&,
const IOobject::writeOption
) const;
public:
//- Runtime type information
TypeName("partialWrite");
// Constructors
//- Construct from Time and dictionary
partialWrite
(
const word& name,
const Time& runTime,
const dictionary& dict
);
//- Destructor
virtual ~partialWrite();
// Member Functions
//- Read the partialWrite data
virtual bool read(const dictionary&);
//- Called when time was set at the end of the Time::operator++
virtual bool timeSet();
//- Execute
virtual bool execute(const bool postProcess = false);
//- Do nothing.
// The fields are registered and written automatically
virtual bool write(const bool postProcess = false);
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace functionObjects
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
#include "partialWriteTemplates.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -1,46 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-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 "partialWriteFunctionObject.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineNamedTemplateTypeNameAndDebug
(
partialWriteFunctionObject,
0
);
addToRunTimeSelectionTable
(
functionObject,
partialWriteFunctionObject,
dictionary
);
}
// ************************************************************************* //

View File

@ -1,105 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2013-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 "partialWrite.H"
#include "volFields.H"
#include "surfaceFields.H"
#include "Time.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
template<class Type>
void Foam::functionObjects::partialWrite::loadField
(
const word& fieldName,
UPtrList<GeometricField<Type, fvPatchField, volMesh>>& vflds,
UPtrList<GeometricField<Type, fvsPatchField, surfaceMesh>>& sflds
) const
{
typedef GeometricField<Type, fvPatchField, volMesh> vfType;
typedef GeometricField<Type, fvsPatchField, surfaceMesh> sfType;
if (obr_.foundObject<vfType>(fieldName))
{
if (debug)
{
Info<< "partialWrite : Field "
<< fieldName << " found in database" << endl;
}
vfType& vField =
const_cast<vfType&>
(
obr_.lookupObject<vfType>(fieldName)
);
const unsigned int sz = vflds.size();
vflds.setSize(sz + 1);
vflds.set(sz, &vField);
}
else if (obr_.foundObject<sfType>(fieldName))
{
if (debug)
{
Info<< "partialWrite : Field " << fieldName
<< " found in database" << endl;
}
sfType& sField =
const_cast<sfType&>
(
obr_.lookupObject<sfType>(fieldName)
);
const unsigned int sz = sflds.size();
sflds.setSize(sz + 1);
sflds.set(sz, &sField);
}
}
template<class Type>
void Foam::functionObjects::partialWrite::changeWriteOptions
(
UPtrList<GeometricField<Type, fvPatchField, volMesh>>& vflds,
UPtrList<GeometricField<Type, fvsPatchField, surfaceMesh>>& sflds,
const IOobject::writeOption wOption
) const
{
forAll(vflds , i)
{
vflds[i].writeOpt() = wOption;
}
forAll(sflds , i)
{
sflds[i].writeOpt() = wOption;
}
}
// ************************************************************************* //

View File

@ -35,7 +35,7 @@ Description
removeRegisteredObject1
{
type removeRegisteredObject;
libs ("libIOFunctionObjects.so");
libs ("libutilityFunctionObjects.so");
...
objectNames (obj1 obj2);
}

View File

@ -58,7 +58,7 @@ functions
type partialWrite;
// Where to load it from
libs ("libIOFunctionObjects.so");
libs ("libutilityFunctionObjects.so");
// Optional mesh region to operate on. Only one partialWrite per
// region allowed.
@ -91,7 +91,7 @@ functions
type writeRegisteredObject;
// Where to load it from
libs ("libIOFunctionObjects.so");
libs ("libutilityFunctionObjects.so");
// When to write:
// timeStep (with optional writeInterval)

View File

@ -44,7 +44,7 @@ Description
writeRegisteredObject1
{
type writeRegisteredObject;
libs ("libIOFunctionObjects.so");
libs ("libutilityFunctionObjects.so");
exclusiveWriting true;
...
objectNames (obj1 obj2);