From 7b941b790ff1aeb08d7110d10a02e54a7080d435 Mon Sep 17 00:00:00 2001 From: Mark Olesen <Mark.Olesen@Germany> Date: Wed, 2 Jun 2010 14:35:03 +0200 Subject: [PATCH] ENH: add operator>> and operator!= to lduMatrix::solverPerformance - needed for reading a List<lduMatrix::solverPerformance> --- .../matrices/lduMatrix/lduMatrix/lduMatrix.H | 5 ++ .../lduMatrix/lduMatrix/lduMatrixTests.C | 48 +++++++++++++++---- 2 files changed, 44 insertions(+), 9 deletions(-) diff --git a/src/OpenFOAM/matrices/lduMatrix/lduMatrix/lduMatrix.H b/src/OpenFOAM/matrices/lduMatrix/lduMatrix/lduMatrix.H index 53708f58e27..9f3ef88a9ae 100644 --- a/src/OpenFOAM/matrices/lduMatrix/lduMatrix/lduMatrix.H +++ b/src/OpenFOAM/matrices/lduMatrix/lduMatrix/lduMatrix.H @@ -223,6 +223,10 @@ public: //- Print summary of solver performance void print() const; + // Member Operators + + bool operator!=(const solverPerformance&) const; + // Friend functions @@ -236,6 +240,7 @@ public: // Ostream Operator + friend Istream& operator>>(Istream&, solverPerformance&); 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 6ec7861bc81..09d8258ba58 100644 --- a/src/OpenFOAM/matrices/lduMatrix/lduMatrix/lduMatrixTests.C +++ b/src/OpenFOAM/matrices/lduMatrix/lduMatrix/lduMatrixTests.C @@ -32,15 +32,7 @@ Description Foam::lduMatrix::solverPerformance::solverPerformance(Istream& is) { - is.readBeginList("lduMatrix::solverPerformance"); - is >> solverName_ - >> fieldName_ - >> initialResidual_ - >> finalResidual_ - >> noIterations_ - >> converged_ - >> singular_; - is.readEndList("lduMatrix::solverPerformance"); + is >> *this; } @@ -118,6 +110,24 @@ void Foam::lduMatrix::solverPerformance::print() const } +bool Foam::lduMatrix::solverPerformance::operator!= +( + const lduMatrix::solverPerformance& sp +) const +{ + return + ( + solverName() != sp.solverName() + || fieldName() != sp.fieldName() + || initialResidual() != sp.initialResidual() + || finalResidual() != sp.finalResidual() + || nIterations() != sp.nIterations() + || converged() != sp.converged() + || singular() != sp.singular() + ); +} + + Foam::lduMatrix::solverPerformance Foam::max ( const lduMatrix::solverPerformance& sp1, @@ -137,6 +147,26 @@ Foam::lduMatrix::solverPerformance Foam::max } +Foam::Istream& Foam::operator>> +( + Istream& is, + Foam::lduMatrix::solverPerformance& sp +) +{ + is.readBeginList("lduMatrix::solverPerformance"); + is >> sp.solverName_ + >> sp.fieldName_ + >> sp.initialResidual_ + >> sp.finalResidual_ + >> sp.noIterations_ + >> sp.converged_ + >> sp.singular_; + is.readEndList("lduMatrix::solverPerformance"); + + return is; +} + + Foam::Ostream& Foam::operator<< ( Ostream& os, -- GitLab