ENH: retain a list of solverPerformance in data

- reset when the iteration changes
This commit is contained in:
Mark Olesen
2010-06-02 15:36:49 +02:00
parent 7b941b790f
commit db8b5e6b8a
2 changed files with 28 additions and 3 deletions

View File

@ -45,7 +45,8 @@ Foam::data::data(const objectRegistry& obr)
IOobject::NO_READ, IOobject::NO_READ,
IOobject::NO_WRITE IOobject::NO_WRITE
) )
) ),
prevTimeIndex_(0)
{ {
set("solverPerformance", dictionary()); set("solverPerformance", dictionary());
} }
@ -65,7 +66,25 @@ void Foam::data::setSolverPerformance
const lduMatrix::solverPerformance& sp const lduMatrix::solverPerformance& sp
) const ) const
{ {
const_cast<dictionary&>(solverPerformanceDict()).set(name, sp); dictionary& dict = const_cast<dictionary&>(solverPerformanceDict());
List<lduMatrix::solverPerformance> perfs;
if (prevTimeIndex_ != this->time().timeIndex())
{
// reset solver performance between iterations
prevTimeIndex_ = this->time().timeIndex();
dict.clear();
}
else
{
dict.readIfPresent(name, perfs);
}
// append to list
perfs.setSize(perfs.size()+1, sp);
dict.set(name, perfs);
} }

View File

@ -54,6 +54,12 @@ class data
: :
public IOdictionary public IOdictionary
{ {
// Private data
//- Previously used time-index, used for reset between iterations
mutable label prevTimeIndex_;
// Private Member Functions // Private Member Functions
//- Disallow default bitwise copy construct //- Disallow default bitwise copy construct