From: Matthias Maier Date: Mon, 21 Apr 2025 18:03:26 +0000 (-0500) Subject: SolverMPGMRES: refactor parameter into function argument X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6e730b860cd4ea857e078b0fe8e6a8fb0485fc7a;p=dealii.git SolverMPGMRES: refactor parameter into function argument --- diff --git a/include/deal.II/lac/solver_gmres.h b/include/deal.II/lac/solver_gmres.h index d7765c650c..0d8b36beb2 100644 --- a/include/deal.II/lac/solver_gmres.h +++ b/include/deal.II/lac/solver_gmres.h @@ -773,20 +773,15 @@ protected: full_mpgmres, }; - /** - * The indexing strategy chosen for MPGMRES. This internal variable gets - * set by the constructor of SolverFGMRES and SolverMPGMRES. - */ - IndexingStrategy indexing_strategy; - /** * Solve the linear system $Ax=b$ for x. */ template void - solve_internal(const MatrixType &A, - VectorType &x, - const VectorType &b, + solve_internal(const MatrixType &A, + VectorType &x, + const VectorType &b, + const IndexingStrategy &indexing_strategy, const PreconditionerTypes &...preconditioners); private: @@ -2138,10 +2133,6 @@ SolverMPGMRES::SolverMPGMRES(SolverControl &cn, : SolverBase(cn, mem) , additional_data(data) { - if (data.use_truncated_mpgmres_strategy) - indexing_strategy = IndexingStrategy::truncated_mpgmres; - else - indexing_strategy = IndexingStrategy::full_mpgmres; } @@ -2153,10 +2144,6 @@ SolverMPGMRES::SolverMPGMRES(SolverControl &cn, : SolverBase(cn) , additional_data(data) { - if (data.use_truncated_mpgmres_strategy) - indexing_strategy = IndexingStrategy::truncated_mpgmres; - else - indexing_strategy = IndexingStrategy::full_mpgmres; } @@ -2174,7 +2161,13 @@ void SolverMPGMRES::solve( const PreconditionerTypes &...preconditioners) { LogStream::Prefix prefix("MPGMRES"); - SolverMPGMRES::solve_internal(A, x, b, preconditioners...); + + if (additional_data.use_truncated_mpgmres_strategy) + SolverMPGMRES::solve_internal( + A, x, b, IndexingStrategy::truncated_mpgmres, preconditioners...); + else + SolverMPGMRES::solve_internal( + A, x, b, IndexingStrategy::full_mpgmres, preconditioners...); } @@ -2183,9 +2176,10 @@ template DEAL_II_CXX20_REQUIRES(concepts::is_vector_space_vector) template void SolverMPGMRES::solve_internal( - const MatrixType &A, - VectorType &x, - const VectorType &b, + const MatrixType &A, + VectorType &x, + const VectorType &b, + const IndexingStrategy &indexing_strategy, const PreconditionerTypes &...preconditioners) { constexpr std::size_t n_preconditioners = sizeof...(PreconditionerTypes); @@ -2231,7 +2225,8 @@ void SolverMPGMRES::solve_internal( // Krylov space sequence according to the chosen indexing strategy // const auto previous_vector_index = - [this, n_preconditioners](unsigned int i) -> unsigned int { + [this, n_preconditioners, indexing_strategy]( + unsigned int i) -> unsigned int { switch (indexing_strategy) { case IndexingStrategy::fgmres: @@ -2351,7 +2346,6 @@ SolverFGMRES::SolverFGMRES(SolverControl &cn, true, data.orthogonalization_strategy}) { - this->indexing_strategy = SolverMPGMRES::IndexingStrategy::fgmres; } @@ -2367,7 +2361,6 @@ SolverFGMRES::SolverFGMRES(SolverControl &cn, true, data.orthogonalization_strategy}) { - this->indexing_strategy = SolverMPGMRES::IndexingStrategy::fgmres; } @@ -2385,7 +2378,8 @@ void SolverFGMRES::solve( const PreconditionerTypes &...preconditioners) { LogStream::Prefix prefix("FGMRES"); - SolverMPGMRES::solve_internal(A, x, b, preconditioners...); + SolverMPGMRES::solve_internal( + A, x, b, SolverFGMRES::IndexingStrategy::fgmres, preconditioners...); }