mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
EMH: Adding a hook to functionObject called 'timeSet' at the
end of Time::operator++. This allows to know if the next timeIndex will be a dumping time. The function object "partialWrite" modifyes the write option of the those fields which will be written down at given intervals of the overall outout times.
This commit is contained in:
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2013 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -87,13 +87,33 @@ void Foam::partialWrite::read(const dictionary& dict)
|
||||
<< ". 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_);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::partialWrite::execute()
|
||||
{
|
||||
//Pout<< "execute at time " << obr_.time().timeName()
|
||||
// << " index:" << obr_.time().timeIndex() << endl;
|
||||
}
|
||||
|
||||
|
||||
@ -104,99 +124,61 @@ void Foam::partialWrite::end()
|
||||
}
|
||||
|
||||
|
||||
void Foam::partialWrite::write()
|
||||
void Foam::partialWrite::timeSet()
|
||||
{
|
||||
//Pout<< "write at time " << obr_.time().timeName() << endl;
|
||||
if (obr_.time().outputTime())
|
||||
{
|
||||
// Above check so it can be used both with
|
||||
// outputControl timeStep;
|
||||
// outputInterval 1;
|
||||
// or with
|
||||
// outputControl outputTime;
|
||||
|
||||
writeInstance_++;
|
||||
|
||||
if (writeInstance_ == writeInterval_)
|
||||
{
|
||||
// Normal dump
|
||||
// Next overall dump corresponf 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
|
||||
{
|
||||
// Delete all but marked objects
|
||||
fileName dbDir;
|
||||
if (isA<polyMesh>(obr_))
|
||||
{
|
||||
dbDir = dynamic_cast<const polyMesh&>(obr_).dbDir();
|
||||
}
|
||||
|
||||
IOobjectList objects(obr_, obr_.time().timeName());
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Pout<< "For region:" << obr_.name() << endl;
|
||||
}
|
||||
|
||||
forAllConstIter(IOobjectList, objects, iter)
|
||||
{
|
||||
if (!objectNames_.found(iter()->name()))
|
||||
{
|
||||
const fileName f =
|
||||
obr_.time().timePath()
|
||||
/dbDir
|
||||
/iter()->name();
|
||||
if (debug)
|
||||
{
|
||||
Pout<< " rm " << f << endl;
|
||||
}
|
||||
rm(f);
|
||||
}
|
||||
}
|
||||
|
||||
// Do the lagrangian files as well.
|
||||
fileNameList cloudDirs
|
||||
changeWriteOptions<scalar>(vsf_, ssf_, IOobject::NO_WRITE);
|
||||
changeWriteOptions<vector>(vvf_, svf_, IOobject::NO_WRITE);
|
||||
changeWriteOptions<sphericalTensor>
|
||||
(
|
||||
readDir
|
||||
(
|
||||
obr_.time().timePath()/dbDir/cloud::prefix,
|
||||
fileName::DIRECTORY
|
||||
)
|
||||
vSpheretf_,
|
||||
sSpheretf_,
|
||||
IOobject::NO_WRITE
|
||||
);
|
||||
forAll(cloudDirs, i)
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
Pout<< "For cloud:" << cloudDirs[i] << endl;
|
||||
}
|
||||
|
||||
IOobjectList sprayObjs
|
||||
(
|
||||
obr_,
|
||||
obr_.time().timeName(),
|
||||
cloud::prefix/cloudDirs[i]
|
||||
);
|
||||
forAllConstIter(IOobjectList, sprayObjs, iter)
|
||||
{
|
||||
if (!objectNames_.found(iter()->name()))
|
||||
{
|
||||
const fileName f =
|
||||
obr_.time().timePath()
|
||||
/dbDir
|
||||
/cloud::prefix
|
||||
/cloudDirs[i]
|
||||
/iter()->name();
|
||||
if (debug)
|
||||
{
|
||||
Pout<< " rm " << f << endl;
|
||||
}
|
||||
rm(f);
|
||||
}
|
||||
}
|
||||
}
|
||||
changeWriteOptions<symmTensor>
|
||||
(
|
||||
vSymmtf_,
|
||||
sSymmtf_,
|
||||
IOobject::NO_WRITE
|
||||
);
|
||||
changeWriteOptions<tensor>(vtf_, stf_, IOobject::NO_WRITE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::partialWrite::write()
|
||||
{
|
||||
// Do nothing. The fields get written through the
|
||||
// standard dump
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -29,8 +29,8 @@ Group
|
||||
|
||||
Description
|
||||
This function object allows user-selected fields/registered objects to be
|
||||
written at a custom write interval. It operates by deleting all entries
|
||||
except those selected after writing.
|
||||
written at a custom write interval. The interval is given in terms of
|
||||
number of overall dumps
|
||||
|
||||
Example of function object specification:
|
||||
\verbatim
|
||||
@ -66,8 +66,9 @@ SourceFiles
|
||||
#define partialWrite_H
|
||||
|
||||
#include "HashSet.H"
|
||||
#include "DynamicList.H"
|
||||
#include "runTimeSelectionTables.H"
|
||||
#include "volFields.H"
|
||||
#include "surfaceFields.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -95,6 +96,18 @@ protected:
|
||||
|
||||
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
|
||||
|
||||
@ -105,6 +118,7 @@ protected:
|
||||
label writeInterval_;
|
||||
|
||||
|
||||
|
||||
//- Current dump instance. If reaches writeInterval do a full write.
|
||||
label writeInstance_;
|
||||
|
||||
@ -118,6 +132,24 @@ protected:
|
||||
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
|
||||
@ -152,12 +184,15 @@ public:
|
||||
//- Read the partialWrite data
|
||||
virtual void read(const dictionary&);
|
||||
|
||||
//- Execute, currently does nothing
|
||||
//- Execute
|
||||
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();
|
||||
|
||||
//- Write the partialWrite
|
||||
virtual void write();
|
||||
|
||||
@ -177,6 +212,12 @@ public:
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
# include "partialWriteTemplates.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2013 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -92,6 +92,12 @@ void Foam::removeRegisteredObject::end()
|
||||
}
|
||||
|
||||
|
||||
void Foam::removeRegisteredObject::timeSet()
|
||||
{
|
||||
// Do nothing - only valid on execute
|
||||
}
|
||||
|
||||
|
||||
void Foam::removeRegisteredObject::write()
|
||||
{
|
||||
// Do nothing - only valid on execute
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2013 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -146,6 +146,9 @@ public:
|
||||
//- 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 the removeRegisteredObject
|
||||
virtual void write();
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2013 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -199,6 +199,12 @@ void Foam::writeDictionary::end()
|
||||
}
|
||||
|
||||
|
||||
void Foam::writeDictionary::timeSet()
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
||||
|
||||
void Foam::writeDictionary::write()
|
||||
{
|
||||
// do nothing
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2013 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -134,6 +134,9 @@ public:
|
||||
//- 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 the writeDictionary
|
||||
virtual void write();
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -79,6 +79,12 @@ void Foam::writeRegisteredObject::end()
|
||||
}
|
||||
|
||||
|
||||
void Foam::writeRegisteredObject::timeSet()
|
||||
{
|
||||
// Do nothing - only valid on write
|
||||
}
|
||||
|
||||
|
||||
void Foam::writeRegisteredObject::write()
|
||||
{
|
||||
forAll(objectNames_, i)
|
||||
|
||||
@ -147,6 +147,9 @@ public:
|
||||
//- 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 the writeRegisteredObject
|
||||
virtual void write();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user