From: Wolfgang Bangerth Date: Fri, 10 May 2024 02:32:49 +0000 (+0530) Subject: Annotate solver classes with vector space vector concept. X-Git-Tag: v9.6.0-rc1~288^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=187b26a9f4d6c3edc3d3e986beb63eda4caae26e;p=dealii.git Annotate solver classes with vector space vector concept. --- diff --git a/include/deal.II/lac/solver.h b/include/deal.II/lac/solver.h index 60f7b4c21c..126265ffc5 100644 --- a/include/deal.II/lac/solver.h +++ b/include/deal.II/lac/solver.h @@ -18,6 +18,7 @@ #include #include +#include #include #include @@ -336,6 +337,7 @@ class Vector; * @ingroup Solvers */ template > +DEAL_II_CXX20_REQUIRES(concepts::is_vector_space_vector) class SolverBase : public Subscriptor { public: @@ -475,8 +477,8 @@ protected: #ifndef DOXYGEN template -inline SolverControl::State -SolverBase::StateCombiner::operator()( +DEAL_II_CXX20_REQUIRES(concepts::is_vector_space_vector) +inline SolverControl::State SolverBase::StateCombiner::operator()( const SolverControl::State state1, const SolverControl::State state2) const { @@ -491,10 +493,11 @@ SolverBase::StateCombiner::operator()( template +DEAL_II_CXX20_REQUIRES(concepts::is_vector_space_vector) template inline SolverControl::State -SolverBase::StateCombiner::operator()(const Iterator begin, - const Iterator end) const + SolverBase::StateCombiner::operator()(const Iterator begin, + const Iterator end) const { Assert(begin != end, ExcMessage("You can't combine iterator states if no state is given.")); @@ -511,6 +514,7 @@ SolverBase::StateCombiner::operator()(const Iterator begin, template +DEAL_II_CXX20_REQUIRES(concepts::is_vector_space_vector) inline SolverBase::SolverBase( SolverControl &solver_control, VectorMemory &vector_memory) @@ -530,6 +534,7 @@ inline SolverBase::SolverBase( template +DEAL_II_CXX20_REQUIRES(concepts::is_vector_space_vector) inline SolverBase::SolverBase(SolverControl &solver_control) : // use the static memory object this class owns memory(static_vector_memory) @@ -548,8 +553,8 @@ inline SolverBase::SolverBase(SolverControl &solver_control) template -inline boost::signals2::connection -SolverBase::connect( +DEAL_II_CXX20_REQUIRES(concepts::is_vector_space_vector) +inline boost::signals2::connection SolverBase::connect( const std::function diff --git a/include/deal.II/lac/solver_bicgstab.h b/include/deal.II/lac/solver_bicgstab.h index 5cde570ced..79b3d67974 100644 --- a/include/deal.II/lac/solver_bicgstab.h +++ b/include/deal.II/lac/solver_bicgstab.h @@ -21,6 +21,7 @@ #include #include #include +#include #include #include @@ -75,6 +76,7 @@ DEAL_II_NAMESPACE_OPEN * to observe the progress of the iteration. */ template > +DEAL_II_CXX20_REQUIRES(concepts::is_vector_space_vector) class SolverBicgstab : public SolverBase { public: @@ -209,6 +211,7 @@ private: template +DEAL_II_CXX20_REQUIRES(concepts::is_vector_space_vector) SolverBicgstab::IterationResult::IterationResult( const bool breakdown, const SolverControl::State state, @@ -223,6 +226,7 @@ SolverBicgstab::IterationResult::IterationResult( template +DEAL_II_CXX20_REQUIRES(concepts::is_vector_space_vector) SolverBicgstab::SolverBicgstab(SolverControl &cn, VectorMemory &mem, const AdditionalData &data) @@ -233,6 +237,7 @@ SolverBicgstab::SolverBicgstab(SolverControl &cn, template +DEAL_II_CXX20_REQUIRES(concepts::is_vector_space_vector) SolverBicgstab::SolverBicgstab(SolverControl &cn, const AdditionalData &data) : SolverBase(cn) @@ -242,12 +247,12 @@ SolverBicgstab::SolverBicgstab(SolverControl &cn, template +DEAL_II_CXX20_REQUIRES(concepts::is_vector_space_vector) template -double -SolverBicgstab::criterion(const MatrixType &A, - const VectorType &x, - const VectorType &b, - VectorType &t) +double SolverBicgstab::criterion(const MatrixType &A, + const VectorType &x, + const VectorType &b, + VectorType &t) { A.vmult(t, x); return std::sqrt(t.add_and_dot(-1.0, b, t)); @@ -256,23 +261,24 @@ SolverBicgstab::criterion(const MatrixType &A, template -void -SolverBicgstab::print_vectors(const unsigned int, - const VectorType &, - const VectorType &, - const VectorType &) const +DEAL_II_CXX20_REQUIRES(concepts::is_vector_space_vector) +void SolverBicgstab::print_vectors(const unsigned int, + const VectorType &, + const VectorType &, + const VectorType &) const {} template +DEAL_II_CXX20_REQUIRES(concepts::is_vector_space_vector) template typename SolverBicgstab::IterationResult -SolverBicgstab::iterate(const MatrixType &A, - VectorType &x, - const VectorType &b, - const PreconditionerType &preconditioner, - const unsigned int last_step) + SolverBicgstab::iterate(const MatrixType &A, + VectorType &x, + const VectorType &b, + const PreconditionerType &preconditioner, + const unsigned int last_step) { // Allocate temporary memory. typename VectorMemory::Pointer Vr(this->memory); @@ -397,12 +403,12 @@ SolverBicgstab::iterate(const MatrixType &A, template +DEAL_II_CXX20_REQUIRES(concepts::is_vector_space_vector) template -void -SolverBicgstab::solve(const MatrixType &A, - VectorType &x, - const VectorType &b, - const PreconditionerType &preconditioner) +void SolverBicgstab::solve(const MatrixType &A, + VectorType &x, + const VectorType &b, + const PreconditionerType &preconditioner) { LogStream::Prefix prefix("Bicgstab"); diff --git a/include/deal.II/lac/solver_cg.h b/include/deal.II/lac/solver_cg.h index 7423ada149..498df053c4 100644 --- a/include/deal.II/lac/solver_cg.h +++ b/include/deal.II/lac/solver_cg.h @@ -21,6 +21,7 @@ #include #include #include +#include #include #include @@ -173,6 +174,7 @@ namespace LinearAlgebra * the operation after the loop performs a total of 7 reductions in parallel. */ template > +DEAL_II_CXX20_REQUIRES(concepts::is_vector_space_vector) class SolverCG : public SolverBase { public: @@ -350,6 +352,7 @@ protected: * descent method. */ template > +DEAL_II_CXX20_REQUIRES(concepts::is_vector_space_vector) class SolverFlexibleCG : public SolverCG { public: @@ -391,6 +394,7 @@ public: template +DEAL_II_CXX20_REQUIRES(concepts::is_vector_space_vector) SolverCG::SolverCG(SolverControl &cn, VectorMemory &mem, const AdditionalData &data) @@ -402,6 +406,7 @@ SolverCG::SolverCG(SolverControl &cn, template +DEAL_II_CXX20_REQUIRES(concepts::is_vector_space_vector) SolverCG::SolverCG(SolverControl &cn, const AdditionalData &data) : SolverBase(cn) , additional_data(data) @@ -411,18 +416,18 @@ SolverCG::SolverCG(SolverControl &cn, const AdditionalData &data) template -void -SolverCG::print_vectors(const unsigned int, - const VectorType &, - const VectorType &, - const VectorType &) const +DEAL_II_CXX20_REQUIRES(concepts::is_vector_space_vector) +void SolverCG::print_vectors(const unsigned int, + const VectorType &, + const VectorType &, + const VectorType &) const {} template -inline void -SolverCG::compute_eigs_and_cond( +DEAL_II_CXX20_REQUIRES(concepts::is_vector_space_vector) +inline void SolverCG::compute_eigs_and_cond( const std::vector &diagonal, const std::vector &offdiagonal, const boost::signals2::signal &)> @@ -1258,12 +1263,12 @@ namespace internal template +DEAL_II_CXX20_REQUIRES(concepts::is_vector_space_vector) template -void -SolverCG::solve(const MatrixType &A, - VectorType &x, - const VectorType &b, - const PreconditionerType &preconditioner) +void SolverCG::solve(const MatrixType &A, + VectorType &x, + const VectorType &b, + const PreconditionerType &preconditioner) { using number = typename VectorType::value_type; @@ -1339,8 +1344,8 @@ SolverCG::solve(const MatrixType &A, template -boost::signals2::connection -SolverCG::connect_coefficients_slot( +DEAL_II_CXX20_REQUIRES(concepts::is_vector_space_vector) +boost::signals2::connection SolverCG::connect_coefficients_slot( const std::function &slot) { @@ -1350,8 +1355,8 @@ SolverCG::connect_coefficients_slot( template -boost::signals2::connection -SolverCG::connect_condition_number_slot( +DEAL_II_CXX20_REQUIRES(concepts::is_vector_space_vector) +boost::signals2::connection SolverCG::connect_condition_number_slot( const std::function &slot, const bool every_iteration) { @@ -1368,8 +1373,8 @@ SolverCG::connect_condition_number_slot( template -boost::signals2::connection -SolverCG::connect_eigenvalues_slot( +DEAL_II_CXX20_REQUIRES(concepts::is_vector_space_vector) +boost::signals2::connection SolverCG::connect_eigenvalues_slot( const std::function &)> &slot, const bool every_iteration) { @@ -1386,6 +1391,7 @@ SolverCG::connect_eigenvalues_slot( template +DEAL_II_CXX20_REQUIRES(concepts::is_vector_space_vector) SolverFlexibleCG::SolverFlexibleCG(SolverControl &cn, VectorMemory &mem, const AdditionalData &) @@ -1397,6 +1403,7 @@ SolverFlexibleCG::SolverFlexibleCG(SolverControl &cn, template +DEAL_II_CXX20_REQUIRES(concepts::is_vector_space_vector) SolverFlexibleCG::SolverFlexibleCG(SolverControl &cn, const AdditionalData &) : SolverCG(cn) diff --git a/include/deal.II/lac/solver_fire.h b/include/deal.II/lac/solver_fire.h index 0b89dd343f..4efed16e85 100644 --- a/include/deal.II/lac/solver_fire.h +++ b/include/deal.II/lac/solver_fire.h @@ -19,6 +19,7 @@ #include #include +#include #include #include @@ -87,6 +88,7 @@ DEAL_II_NAMESPACE_OPEN * Eidel et al. 2011. */ template > +DEAL_II_CXX20_REQUIRES(concepts::is_vector_space_vector) class SolverFIRE : public SolverBase { public: @@ -187,6 +189,7 @@ protected: #ifndef DOXYGEN template +DEAL_II_CXX20_REQUIRES(concepts::is_vector_space_vector) SolverFIRE::AdditionalData::AdditionalData( const double initial_timestep, const double maximum_timestep, @@ -205,6 +208,7 @@ SolverFIRE::AdditionalData::AdditionalData( template +DEAL_II_CXX20_REQUIRES(concepts::is_vector_space_vector) SolverFIRE::SolverFIRE(SolverControl &solver_control, VectorMemory &vector_memory, const AdditionalData &data) @@ -215,6 +219,7 @@ SolverFIRE::SolverFIRE(SolverControl &solver_control, template +DEAL_II_CXX20_REQUIRES(concepts::is_vector_space_vector) SolverFIRE::SolverFIRE(SolverControl &solver_control, const AdditionalData &data) : SolverBase(solver_control) @@ -224,9 +229,9 @@ SolverFIRE::SolverFIRE(SolverControl &solver_control, template +DEAL_II_CXX20_REQUIRES(concepts::is_vector_space_vector) template -void -SolverFIRE::solve( +void SolverFIRE::solve( const std::function &compute, VectorType &x, const PreconditionerType &inverse_mass_matrix) @@ -346,12 +351,12 @@ SolverFIRE::solve( template +DEAL_II_CXX20_REQUIRES(concepts::is_vector_space_vector) template -void -SolverFIRE::solve(const MatrixType &A, - VectorType &x, - const VectorType &b, - const PreconditionerType &preconditioner) +void SolverFIRE::solve(const MatrixType &A, + VectorType &x, + const VectorType &b, + const PreconditionerType &preconditioner) { std::function compute_func = [&](VectorType &g, const VectorType &x) -> double { @@ -372,11 +377,11 @@ SolverFIRE::solve(const MatrixType &A, template -void -SolverFIRE::print_vectors(const unsigned int, - const VectorType &, - const VectorType &, - const VectorType &) const +DEAL_II_CXX20_REQUIRES(concepts::is_vector_space_vector) +void SolverFIRE::print_vectors(const unsigned int, + const VectorType &, + const VectorType &, + const VectorType &) const {} diff --git a/include/deal.II/lac/solver_gmres.h b/include/deal.II/lac/solver_gmres.h index 418f3931f4..71466995b1 100644 --- a/include/deal.II/lac/solver_gmres.h +++ b/include/deal.II/lac/solver_gmres.h @@ -21,6 +21,7 @@ #include #include +#include #include #include @@ -347,6 +348,7 @@ namespace internal * will then be called from the solver with the estimates as argument. */ template > +DEAL_II_CXX20_REQUIRES(concepts::is_vector_space_vector) class SolverGMRES : public SolverBase { public: @@ -639,6 +641,7 @@ protected: * For more details see @cite Saad1991. */ template > +DEAL_II_CXX20_REQUIRES(concepts::is_vector_space_vector) class SolverFGMRES : public SolverBase { public: @@ -714,6 +717,7 @@ private: #ifndef DOXYGEN template +DEAL_II_CXX20_REQUIRES(concepts::is_vector_space_vector) inline SolverGMRES::AdditionalData::AdditionalData( const unsigned int max_basis_size, const bool right_preconditioning, @@ -737,6 +741,7 @@ inline SolverGMRES::AdditionalData::AdditionalData( template +DEAL_II_CXX20_REQUIRES(concepts::is_vector_space_vector) SolverGMRES::SolverGMRES(SolverControl &cn, VectorMemory &mem, const AdditionalData &data) @@ -748,6 +753,7 @@ SolverGMRES::SolverGMRES(SolverControl &cn, template +DEAL_II_CXX20_REQUIRES(concepts::is_vector_space_vector) SolverGMRES::SolverGMRES(SolverControl &cn, const AdditionalData &data) : SolverBase(cn) @@ -1717,8 +1723,8 @@ namespace internal template -inline void -SolverGMRES::compute_eigs_and_cond( +DEAL_II_CXX20_REQUIRES(concepts::is_vector_space_vector) +inline void SolverGMRES::compute_eigs_and_cond( const FullMatrix &H_orig, const unsigned int n, const boost::signals2::signal> &)> @@ -1769,12 +1775,12 @@ SolverGMRES::compute_eigs_and_cond( template +DEAL_II_CXX20_REQUIRES(concepts::is_vector_space_vector) template -void -SolverGMRES::solve(const MatrixType &A, - VectorType &x, - const VectorType &b, - const PreconditionerType &preconditioner) +void SolverGMRES::solve(const MatrixType &A, + VectorType &x, + const VectorType &b, + const PreconditionerType &preconditioner) { std::unique_ptr prefix; if (!additional_data.batched_mode) @@ -2045,10 +2051,11 @@ SolverGMRES::solve(const MatrixType &A, template +DEAL_II_CXX20_REQUIRES(concepts::is_vector_space_vector) boost::signals2::connection -SolverGMRES::connect_condition_number_slot( - const std::function &slot, - const bool every_iteration) + SolverGMRES::connect_condition_number_slot( + const std::function &slot, + const bool every_iteration) { if (every_iteration) { @@ -2063,8 +2070,8 @@ SolverGMRES::connect_condition_number_slot( template -boost::signals2::connection -SolverGMRES::connect_eigenvalues_slot( +DEAL_II_CXX20_REQUIRES(concepts::is_vector_space_vector) +boost::signals2::connection SolverGMRES::connect_eigenvalues_slot( const std::function> &)> &slot, const bool every_iteration) { @@ -2081,8 +2088,8 @@ SolverGMRES::connect_eigenvalues_slot( template -boost::signals2::connection -SolverGMRES::connect_hessenberg_slot( +DEAL_II_CXX20_REQUIRES(concepts::is_vector_space_vector) +boost::signals2::connection SolverGMRES::connect_hessenberg_slot( const std::function &)> &slot, const bool every_iteration) { @@ -2099,8 +2106,8 @@ SolverGMRES::connect_hessenberg_slot( template -boost::signals2::connection -SolverGMRES::connect_krylov_space_slot( +DEAL_II_CXX20_REQUIRES(concepts::is_vector_space_vector) +boost::signals2::connection SolverGMRES::connect_krylov_space_slot( const std::function &)> &slot) { @@ -2110,9 +2117,10 @@ SolverGMRES::connect_krylov_space_slot( template +DEAL_II_CXX20_REQUIRES(concepts::is_vector_space_vector) boost::signals2::connection -SolverGMRES::connect_re_orthogonalization_slot( - const std::function &slot) + SolverGMRES::connect_re_orthogonalization_slot( + const std::function &slot) { return re_orthogonalize_signal.connect(slot); } @@ -2120,8 +2128,8 @@ SolverGMRES::connect_re_orthogonalization_slot( template -double -SolverGMRES::criterion() +DEAL_II_CXX20_REQUIRES(concepts::is_vector_space_vector) +double SolverGMRES::criterion() { // dummy implementation. this function is not needed for the present // implementation of gmres @@ -2133,6 +2141,7 @@ SolverGMRES::criterion() //----------------------------------------------------------------------// template +DEAL_II_CXX20_REQUIRES(concepts::is_vector_space_vector) SolverFGMRES::SolverFGMRES(SolverControl &cn, VectorMemory &mem, const AdditionalData &data) @@ -2143,6 +2152,7 @@ SolverFGMRES::SolverFGMRES(SolverControl &cn, template +DEAL_II_CXX20_REQUIRES(concepts::is_vector_space_vector) SolverFGMRES::SolverFGMRES(SolverControl &cn, const AdditionalData &data) : SolverBase(cn) @@ -2152,12 +2162,12 @@ SolverFGMRES::SolverFGMRES(SolverControl &cn, template +DEAL_II_CXX20_REQUIRES(concepts::is_vector_space_vector) template -void -SolverFGMRES::solve(const MatrixType &A, - VectorType &x, - const VectorType &b, - const PreconditionerType &preconditioner) +void SolverFGMRES::solve(const MatrixType &A, + VectorType &x, + const VectorType &b, + const PreconditionerType &preconditioner) { LogStream::Prefix prefix("FGMRES"); diff --git a/include/deal.II/lac/solver_idr.h b/include/deal.II/lac/solver_idr.h index 8a5111fa69..bb9e059b4a 100644 --- a/include/deal.II/lac/solver_idr.h +++ b/include/deal.II/lac/solver_idr.h @@ -21,6 +21,7 @@ #include #include #include +#include #include #include @@ -115,6 +116,7 @@ namespace internal * iteration. */ template > +DEAL_II_CXX20_REQUIRES(concepts::is_vector_space_vector) class SolverIDR : public SolverBase { public: @@ -278,6 +280,7 @@ namespace internal template +DEAL_II_CXX20_REQUIRES(concepts::is_vector_space_vector) SolverIDR::SolverIDR(SolverControl &cn, VectorMemory &mem, const AdditionalData &data) @@ -288,6 +291,7 @@ SolverIDR::SolverIDR(SolverControl &cn, template +DEAL_II_CXX20_REQUIRES(concepts::is_vector_space_vector) SolverIDR::SolverIDR(SolverControl &cn, const AdditionalData &data) : SolverBase(cn) , additional_data(data) @@ -296,22 +300,22 @@ SolverIDR::SolverIDR(SolverControl &cn, const AdditionalData &data) template -void -SolverIDR::print_vectors(const unsigned int, - const VectorType &, - const VectorType &, - const VectorType &) const +DEAL_II_CXX20_REQUIRES(concepts::is_vector_space_vector) +void SolverIDR::print_vectors(const unsigned int, + const VectorType &, + const VectorType &, + const VectorType &) const {} template +DEAL_II_CXX20_REQUIRES(concepts::is_vector_space_vector) template -void -SolverIDR::solve(const MatrixType &A, - VectorType &x, - const VectorType &b, - const PreconditionerType &preconditioner) +void SolverIDR::solve(const MatrixType &A, + VectorType &x, + const VectorType &b, + const PreconditionerType &preconditioner) { LogStream::Prefix prefix("IDR(s)"); diff --git a/include/deal.II/lac/solver_minres.h b/include/deal.II/lac/solver_minres.h index 8043c5164d..5078266087 100644 --- a/include/deal.II/lac/solver_minres.h +++ b/include/deal.II/lac/solver_minres.h @@ -21,6 +21,7 @@ #include #include #include +#include #include #include @@ -66,6 +67,7 @@ DEAL_II_NAMESPACE_OPEN * to observe the progress of the iteration. */ template > +DEAL_II_CXX20_REQUIRES(concepts::is_vector_space_vector) class SolverMinRes : public SolverBase { public: @@ -149,6 +151,7 @@ protected: #ifndef DOXYGEN template +DEAL_II_CXX20_REQUIRES(concepts::is_vector_space_vector) SolverMinRes::SolverMinRes(SolverControl &cn, VectorMemory &mem, const AdditionalData &) @@ -159,6 +162,7 @@ SolverMinRes::SolverMinRes(SolverControl &cn, template +DEAL_II_CXX20_REQUIRES(concepts::is_vector_space_vector) SolverMinRes::SolverMinRes(SolverControl &cn, const AdditionalData &) : SolverBase(cn) @@ -168,30 +172,30 @@ SolverMinRes::SolverMinRes(SolverControl &cn, template -double -SolverMinRes::criterion() +DEAL_II_CXX20_REQUIRES(concepts::is_vector_space_vector) +double SolverMinRes::criterion() { return res2; } template -void -SolverMinRes::print_vectors(const unsigned int, - const VectorType &, - const VectorType &, - const VectorType &) const +DEAL_II_CXX20_REQUIRES(concepts::is_vector_space_vector) +void SolverMinRes::print_vectors(const unsigned int, + const VectorType &, + const VectorType &, + const VectorType &) const {} template +DEAL_II_CXX20_REQUIRES(concepts::is_vector_space_vector) template -void -SolverMinRes::solve(const MatrixType &A, - VectorType &x, - const VectorType &b, - const PreconditionerType &preconditioner) +void SolverMinRes::solve(const MatrixType &A, + VectorType &x, + const VectorType &b, + const PreconditionerType &preconditioner) { LogStream::Prefix prefix("minres"); diff --git a/include/deal.II/lac/solver_qmrs.h b/include/deal.II/lac/solver_qmrs.h index 7790371459..75e29c73b6 100644 --- a/include/deal.II/lac/solver_qmrs.h +++ b/include/deal.II/lac/solver_qmrs.h @@ -19,6 +19,7 @@ #include #include +#include #include #include @@ -90,6 +91,7 @@ DEAL_II_NAMESPACE_OPEN * to observe the progress of the iteration. */ template > +DEAL_II_CXX20_REQUIRES(concepts::is_vector_space_vector) class SolverQMRS : public SolverBase { public: @@ -240,6 +242,7 @@ private: template +DEAL_II_CXX20_REQUIRES(concepts::is_vector_space_vector) SolverQMRS::IterationResult::IterationResult( const SolverControl::State state, const double last_residual) @@ -250,6 +253,7 @@ SolverQMRS::IterationResult::IterationResult( template +DEAL_II_CXX20_REQUIRES(concepts::is_vector_space_vector) SolverQMRS::SolverQMRS(SolverControl &cn, VectorMemory &mem, const AdditionalData &data) @@ -258,7 +262,10 @@ SolverQMRS::SolverQMRS(SolverControl &cn, , step(0) {} + + template +DEAL_II_CXX20_REQUIRES(concepts::is_vector_space_vector) SolverQMRS::SolverQMRS(SolverControl &cn, const AdditionalData &data) : SolverBase(cn) @@ -266,21 +273,25 @@ SolverQMRS::SolverQMRS(SolverControl &cn, , step(0) {} + + template -void -SolverQMRS::print_vectors(const unsigned int, - const VectorType &, - const VectorType &, - const VectorType &) const +DEAL_II_CXX20_REQUIRES(concepts::is_vector_space_vector) +void SolverQMRS::print_vectors(const unsigned int, + const VectorType &, + const VectorType &, + const VectorType &) const {} + + template +DEAL_II_CXX20_REQUIRES(concepts::is_vector_space_vector) template -void -SolverQMRS::solve(const MatrixType &A, - VectorType &x, - const VectorType &b, - const PreconditionerType &preconditioner) +void SolverQMRS::solve(const MatrixType &A, + VectorType &x, + const VectorType &b, + const PreconditionerType &preconditioner) { LogStream::Prefix prefix("SQMR"); @@ -322,18 +333,21 @@ SolverQMRS::solve(const MatrixType &A, // otherwise exit as normal } + + template +DEAL_II_CXX20_REQUIRES(concepts::is_vector_space_vector) template typename SolverQMRS::IterationResult -SolverQMRS::iterate(const MatrixType &A, - VectorType &x, - const VectorType &b, - const PreconditionerType &preconditioner, - VectorType &r, - VectorType &u, - VectorType &q, - VectorType &t, - VectorType &d) + SolverQMRS::iterate(const MatrixType &A, + VectorType &x, + const VectorType &b, + const PreconditionerType &preconditioner, + VectorType &r, + VectorType &u, + VectorType &q, + VectorType &t, + VectorType &d) { SolverControl::State state = SolverControl::iterate; diff --git a/include/deal.II/lac/solver_relaxation.h b/include/deal.II/lac/solver_relaxation.h index c0ae0beedb..cf7df9167e 100644 --- a/include/deal.II/lac/solver_relaxation.h +++ b/include/deal.II/lac/solver_relaxation.h @@ -20,6 +20,7 @@ #include #include +#include #include #include @@ -53,6 +54,7 @@ DEAL_II_NAMESPACE_OPEN * @ingroup Solvers */ template > +DEAL_II_CXX20_REQUIRES(concepts::is_vector_space_vector) class SolverRelaxation : public SolverBase { public: @@ -85,6 +87,7 @@ public: //----------------------------------------------------------------------// template +DEAL_II_CXX20_REQUIRES(concepts::is_vector_space_vector) SolverRelaxation::SolverRelaxation(SolverControl &cn, const AdditionalData &) : SolverBase(cn) @@ -93,12 +96,12 @@ SolverRelaxation::SolverRelaxation(SolverControl &cn, template +DEAL_II_CXX20_REQUIRES(concepts::is_vector_space_vector) template -void -SolverRelaxation::solve(const MatrixType &A, - VectorType &x, - const VectorType &b, - const RelaxationType &R) +void SolverRelaxation::solve(const MatrixType &A, + VectorType &x, + const VectorType &b, + const RelaxationType &R) { GrowingVectorMemory mem; SolverControl::State conv = SolverControl::iterate; diff --git a/include/deal.II/lac/solver_richardson.h b/include/deal.II/lac/solver_richardson.h index cb7d3ff7f6..54bab807bf 100644 --- a/include/deal.II/lac/solver_richardson.h +++ b/include/deal.II/lac/solver_richardson.h @@ -20,6 +20,7 @@ #include #include +#include #include #include @@ -60,6 +61,7 @@ DEAL_II_NAMESPACE_OPEN * to observe the progress of the iteration. */ template > +DEAL_II_CXX20_REQUIRES(concepts::is_vector_space_vector) class SolverRichardson : public SolverBase { public: @@ -163,6 +165,7 @@ protected: #ifndef DOXYGEN template +DEAL_II_CXX20_REQUIRES(concepts::is_vector_space_vector) inline SolverRichardson::AdditionalData::AdditionalData( const double omega, const bool use_preconditioned_residual) @@ -172,6 +175,7 @@ inline SolverRichardson::AdditionalData::AdditionalData( template +DEAL_II_CXX20_REQUIRES(concepts::is_vector_space_vector) SolverRichardson::SolverRichardson(SolverControl &cn, VectorMemory &mem, const AdditionalData &data) @@ -182,6 +186,7 @@ SolverRichardson::SolverRichardson(SolverControl &cn, template +DEAL_II_CXX20_REQUIRES(concepts::is_vector_space_vector) SolverRichardson::SolverRichardson(SolverControl &cn, const AdditionalData &data) : SolverBase(cn) @@ -191,12 +196,13 @@ SolverRichardson::SolverRichardson(SolverControl &cn, template +DEAL_II_CXX20_REQUIRES(concepts::is_vector_space_vector) template -void -SolverRichardson::solve(const MatrixType &A, - VectorType &x, - const VectorType &b, - const PreconditionerType &preconditioner) +void SolverRichardson::solve( + const MatrixType &A, + VectorType &x, + const VectorType &b, + const PreconditionerType &preconditioner) { SolverControl::State conv = SolverControl::iterate; @@ -248,12 +254,13 @@ SolverRichardson::solve(const MatrixType &A, template +DEAL_II_CXX20_REQUIRES(concepts::is_vector_space_vector) template -void -SolverRichardson::Tsolve(const MatrixType &A, - VectorType &x, - const VectorType &b, - const PreconditionerType &preconditioner) +void SolverRichardson::Tsolve( + const MatrixType &A, + VectorType &x, + const VectorType &b, + const PreconditionerType &preconditioner) { SolverControl::State conv = SolverControl::iterate; double last_criterion = std::numeric_limits::lowest(); @@ -301,20 +308,22 @@ SolverRichardson::Tsolve(const MatrixType &A, } + template -void -SolverRichardson::print_vectors(const unsigned int, - const VectorType &, - const VectorType &, - const VectorType &) const +DEAL_II_CXX20_REQUIRES(concepts::is_vector_space_vector) +void SolverRichardson::print_vectors(const unsigned int, + const VectorType &, + const VectorType &, + const VectorType &) const {} template +DEAL_II_CXX20_REQUIRES(concepts::is_vector_space_vector) inline typename VectorType::value_type -SolverRichardson::criterion(const VectorType &r, - const VectorType &d) const + SolverRichardson::criterion(const VectorType &r, + const VectorType &d) const { if (!additional_data.use_preconditioned_residual) return r.l2_norm(); @@ -324,8 +333,8 @@ SolverRichardson::criterion(const VectorType &r, template -inline void -SolverRichardson::set_omega(const double om) +DEAL_II_CXX20_REQUIRES(concepts::is_vector_space_vector) +inline void SolverRichardson::set_omega(const double om) { additional_data.omega = om; } diff --git a/include/deal.II/lac/solver_selector.h b/include/deal.II/lac/solver_selector.h index 1376a8ab03..dbf036333e 100644 --- a/include/deal.II/lac/solver_selector.h +++ b/include/deal.II/lac/solver_selector.h @@ -19,6 +19,7 @@ #include #include +#include #include #include @@ -87,6 +88,7 @@ DEAL_II_NAMESPACE_OPEN * access to that new solver. */ template > +DEAL_II_CXX20_REQUIRES(concepts::is_vector_space_vector) class SolverSelector : public Subscriptor { public: @@ -115,12 +117,12 @@ public: * Solver procedure. Calls the @p solve function of the @p solver whose @p * SolverName was specified in the constructor. */ - template + template void - solve(const Matrix &A, - VectorType &x, - const VectorType &b, - const Preconditioner &precond) const; + 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 @@ -246,6 +248,7 @@ private: template +DEAL_II_CXX20_REQUIRES(concepts::is_vector_space_vector) SolverSelector::SolverSelector(const std::string &name, SolverControl &solver_control) : solver_name(name) @@ -255,8 +258,8 @@ SolverSelector::SolverSelector(const std::string &name, template -void -SolverSelector::select(const std::string &name) +DEAL_II_CXX20_REQUIRES(concepts::is_vector_space_vector) +void SolverSelector::select(const std::string &name) { solver_name = name; } @@ -264,12 +267,12 @@ SolverSelector::select(const std::string &name) template -template -void -SolverSelector::solve(const Matrix &A, - VectorType &x, - const VectorType &b, - const Preconditioner &precond) const +DEAL_II_CXX20_REQUIRES(concepts::is_vector_space_vector) +template +void SolverSelector::solve(const MatrixType &A, + VectorType &x, + const VectorType &b, + const PreconditionerType &precond) const { if (solver_name == "richardson") { @@ -308,8 +311,8 @@ SolverSelector::solve(const Matrix &A, template -void -SolverSelector::set_control(SolverControl &ctrl) +DEAL_II_CXX20_REQUIRES(concepts::is_vector_space_vector) +void SolverSelector::set_control(SolverControl &ctrl) { control = &ctrl; } @@ -317,8 +320,8 @@ SolverSelector::set_control(SolverControl &ctrl) template -std::string -SolverSelector::get_solver_names() +DEAL_II_CXX20_REQUIRES(concepts::is_vector_space_vector) +std::string SolverSelector::get_solver_names() { return "richardson|cg|bicgstab|gmres|fgmres|minres"; } @@ -326,8 +329,8 @@ SolverSelector::get_solver_names() template -void -SolverSelector::set_data( +DEAL_II_CXX20_REQUIRES(concepts::is_vector_space_vector) +void SolverSelector::set_data( const typename SolverGMRES::AdditionalData &data) { gmres_data = data; @@ -336,8 +339,8 @@ SolverSelector::set_data( template -void -SolverSelector::set_data( +DEAL_II_CXX20_REQUIRES(concepts::is_vector_space_vector) +void SolverSelector::set_data( const typename SolverFGMRES::AdditionalData &data) { fgmres_data = data; @@ -346,8 +349,8 @@ SolverSelector::set_data( template -void -SolverSelector::set_data( +DEAL_II_CXX20_REQUIRES(concepts::is_vector_space_vector) +void SolverSelector::set_data( const typename SolverRichardson::AdditionalData &data) { richardson_data = data; @@ -356,8 +359,8 @@ SolverSelector::set_data( template -void -SolverSelector::set_data( +DEAL_II_CXX20_REQUIRES(concepts::is_vector_space_vector) +void SolverSelector::set_data( const typename SolverCG::AdditionalData &data) { cg_data = data; @@ -366,8 +369,8 @@ SolverSelector::set_data( template -void -SolverSelector::set_data( +DEAL_II_CXX20_REQUIRES(concepts::is_vector_space_vector) +void SolverSelector::set_data( const typename SolverMinRes::AdditionalData &data) { minres_data = data; @@ -376,8 +379,8 @@ SolverSelector::set_data( template -void -SolverSelector::set_data( +DEAL_II_CXX20_REQUIRES(concepts::is_vector_space_vector) +void SolverSelector::set_data( const typename SolverBicgstab::AdditionalData &data) { bicgstab_data = data; diff --git a/include/deal.II/lac/trilinos_solver.h b/include/deal.II/lac/trilinos_solver.h index 9af6964057..6e1dc27f11 100644 --- a/include/deal.II/lac/trilinos_solver.h +++ b/include/deal.II/lac/trilinos_solver.h @@ -20,6 +20,8 @@ #ifdef DEAL_II_WITH_TRILINOS +# include + # include # include # include @@ -687,6 +689,7 @@ namespace TrilinosWrappers * targeting deal.II data structures. */ template + DEAL_II_CXX20_REQUIRES(concepts::is_vector_space_vector) class SolverBelos { public: @@ -775,6 +778,7 @@ namespace TrilinosWrappers * https://docs.trilinos.org/latest-release/packages/belos/doc/html/classBelos_1_1MultiVec.html. */ template + DEAL_II_CXX20_REQUIRES(concepts::is_vector_space_vector) class MultiVecWrapper : public Belos::MultiVec { @@ -1214,6 +1218,7 @@ namespace TrilinosWrappers * https://docs.trilinos.org/latest-release/packages/belos/doc/html/classBelos_1_1Operator.html. */ template + DEAL_II_CXX20_REQUIRES(concepts::is_vector_space_vector) class OperatorWrapper : public Belos::Operator { @@ -1283,6 +1288,7 @@ namespace TrilinosWrappers template + DEAL_II_CXX20_REQUIRES(concepts::is_vector_space_vector) SolverBelos::SolverBelos( SolverControl &solver_control, const AdditionalData &additional_data, @@ -1295,12 +1301,12 @@ namespace TrilinosWrappers template + DEAL_II_CXX20_REQUIRES(concepts::is_vector_space_vector) template - void - SolverBelos::solve(const OperatorType &A_dealii, - VectorType &x_dealii, - const VectorType &b_dealii, - const PreconditionerType &P_dealii) + void SolverBelos::solve(const OperatorType &A_dealii, + VectorType &x_dealii, + const VectorType &b_dealii, + const PreconditionerType &P_dealii) { using value_type = typename VectorType::value_type;