mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: avoid the build-up of the background solver dictionary
The solverPerformanceDict gets larger due to the addition of a SolverPerformance data per field at every outer iteration within the same main iteration/time step. However, the subsequent functionalities seem to use only the first and last element of this dictionary per field; therefore, storing the interim values was revealed to be redundant. The change removes the interim values by transforming the `List` container into the `Pair` container, and modifying the relevant algorithms.
This commit is contained in:
@ -39,12 +39,14 @@ void Foam::meshState::setSolverPerformance
|
||||
{
|
||||
dictionary& dict = const_cast<dictionary&>(solverPerformanceDict());
|
||||
|
||||
List<SolverPerformance<Type>> perfs;
|
||||
Pair<SolverPerformance<Type>> perfs;
|
||||
|
||||
if (prevTimeIndex_ != this->time().timeIndex())
|
||||
const label timeIndex = this->time().timeIndex();
|
||||
|
||||
if (prevTimeIndex_ != timeIndex)
|
||||
{
|
||||
// Reset solver performance between iterations
|
||||
prevTimeIndex_ = this->time().timeIndex();
|
||||
prevTimeIndex_ = timeIndex;
|
||||
dict.clear();
|
||||
}
|
||||
else
|
||||
@ -52,7 +54,14 @@ void Foam::meshState::setSolverPerformance
|
||||
dict.readIfPresent(name, perfs);
|
||||
}
|
||||
|
||||
perfs.push_back(sp);
|
||||
if (dict.found(name))
|
||||
{
|
||||
perfs.second() = sp;
|
||||
}
|
||||
else
|
||||
{
|
||||
perfs = Pair<SolverPerformance<Type>>(sp, sp);
|
||||
}
|
||||
|
||||
dict.set(name, perfs);
|
||||
}
|
||||
|
||||
@ -227,7 +227,7 @@ bool Foam::solutionControl::maxTypeResidual
|
||||
|
||||
if (fvmesh.foundObject<fieldType>(fieldName))
|
||||
{
|
||||
const List<SolverPerformance<Type>> sp(solverPerfDictEntry.stream());
|
||||
const Pair<SolverPerformance<Type>> sp(solverPerfDictEntry.stream());
|
||||
|
||||
residuals.first() = cmptMax(sp.first().initialResidual());
|
||||
residuals.last() = cmptMax(sp.last().initialResidual());
|
||||
|
||||
@ -43,7 +43,7 @@ equationInitialResidualCondition::setResidual
|
||||
|
||||
if (canSet && mesh.foundObject<volFieldType>(fieldName))
|
||||
{
|
||||
const List<SolverPerformance<Type>> sp(dict.lookup(fieldName));
|
||||
const Pair<SolverPerformance<Type>> sp(dict.lookup(fieldName));
|
||||
const Type& allComponents = sp.first().initialResidual();
|
||||
|
||||
if (componenti != -1)
|
||||
|
||||
@ -107,7 +107,7 @@ bool Foam::functionObjects::runTimeControls::equationMaxIterCondition::apply()
|
||||
|
||||
if (solverDict.found(fieldName))
|
||||
{
|
||||
const List<solverPerformance> sp(solverDict.lookup(fieldName));
|
||||
const Pair<solverPerformance> sp(solverDict.lookup(fieldName));
|
||||
const label nIterations = sp.first().nIterations();
|
||||
result[fieldi] = nIterations;
|
||||
|
||||
|
||||
@ -119,7 +119,7 @@ void Foam::functionObjects::solverInfo::updateSolverInfo(const word& fieldName)
|
||||
|
||||
if (solverDict.found(fieldName))
|
||||
{
|
||||
const List<SolverPerformance<Type>> sp
|
||||
const Pair<SolverPerformance<Type>> sp
|
||||
(
|
||||
solverDict.lookup(fieldName)
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user