Commit 99fa564b authored by henry's avatar henry
Browse files

solverPerformance: added a "max" function

Improves the handling of residuals from the segregated solution of vectors and tensors.
parent 6a63046e
......@@ -210,6 +210,16 @@ public:
void print() const;
// Friend functions
//- Return the element-wise maximum of two solverPerformances
friend solverPerformance max
(
const solverPerformance&,
const solverPerformance&
);
// Ostream Operator
friend Ostream& operator<<(Ostream&, const solverPerformance&);
......
......@@ -118,6 +118,25 @@ void Foam::lduMatrix::solverPerformance::print() const
}
Foam::lduMatrix::solverPerformance::solverPerformance Foam::max
(
const lduMatrix::solverPerformance& sp1,
const lduMatrix::solverPerformance& sp2
)
{
return lduMatrix::solverPerformance
(
sp1.solverName(),
sp1.fieldName_,
max(sp1.initialResidual(), sp2.initialResidual()),
max(sp1.finalResidual(), sp2.finalResidual()),
max(sp1.nIterations(), sp2.nIterations()),
sp1.converged() && sp2.converged(),
sp1.singular() || sp2.singular()
);
}
Foam::Ostream& Foam::operator<<
(
Ostream& os,
......@@ -137,4 +156,5 @@ Foam::Ostream& Foam::operator<<
return os;
}
// ************************************************************************* //
......@@ -149,14 +149,7 @@ Foam::lduMatrix::solverPerformance Foam::fvMatrix<Type>::solve
solverPerf.print();
if
(
solverPerf.initialResidual() > solverPerfVec.initialResidual()
&& !solverPerf.singular()
)
{
solverPerfVec = solverPerf;
}
solverPerfVec = max(solverPerfVec, solverPerf);
psi.internalField().replace(cmpt, psiCmpt);
diag() = saveDiag;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment