From dc4b24981d275576081e76ab8af1762c7a54567a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Klinkovsk=C3=BD?= <klinkjak@fjfi.cvut.cz> Date: Thu, 20 Sep 2018 13:33:23 +0200 Subject: [PATCH] Refactoring preconditioners - the solve method can return just void --- src/TNL/Solvers/Linear/Preconditioners/ILU0.h | 6 +++--- src/TNL/Solvers/Linear/Preconditioners/ILU0_impl.h | 8 ++------ src/TNL/Solvers/Linear/Preconditioners/ILUT.h | 6 +++--- src/TNL/Solvers/Linear/Preconditioners/ILUT_impl.h | 4 +--- src/TNL/Solvers/Linear/Preconditioners/Preconditioner.h | 3 +-- 5 files changed, 10 insertions(+), 17 deletions(-) diff --git a/src/TNL/Solvers/Linear/Preconditioners/ILU0.h b/src/TNL/Solvers/Linear/Preconditioners/ILU0.h index b94d790526..868cb81b3f 100644 --- a/src/TNL/Solvers/Linear/Preconditioners/ILU0.h +++ b/src/TNL/Solvers/Linear/Preconditioners/ILU0.h @@ -59,7 +59,7 @@ public: virtual void update( const MatrixPointer& matrixPointer ) override; - virtual bool solve( ConstVectorViewType b, VectorViewType x ) const override; + virtual void solve( ConstVectorViewType b, VectorViewType x ) const override; protected: Matrices::CSR< RealType, DeviceType, IndexType > L; @@ -87,7 +87,7 @@ public: virtual void update( const MatrixPointer& matrixPointer ) override; - virtual bool solve( ConstVectorViewType b, VectorViewType x ) const override; + virtual void solve( ConstVectorViewType b, VectorViewType x ) const override; ~ILU0_impl() { @@ -188,7 +188,7 @@ public: throw std::runtime_error("Not Iplemented yet for MIC"); } - virtual bool solve( ConstVectorViewType b, VectorViewType x ) const override + virtual void solve( ConstVectorViewType b, VectorViewType x ) const override { throw std::runtime_error("Not Iplemented yet for MIC"); } diff --git a/src/TNL/Solvers/Linear/Preconditioners/ILU0_impl.h b/src/TNL/Solvers/Linear/Preconditioners/ILU0_impl.h index 2b2244df36..8d220b8b0d 100644 --- a/src/TNL/Solvers/Linear/Preconditioners/ILU0_impl.h +++ b/src/TNL/Solvers/Linear/Preconditioners/ILU0_impl.h @@ -103,7 +103,7 @@ update( const MatrixPointer& matrixPointer ) } template< typename Matrix, typename Real, typename Index > -bool +void ILU0_impl< Matrix, Real, Devices::Host, Index >:: solve( ConstVectorViewType b, VectorViewType x ) const { @@ -147,8 +147,6 @@ solve( ConstVectorViewType b, VectorViewType x ) const x[ i ] /= U_ii; } - - return true; } @@ -262,7 +260,7 @@ update( const MatrixPointer& matrixPointer ) } template< typename Matrix > -bool +void ILU0_impl< Matrix, double, Devices::Cuda, int >:: solve( ConstVectorViewType b, VectorViewType x ) const { @@ -290,8 +288,6 @@ solve( ConstVectorViewType b, VectorViewType x ) const y.getData(), x.getData(), policy_U, (void*) pBuffer.getData() ); - - return true; #else throw std::runtime_error("The program was not compiled with the CUSPARSE library. Pass -DHAVE_CUSPARSE -lcusparse to the compiler."); #endif diff --git a/src/TNL/Solvers/Linear/Preconditioners/ILUT.h b/src/TNL/Solvers/Linear/Preconditioners/ILUT.h index f9147c7b88..3fbb1ee11c 100644 --- a/src/TNL/Solvers/Linear/Preconditioners/ILUT.h +++ b/src/TNL/Solvers/Linear/Preconditioners/ILUT.h @@ -64,7 +64,7 @@ public: virtual void update( const MatrixPointer& matrixPointer ) override; - virtual bool solve( ConstVectorViewType b, VectorViewType x ) const override; + virtual void solve( ConstVectorViewType b, VectorViewType x ) const override; protected: Index p = 0; @@ -92,7 +92,7 @@ public: throw std::runtime_error("Not Iplemented yet for CUDA"); } - virtual bool solve( ConstVectorViewType b, VectorViewType x ) const override + virtual void solve( ConstVectorViewType b, VectorViewType x ) const override { throw std::runtime_error("Not Iplemented yet for CUDA"); } @@ -115,7 +115,7 @@ public: throw std::runtime_error("Not Iplemented yet for MIC"); } - virtual bool solve( ConstVectorViewType b, VectorViewType x ) const override + virtual void solve( ConstVectorViewType b, VectorViewType x ) const override { throw std::runtime_error("Not Iplemented yet for MIC"); } diff --git a/src/TNL/Solvers/Linear/Preconditioners/ILUT_impl.h b/src/TNL/Solvers/Linear/Preconditioners/ILUT_impl.h index bb08ffb144..4a7a724a5b 100644 --- a/src/TNL/Solvers/Linear/Preconditioners/ILUT_impl.h +++ b/src/TNL/Solvers/Linear/Preconditioners/ILUT_impl.h @@ -241,7 +241,7 @@ update( const MatrixPointer& matrixPointer ) } template< typename Matrix, typename Real, typename Index > -bool +void ILUT_impl< Matrix, Real, Devices::Host, Index >:: solve( ConstVectorViewType b, VectorViewType x ) const { @@ -289,8 +289,6 @@ solve( ConstVectorViewType b, VectorViewType x ) const x[ i ] /= U_ii; } - - return true; } } // namespace Preconditioners diff --git a/src/TNL/Solvers/Linear/Preconditioners/Preconditioner.h b/src/TNL/Solvers/Linear/Preconditioners/Preconditioner.h index cda81802da..70c5d7cf84 100644 --- a/src/TNL/Solvers/Linear/Preconditioners/Preconditioner.h +++ b/src/TNL/Solvers/Linear/Preconditioners/Preconditioner.h @@ -46,10 +46,9 @@ public: virtual void update( const MatrixPointer& matrixPointer ) {} - virtual bool solve( ConstVectorViewType b, VectorViewType x ) const + virtual void solve( ConstVectorViewType b, VectorViewType x ) const { TNL_ASSERT_TRUE( false, "The solve() method of a dummy preconditioner should not be called." ); - return true; } String getType() const -- GitLab