From: Wolfgang Bangerth Date: Mon, 3 Jul 2023 21:59:20 +0000 (-0600) Subject: Create a vector space vector concept. X-Git-Tag: relicensing~752^2~1 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0de3ebf515ffe466b1cd7334d0a2063911128464;p=dealii.git Create a vector space vector concept. --- diff --git a/include/deal.II/base/template_constraints.h b/include/deal.II/base/template_constraints.h index d298064240..0b60c5e96a 100644 --- a/include/deal.II/base/template_constraints.h +++ b/include/deal.II/base/template_constraints.h @@ -977,7 +977,97 @@ namespace concepts template concept is_triangulation_or_dof_handler = internal::is_triangulation_or_dof_handler; + + /** + * A concept that tests whether a class `VectorType` has the required + * interface to serve as a vector in vector-space operations -- principally + * what is required to run iterative solvers: things such as norms, dot + * products, etc. + */ + template + concept is_vector_space_vector = requires(VectorType U, + VectorType V, + VectorType W, + typename VectorType::value_type a, + typename VectorType::value_type b, + typename VectorType::value_type s) + { + // Check local type requirements: + typename VectorType::value_type; + typename VectorType::size_type; + typename VectorType::real_type; + + // Check some assignment and reinit operations; + U.reinit(V); + U.reinit(V, /* omit_zeroing_entries= */ true); + + U = V; + U = a; // assignment of scalar + + U.equ(a, V); + + // Check scaling operations + U *= a; + U /= a; + + U.scale(V); + + // Vector additions: + U += V; + U -= V; + + U.add(a); + U.add(a, V); + U.add(a, V, b, W); + + U.sadd(s, a, V); + + // Norms and similar stuff: + { + U.mean_value() + } + ->std::convertible_to; + + { + U.l1_norm() + } + ->std::convertible_to; + + { + U.l2_norm() + } + ->std::convertible_to; + + { + U.linfty_norm() + } + ->std::convertible_to; + + // Dot products: + { + U *V + } + ->std::convertible_to; + + { + U.add_and_dot(a, V, W) + } + ->std::convertible_to; + + // Some queries: + { + U.size() + } + ->std::convertible_to; + + { + U.all_zero() + } + ->std::same_as; + }; + #endif + } // namespace concepts