From 0b23a08618f8d459a28e252809c1dfeec8a5358e Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Mon, 3 Jul 2023 16:17:39 -0600 Subject: [PATCH] Check vector-space-vector concepts for all vector classes. --- source/lac/block_vector.inst.in | 7 +++++++ source/lac/la_parallel_block_vector.inst.in | 5 +++++ source/lac/la_parallel_vector.inst.in | 6 ++++++ source/lac/petsc_parallel_block_vector.cc | 8 ++++++++ source/lac/petsc_parallel_vector.cc | 8 ++++++++ source/lac/trilinos_epetra_vector.cc | 8 ++++++++ source/lac/trilinos_tpetra_vector.cc | 22 +++++++++++++++++++++ source/lac/vector.inst.in | 8 ++++++++ 8 files changed, 72 insertions(+) diff --git a/source/lac/block_vector.inst.in b/source/lac/block_vector.inst.in index e4a758c6c4..590a89688f 100644 --- a/source/lac/block_vector.inst.in +++ b/source/lac/block_vector.inst.in @@ -17,6 +17,13 @@ for (S : REAL_AND_COMPLEX_SCALARS) { + // Check that the class we declare here satisfies the + // vector-space-vector concept. If we catch it here, + // any mistake in the vector class declaration would + // show up in uses of this class later on as well. +#ifdef DEAL_II_HAVE_CXX20 + static_assert(concepts::is_vector_space_vector>); +#endif template class BlockVector; } diff --git a/source/lac/la_parallel_block_vector.inst.in b/source/lac/la_parallel_block_vector.inst.in index 0f3e8f1bf8..cddb19fd82 100644 --- a/source/lac/la_parallel_block_vector.inst.in +++ b/source/lac/la_parallel_block_vector.inst.in @@ -21,7 +21,12 @@ for (SCALAR : REAL_AND_COMPLEX_SCALARS) \{ namespace distributed \{ +#ifdef DEAL_II_HAVE_CXX20 + static_assert(concepts::is_vector_space_vector>); +#endif + template class BlockVector; + template void BlockVector::multivector_inner_product( FullMatrix &, diff --git a/source/lac/la_parallel_vector.inst.in b/source/lac/la_parallel_vector.inst.in index 64032b7ec1..3a8b480310 100644 --- a/source/lac/la_parallel_vector.inst.in +++ b/source/lac/la_parallel_vector.inst.in @@ -21,7 +21,13 @@ for (SCALAR : REAL_AND_COMPLEX_SCALARS) \{ namespace distributed \{ +#ifdef DEAL_II_HAVE_CXX20 + static_assert(concepts::is_vector_space_vector< + Vector>); +#endif + template class Vector; + template void Vector::import_elements< ::dealii::MemorySpace::Host>( diff --git a/source/lac/petsc_parallel_block_vector.cc b/source/lac/petsc_parallel_block_vector.cc index d96544f954..76802b3dad 100644 --- a/source/lac/petsc_parallel_block_vector.cc +++ b/source/lac/petsc_parallel_block_vector.cc @@ -25,6 +25,14 @@ namespace PETScWrappers { namespace MPI { + // Check that the class we declare here satisfies the + // vector-space-vector concept. If we catch it here, + // any mistake in the vector class declaration would + // show up in uses of this class later on as well. +# ifdef DEAL_II_HAVE_CXX20 + static_assert(concepts::is_vector_space_vector); +# endif + using size_type = types::global_dof_index; BlockVector::~BlockVector() diff --git a/source/lac/petsc_parallel_vector.cc b/source/lac/petsc_parallel_vector.cc index a5145b3837..91a40a087e 100644 --- a/source/lac/petsc_parallel_vector.cc +++ b/source/lac/petsc_parallel_vector.cc @@ -28,6 +28,14 @@ namespace PETScWrappers { namespace MPI { + // Check that the class we declare here satisfies the + // vector-space-vector concept. If we catch it here, + // any mistake in the vector class declaration would + // show up in uses of this class later on as well. +# ifdef DEAL_II_HAVE_CXX20 + static_assert(concepts::is_vector_space_vector); +# endif + Vector::Vector() { // virtual functions called in constructors and destructors never use the diff --git a/source/lac/trilinos_epetra_vector.cc b/source/lac/trilinos_epetra_vector.cc index 9a69a287c8..7b179c9392 100644 --- a/source/lac/trilinos_epetra_vector.cc +++ b/source/lac/trilinos_epetra_vector.cc @@ -38,6 +38,14 @@ namespace LinearAlgebra { namespace EpetraWrappers { + // Check that the class we declare here satisfies the + // vector-space-vector concept. If we catch it here, + // any mistake in the vector class declaration would + // show up in uses of this class later on as well. +# ifdef DEAL_II_HAVE_CXX20 + static_assert(concepts::is_vector_space_vector); +# endif + Vector::Vector() : Subscriptor() , vector(new Epetra_FEVector( diff --git a/source/lac/trilinos_tpetra_vector.cc b/source/lac/trilinos_tpetra_vector.cc index 8c5f19d4b0..dc38057124 100644 --- a/source/lac/trilinos_tpetra_vector.cc +++ b/source/lac/trilinos_tpetra_vector.cc @@ -23,17 +23,39 @@ namespace LinearAlgebra { namespace TpetraWrappers { + // Instantiate these vectors types for specific scalar types. + // + // While there: + // Check that the class we declare here satisfies the + // vector-space-vector concept. If we catch it here, + // any mistake in the vector class declaration would + // show up in uses of this class later on as well. + # ifdef HAVE_TPETRA_INST_FLOAT +# ifdef DEAL_II_HAVE_CXX20 + static_assert(concepts::is_vector_space_vector>); +# endif template class Vector; # endif # ifdef HAVE_TPETRA_INST_DOUBLE +# ifdef DEAL_II_HAVE_CXX20 + static_assert(concepts::is_vector_space_vector>); +# endif template class Vector; # endif # ifdef DEAL_II_WITH_COMPLEX_VALUES # ifdef HAVE_TPETRA_INST_COMPLEX_FLOAT +# ifdef DEAL_II_HAVE_CXX20 + static_assert(concepts::is_vector_space_vector < + Vector>); +# endif template class Vector>; # endif # ifdef HAVE_TPETRA_INST_COMPLEX_DOUBLE +# ifdef DEAL_II_HAVE_CXX20 + static_assert(concepts::is_vector_space_vector < + Vector>); +# endif template class Vector>; # endif # endif diff --git a/source/lac/vector.inst.in b/source/lac/vector.inst.in index a9ae3d395e..ac2b2fcaaa 100644 --- a/source/lac/vector.inst.in +++ b/source/lac/vector.inst.in @@ -17,6 +17,14 @@ for (SCALAR : REAL_AND_COMPLEX_SCALARS) { + // Check that the class we declare here satisfies the + // vector-space-vector concept. If we catch it here, + // any mistake in the vector class declaration would + // show up in uses of this class later on as well. +#ifdef DEAL_II_HAVE_CXX20 + static_assert(concepts::is_vector_space_vector>); +#endif + template class Vector; } -- 2.39.5