From: Wolfgang Bangerth Date: Fri, 10 May 2024 09:30:04 +0000 (+0530) Subject: Annotate MatrixType with linear operator concepts. X-Git-Tag: v9.6.0-rc1~271^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1e7cbd004d7d1383707c1c8015a5bc46e78cd4d9;p=dealii.git Annotate MatrixType with linear operator concepts. --- diff --git a/include/deal.II/lac/solver_bicgstab.h b/include/deal.II/lac/solver_bicgstab.h index 79b3d67974..2695c61f31 100644 --- a/include/deal.II/lac/solver_bicgstab.h +++ b/include/deal.II/lac/solver_bicgstab.h @@ -139,11 +139,13 @@ public: * Solve primal problem only. */ template - void - solve(const MatrixType &A, - VectorType &x, - const VectorType &b, - const PreconditionerType &preconditioner); + DEAL_II_CXX20_REQUIRES( + (concepts::is_linear_operator_on && + concepts::is_linear_operator_on)) + void solve(const MatrixType &A, + VectorType &x, + const VectorType &b, + const PreconditionerType &preconditioner); protected: /** @@ -405,6 +407,9 @@ typename SolverBicgstab::IterationResult template DEAL_II_CXX20_REQUIRES(concepts::is_vector_space_vector) template +DEAL_II_CXX20_REQUIRES( + (concepts::is_linear_operator_on && + concepts::is_linear_operator_on)) void SolverBicgstab::solve(const MatrixType &A, VectorType &x, const VectorType &b, diff --git a/include/deal.II/lac/solver_cg.h b/include/deal.II/lac/solver_cg.h index 498df053c4..dca6a25b68 100644 --- a/include/deal.II/lac/solver_cg.h +++ b/include/deal.II/lac/solver_cg.h @@ -213,11 +213,13 @@ public: * Solve the linear system $Ax=b$ for x. */ template - void - solve(const MatrixType &A, - VectorType &x, - const VectorType &b, - const PreconditionerType &preconditioner); + DEAL_II_CXX20_REQUIRES( + (concepts::is_linear_operator_on && + concepts::is_linear_operator_on)) + void solve(const MatrixType &A, + VectorType &x, + const VectorType &b, + const PreconditionerType &preconditioner); /** * Connect a slot to retrieve the CG coefficients. The slot will be called @@ -1265,6 +1267,9 @@ namespace internal template DEAL_II_CXX20_REQUIRES(concepts::is_vector_space_vector) template +DEAL_II_CXX20_REQUIRES( + (concepts::is_linear_operator_on && + concepts::is_linear_operator_on)) void SolverCG::solve(const MatrixType &A, VectorType &x, const VectorType &b, diff --git a/include/deal.II/lac/solver_fire.h b/include/deal.II/lac/solver_fire.h index 4efed16e85..279905ae9d 100644 --- a/include/deal.II/lac/solver_fire.h +++ b/include/deal.II/lac/solver_fire.h @@ -157,11 +157,13 @@ public: * = \frac{1}{2} \mathbf x^{T} \mathbf A \mathbf x - \mathbf x^{T} \mathbf b$. */ template - void - solve(const MatrixType &A, - VectorType &x, - const VectorType &b, - const PreconditionerType &preconditioner); + DEAL_II_CXX20_REQUIRES( + (concepts::is_linear_operator_on && + concepts::is_linear_operator_on)) + void solve(const MatrixType &A, + VectorType &x, + const VectorType &b, + const PreconditionerType &preconditioner); protected: /** @@ -353,6 +355,9 @@ void SolverFIRE::solve( template DEAL_II_CXX20_REQUIRES(concepts::is_vector_space_vector) template +DEAL_II_CXX20_REQUIRES( + (concepts::is_linear_operator_on && + concepts::is_linear_operator_on)) void SolverFIRE::solve(const MatrixType &A, VectorType &x, const VectorType &b, diff --git a/include/deal.II/lac/solver_gmres.h b/include/deal.II/lac/solver_gmres.h index 71466995b1..82f306f404 100644 --- a/include/deal.II/lac/solver_gmres.h +++ b/include/deal.II/lac/solver_gmres.h @@ -457,11 +457,13 @@ public: * Solve the linear system $Ax=b$ for x. */ template - void - solve(const MatrixType &A, - VectorType &x, - const VectorType &b, - const PreconditionerType &preconditioner); + DEAL_II_CXX20_REQUIRES( + (concepts::is_linear_operator_on && + concepts::is_linear_operator_on)) + void solve(const MatrixType &A, + VectorType &x, + const VectorType &b, + const PreconditionerType &preconditioner); /** * Connect a slot to retrieve the estimated condition number. Called on each @@ -691,11 +693,13 @@ public: * Solve the linear system $Ax=b$ for x. */ template - void - solve(const MatrixType &A, - VectorType &x, - const VectorType &b, - const PreconditionerType &preconditioner); + DEAL_II_CXX20_REQUIRES( + (concepts::is_linear_operator_on && + concepts::is_linear_operator_on)) + void solve(const MatrixType &A, + VectorType &x, + const VectorType &b, + const PreconditionerType &preconditioner); private: /** @@ -1777,6 +1781,9 @@ inline void SolverGMRES::compute_eigs_and_cond( template DEAL_II_CXX20_REQUIRES(concepts::is_vector_space_vector) template +DEAL_II_CXX20_REQUIRES( + (concepts::is_linear_operator_on && + concepts::is_linear_operator_on)) void SolverGMRES::solve(const MatrixType &A, VectorType &x, const VectorType &b, @@ -2164,6 +2171,9 @@ SolverFGMRES::SolverFGMRES(SolverControl &cn, template DEAL_II_CXX20_REQUIRES(concepts::is_vector_space_vector) template +DEAL_II_CXX20_REQUIRES( + (concepts::is_linear_operator_on && + concepts::is_linear_operator_on)) void SolverFGMRES::solve(const MatrixType &A, VectorType &x, const VectorType &b, diff --git a/include/deal.II/lac/solver_idr.h b/include/deal.II/lac/solver_idr.h index bb9e059b4a..693868ca2b 100644 --- a/include/deal.II/lac/solver_idr.h +++ b/include/deal.II/lac/solver_idr.h @@ -158,11 +158,13 @@ public: * Solve the linear system Ax=b for x. */ template - void - solve(const MatrixType &A, - VectorType &x, - const VectorType &b, - const PreconditionerType &preconditioner); + DEAL_II_CXX20_REQUIRES( + (concepts::is_linear_operator_on && + concepts::is_linear_operator_on)) + void solve(const MatrixType &A, + VectorType &x, + const VectorType &b, + const PreconditionerType &preconditioner); protected: /** @@ -312,6 +314,9 @@ void SolverIDR::print_vectors(const unsigned int, template DEAL_II_CXX20_REQUIRES(concepts::is_vector_space_vector) template +DEAL_II_CXX20_REQUIRES( + (concepts::is_linear_operator_on && + concepts::is_linear_operator_on)) void SolverIDR::solve(const MatrixType &A, VectorType &x, const VectorType &b, diff --git a/include/deal.II/lac/solver_minres.h b/include/deal.II/lac/solver_minres.h index 5078266087..6c2b62eb56 100644 --- a/include/deal.II/lac/solver_minres.h +++ b/include/deal.II/lac/solver_minres.h @@ -101,11 +101,13 @@ public: * Solve the linear system $Ax=b$ for x. */ template - void - solve(const MatrixType &A, - VectorType &x, - const VectorType &b, - const PreconditionerType &preconditioner); + DEAL_II_CXX20_REQUIRES( + (concepts::is_linear_operator_on && + concepts::is_linear_operator_on)) + void solve(const MatrixType &A, + VectorType &x, + const VectorType &b, + const PreconditionerType &preconditioner); /** * @addtogroup Exceptions @@ -192,6 +194,9 @@ void SolverMinRes::print_vectors(const unsigned int, template DEAL_II_CXX20_REQUIRES(concepts::is_vector_space_vector) template +DEAL_II_CXX20_REQUIRES( + (concepts::is_linear_operator_on && + concepts::is_linear_operator_on)) void SolverMinRes::solve(const MatrixType &A, VectorType &x, const VectorType &b, diff --git a/include/deal.II/lac/solver_qmrs.h b/include/deal.II/lac/solver_qmrs.h index 75e29c73b6..1eab3ca3e6 100644 --- a/include/deal.II/lac/solver_qmrs.h +++ b/include/deal.II/lac/solver_qmrs.h @@ -176,11 +176,13 @@ public: * Solve the linear system $Ax=b$ for x. */ template - void - solve(const MatrixType &A, - VectorType &x, - const VectorType &b, - const PreconditionerType &preconditioner); + DEAL_II_CXX20_REQUIRES( + (concepts::is_linear_operator_on && + concepts::is_linear_operator_on)) + void solve(const MatrixType &A, + VectorType &x, + const VectorType &b, + const PreconditionerType &preconditioner); /** * Interface for derived class. This function gets the current iteration @@ -288,6 +290,9 @@ void SolverQMRS::print_vectors(const unsigned int, template DEAL_II_CXX20_REQUIRES(concepts::is_vector_space_vector) template +DEAL_II_CXX20_REQUIRES( + (concepts::is_linear_operator_on && + concepts::is_linear_operator_on)) void SolverQMRS::solve(const MatrixType &A, VectorType &x, const VectorType &b, diff --git a/include/deal.II/lac/solver_relaxation.h b/include/deal.II/lac/solver_relaxation.h index cf7df9167e..f240a798a0 100644 --- a/include/deal.II/lac/solver_relaxation.h +++ b/include/deal.II/lac/solver_relaxation.h @@ -77,11 +77,15 @@ public: * residual. */ template - void - solve(const MatrixType &A, - VectorType &x, - const VectorType &b, - const RelaxationType &R); + DEAL_II_CXX20_REQUIRES( + (concepts::is_linear_operator_on && + requires(const RelaxationType &R, VectorType &a, VectorType &b) { + R.step(a, b); + })) + void solve(const MatrixType &A, + VectorType &x, + const VectorType &b, + const RelaxationType &R); }; //----------------------------------------------------------------------// @@ -98,6 +102,11 @@ SolverRelaxation::SolverRelaxation(SolverControl &cn, template DEAL_II_CXX20_REQUIRES(concepts::is_vector_space_vector) template +DEAL_II_CXX20_REQUIRES( + (concepts::is_linear_operator_on && + requires(const RelaxationType &R, VectorType &a, VectorType &b) { + R.step(a, b); + })) void SolverRelaxation::solve(const MatrixType &A, VectorType &x, const VectorType &b, diff --git a/include/deal.II/lac/solver_richardson.h b/include/deal.II/lac/solver_richardson.h index 54bab807bf..db10303de8 100644 --- a/include/deal.II/lac/solver_richardson.h +++ b/include/deal.II/lac/solver_richardson.h @@ -110,21 +110,25 @@ public: * Solve the linear system $Ax=b$ for x. */ template - void - solve(const MatrixType &A, - VectorType &x, - const VectorType &b, - const PreconditionerType &preconditioner); + DEAL_II_CXX20_REQUIRES( + (concepts::is_linear_operator_on && + concepts::is_linear_operator_on)) + void solve(const MatrixType &A, + VectorType &x, + const VectorType &b, + const PreconditionerType &preconditioner); /** * Solve $A^Tx=b$ for $x$. */ template - void - Tsolve(const MatrixType &A, - VectorType &x, - const VectorType &b, - const PreconditionerType &preconditioner); + DEAL_II_CXX20_REQUIRES( + (concepts::is_transpose_linear_operator_on && + concepts::is_transpose_linear_operator_on)) + void Tsolve(const MatrixType &A, + VectorType &x, + const VectorType &b, + const PreconditionerType &preconditioner); /** * Set the damping-coefficient. Default is 1., i.e. no damping. @@ -198,6 +202,9 @@ SolverRichardson::SolverRichardson(SolverControl &cn, template DEAL_II_CXX20_REQUIRES(concepts::is_vector_space_vector) template +DEAL_II_CXX20_REQUIRES( + (concepts::is_linear_operator_on && + concepts::is_linear_operator_on)) void SolverRichardson::solve( const MatrixType &A, VectorType &x, @@ -256,6 +263,9 @@ void SolverRichardson::solve( template DEAL_II_CXX20_REQUIRES(concepts::is_vector_space_vector) template +DEAL_II_CXX20_REQUIRES( + (concepts::is_transpose_linear_operator_on && + concepts::is_transpose_linear_operator_on)) void SolverRichardson::Tsolve( const MatrixType &A, VectorType &x, diff --git a/include/deal.II/lac/solver_selector.h b/include/deal.II/lac/solver_selector.h index dbf036333e..d7bba231d8 100644 --- a/include/deal.II/lac/solver_selector.h +++ b/include/deal.II/lac/solver_selector.h @@ -118,11 +118,13 @@ public: * SolverName was specified in the constructor. */ template - void - solve(const MatrixType &A, - VectorType &x, - const VectorType &b, - const PreconditionerType &precond) const; + DEAL_II_CXX20_REQUIRES( + (concepts::is_linear_operator_on && + concepts::is_linear_operator_on)) + void solve(const MatrixType &A, + VectorType &x, + const VectorType &b, + const PreconditionerType &precond) const; /** * Select a new solver. Note that all solver names used in this class are @@ -269,6 +271,9 @@ void SolverSelector::select(const std::string &name) template DEAL_II_CXX20_REQUIRES(concepts::is_vector_space_vector) template +DEAL_II_CXX20_REQUIRES( + (concepts::is_linear_operator_on && + concepts::is_linear_operator_on)) void SolverSelector::solve(const MatrixType &A, VectorType &x, const VectorType &b,