New feature: Added switch which enables storing only first and last iteration residuals in solvePerformance
This commit is contained in:
parent
e3115846f5
commit
f58e0ebf49
3 changed files with 29 additions and 3 deletions
|
@ -127,6 +127,15 @@ void Foam::solution::read(const dictionary& dict)
|
|||
{
|
||||
solverPerformance_ = dict.subDict("solverPerformance");
|
||||
}
|
||||
|
||||
if (dict.found("residuals"))
|
||||
{
|
||||
storeAllResiduals_ =
|
||||
dict.subDict("residuals").lookupOrDefault
|
||||
(
|
||||
"storeAllResiduals", false
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -153,7 +162,8 @@ Foam::solution::solution(const objectRegistry& obr, const fileName& dictName)
|
|||
eqnRelaxDefault_(0),
|
||||
solvers_(dictionary::null),
|
||||
solverPerformance_(dictionary::null),
|
||||
prevTimeIndex_(0)
|
||||
prevTimeIndex_(0),
|
||||
storeAllResiduals_(false)
|
||||
{
|
||||
if (!headerOk())
|
||||
{
|
||||
|
|
|
@ -82,6 +82,10 @@ class solution
|
|||
//- Previously used time-index, used for reset between iterations
|
||||
mutable label prevTimeIndex_;
|
||||
|
||||
//- Switch for storing residuals of every iteration inside a single
|
||||
// timestep
|
||||
bool storeAllResiduals_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
|
|
|
@ -65,8 +65,20 @@ void Foam::solution::setSolverPerformance
|
|||
solverPerformance_.readIfPresent(name, perfs);
|
||||
}
|
||||
|
||||
// Append to list
|
||||
perfs.setSize(perfs.size() + 1, sp);
|
||||
// If storeAllResiduals_ is true, we are storing residual of every iteration
|
||||
// inside a single time step. Otherwise, only the first iteration residual
|
||||
// and the current iteration residual are required, so the current
|
||||
// iteration residual replaces the previous one and only the first iteration
|
||||
// residual is always present, VS 2018-02-11
|
||||
if (storeAllResiudals_ || perfs.size() < 2)
|
||||
{
|
||||
// Append to list
|
||||
perfs.setSize(perfs.size() + 1, sp);
|
||||
}
|
||||
else
|
||||
{
|
||||
perfs.last() = sp;
|
||||
}
|
||||
|
||||
solverPerformance_.set(name, perfs);
|
||||
}
|
||||
|
|
Reference in a new issue