]> https://gitweb.dealii.org/ - dealii.git/commitdiff
SolverFGMRES: also allow multiple preconditioners because why not...
authorMatthias Maier <tamiko@43-1.org>
Fri, 28 Mar 2025 21:05:39 +0000 (16:05 -0500)
committerMatthias Maier <tamiko@43-1.org>
Mon, 5 May 2025 21:10:57 +0000 (16:10 -0500)
include/deal.II/lac/solver_gmres.h

index 42b85b5833fad29b0a1e2b8417e696a408614a7c..d7765c650c8794fb1721b732724cb4084e13c843 100644 (file)
@@ -878,19 +878,15 @@ public:
 
   /**
    * Solve the linear system $Ax=b$ for x.
-   *
-   * @note If you want to use more than one preconditioner, then you will
-   * need to supply a @p preconditioner object that switches
-   * preconditioners for each vmult() invocation.
    */
-  template <typename MatrixType, typename PreconditionerType>
+  template <typename MatrixType, typename... PreconditionerTypes>
   DEAL_II_CXX20_REQUIRES(
     (concepts::is_linear_operator_on<MatrixType, VectorType> &&
-     concepts::is_linear_operator_on<PreconditionerType, VectorType>))
-  void solve(const MatrixType         &A,
-             VectorType               &x,
-             const VectorType         &b,
-             const PreconditionerType &preconditioner);
+     (concepts::is_linear_operator_on<PreconditionerTypes, VectorType> && ...)))
+  void solve(const MatrixType &A,
+             VectorType       &x,
+             const VectorType &b,
+             const PreconditionerTypes &...preconditioners);
 };
 
 /** @} */
@@ -2378,17 +2374,18 @@ SolverFGMRES<VectorType>::SolverFGMRES(SolverControl        &cn,
 
 template <typename VectorType>
 DEAL_II_CXX20_REQUIRES(concepts::is_vector_space_vector<VectorType>)
-template <typename MatrixType, typename PreconditionerType>
+template <typename MatrixType, typename... PreconditionerTypes>
 DEAL_II_CXX20_REQUIRES(
   (concepts::is_linear_operator_on<MatrixType, VectorType> &&
-   concepts::is_linear_operator_on<PreconditionerType, VectorType>))
-void SolverFGMRES<VectorType>::solve(const MatrixType         &A,
-                                     VectorType               &x,
-                                     const VectorType         &b,
-                                     const PreconditionerType &preconditioner)
+   (concepts::is_linear_operator_on<PreconditionerTypes, VectorType> && ...)))
+void SolverFGMRES<VectorType>::solve(
+  const MatrixType &A,
+  VectorType       &x,
+  const VectorType &b,
+  const PreconditionerTypes &...preconditioners)
 {
   LogStream::Prefix prefix("FGMRES");
-  SolverMPGMRES<VectorType>::solve_internal(A, x, b, preconditioner);
+  SolverMPGMRES<VectorType>::solve_internal(A, x, b, preconditioners...);
 }
 
 

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.