diff --git a/src/OpenFOAM/matrices/lduMatrix/lduMatrix/lduMatrix.H b/src/OpenFOAM/matrices/lduMatrix/lduMatrix/lduMatrix.H index b96925a91b..860a593b83 100644 --- a/src/OpenFOAM/matrices/lduMatrix/lduMatrix/lduMatrix.H +++ b/src/OpenFOAM/matrices/lduMatrix/lduMatrix/lduMatrix.H @@ -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&); diff --git a/src/OpenFOAM/matrices/lduMatrix/lduMatrix/lduMatrixTests.C b/src/OpenFOAM/matrices/lduMatrix/lduMatrix/lduMatrixTests.C index c1fafc95ec..c4c8774098 100644 --- a/src/OpenFOAM/matrices/lduMatrix/lduMatrix/lduMatrixTests.C +++ b/src/OpenFOAM/matrices/lduMatrix/lduMatrix/lduMatrixTests.C @@ -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; } + // ************************************************************************* // diff --git a/src/finiteVolume/fvMatrices/fvMatrix/fvMatrixSolve.C b/src/finiteVolume/fvMatrices/fvMatrix/fvMatrixSolve.C index aa3fe8dd3f..e1984ef878 100644 --- a/src/finiteVolume/fvMatrices/fvMatrix/fvMatrixSolve.C +++ b/src/finiteVolume/fvMatrices/fvMatrix/fvMatrixSolve.C @@ -149,14 +149,7 @@ Foam::lduMatrix::solverPerformance Foam::fvMatrix::solve solverPerf.print(); - if - ( - solverPerf.initialResidual() > solverPerfVec.initialResidual() - && !solverPerf.singular() - ) - { - solverPerfVec = solverPerf; - } + solverPerfVec = max(solverPerfVec, solverPerf); psi.internalField().replace(cmpt, psiCmpt); diag() = saveDiag;