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:
Sergio Ferraris
2013-06-07 10:11:07 +01:00
parent 2e1ccf40b7
commit a50d78ea93
83 changed files with 547 additions and 152 deletions

View File

@ -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
}
// ************************************************************************* //