From: Wolfgang Bangerth Date: Sat, 22 Apr 2023 23:23:26 +0000 (-0600) Subject: Add 'requires' clauses to PETSc solvers. X-Git-Tag: v9.5.0-rc1~251^2~2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=81c5479e15582af84dc4474cd53fdd1f002218a7;p=dealii.git Add 'requires' clauses to PETSc solvers. --- diff --git a/include/deal.II/base/template_constraints.h b/include/deal.II/base/template_constraints.h index da9ba16131..0f735f42f6 100644 --- a/include/deal.II/base/template_constraints.h +++ b/include/deal.II/base/template_constraints.h @@ -656,6 +656,7 @@ namespace LinearAlgebra #ifdef DEAL_II_WITH_PETSC namespace PETScWrappers { + class VectorBase; class Vector; class BlockVector; @@ -788,6 +789,40 @@ namespace concepts dealii::LinearAlgebra::TpetraWrappers::Vector> = true; # endif # endif + + + /** + * A template variable that returns whether the template argument is + * a valid deal.II vector type that is internally built on PETSc + * functionality. Its general definition is `false`, with + * specializations dealing with actual vector types for which the + * predicate is `true`. + */ + template + inline constexpr bool is_dealii_petsc_vector_type = false; + +# ifdef DEAL_II_WITH_PETSC + template <> + inline constexpr bool + is_dealii_petsc_vector_type = true; + + template <> + inline constexpr bool + is_dealii_petsc_vector_type = true; + + template <> + inline constexpr bool + is_dealii_petsc_vector_type = true; + + template <> + inline constexpr bool + is_dealii_petsc_vector_type = true; + + template <> + inline constexpr bool + is_dealii_petsc_vector_type = + true; +# endif } // namespace internal @@ -820,6 +855,18 @@ namespace concepts (std::is_const_v == false); + /** + * A concept that tests whether a given template argument is a deal.II + * vector type that internally builds on PETSc functionality. This + * concept is used to constrain some classes that implement advanced + * functionality based on PETSc and that requires that the vector + * it works on are PETSc vectors. This includes, for example, the + * time stepping and nonlinear solver classes in namespace PETScWrappers. + */ + template + concept is_dealii_petsc_vector_type = + internal::is_dealii_petsc_vector_type; + #endif } // namespace concepts diff --git a/include/deal.II/lac/petsc_snes.h b/include/deal.II/lac/petsc_snes.h index ebae3fa4da..11c6db51e5 100644 --- a/include/deal.II/lac/petsc_snes.h +++ b/include/deal.II/lac/petsc_snes.h @@ -224,6 +224,7 @@ namespace PETScWrappers template + DEAL_II_CXX20_REQUIRES(concepts::is_dealii_petsc_vector_type) class NonlinearSolver { public: diff --git a/include/deal.II/lac/petsc_ts.h b/include/deal.II/lac/petsc_ts.h index 3dc726407f..64e9cb235f 100644 --- a/include/deal.II/lac/petsc_ts.h +++ b/include/deal.II/lac/petsc_ts.h @@ -289,6 +289,7 @@ namespace PETScWrappers template + DEAL_II_CXX20_REQUIRES(concepts::is_dealii_petsc_vector_type) class TimeStepper { public: