From: Wolfgang Bangerth Date: Wed, 24 May 2023 20:55:17 +0000 (-0600) Subject: Introduce concepts for PETSc-based matrices. X-Git-Tag: v9.5.0-rc1~184^2~2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b7e874b7c128eaeec1ab13592ecc940b9d1c1147;p=dealii.git Introduce concepts for PETSc-based matrices. --- diff --git a/include/deal.II/base/template_constraints.h b/include/deal.II/base/template_constraints.h index 0f735f42f6..1a0ef775f4 100644 --- a/include/deal.II/base/template_constraints.h +++ b/include/deal.II/base/template_constraints.h @@ -664,6 +664,9 @@ namespace PETScWrappers { class Vector; class BlockVector; + + class SparseMatrix; + class BlockSparseMatrix; } // namespace MPI } // namespace PETScWrappers #endif @@ -823,6 +826,28 @@ namespace concepts is_dealii_petsc_vector_type = true; # endif + + + /** + * A template variable that returns whether the template argument is + * a valid deal.II matrix type that is internally built on PETSc + * functionality. Its general definition is `false`, with + * specializations dealing with actual matrix types for which the + * predicate is `true`. + */ + template + inline constexpr bool is_dealii_petsc_matrix_type = false; + +# ifdef DEAL_II_WITH_PETSC + template <> + inline constexpr bool + is_dealii_petsc_matrix_type = + true; + + template <> + inline constexpr bool is_dealii_petsc_matrix_type< + dealii::PETScWrappers::MPI::BlockSparseMatrix> = true; +# endif } // namespace internal @@ -867,6 +892,17 @@ namespace concepts concept is_dealii_petsc_vector_type = internal::is_dealii_petsc_vector_type; + /** + * A concept that tests whether a given template argument is a deal.II + * matrix 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 matrix + * it works on are PETSc matrices. This includes, for example, the + * time stepping and nonlinear solver classes in namespace PETScWrappers. + */ + template + concept is_dealii_petsc_matrix_type = + internal::is_dealii_petsc_matrix_type; #endif } // namespace concepts