From: David Wells Date: Tue, 23 Aug 2022 12:29:10 +0000 (-0400) Subject: Update checks for AD-types. X-Git-Tag: v9.5.0-rc1~1006^2~1 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=94476c0bb12f24e4d03428bb49aa0394135e8e88;p=dealii.git Update checks for AD-types. At some point these stopped working and something like #include #include #include int main() { using namespace dealii; Vector vec; } managed to compile (but compiling Vector::l2_norm() fails). In practice we don't support any type here which we cannot call std::abs() on, so lets just switch to a simpler check for these types. --- diff --git a/include/deal.II/lac/full_matrix.h b/include/deal.II/lac/full_matrix.h index 03323f16ba..3a628a558b 100644 --- a/include/deal.II/lac/full_matrix.h +++ b/include/deal.II/lac/full_matrix.h @@ -23,8 +23,6 @@ #include #include -#include - #include #include @@ -80,11 +78,19 @@ template class FullMatrix : public Table<2, number> { public: - // The assertion in full_matrix.templates.h for whether or not a number is - // finite is not compatible for AD number types. + /** + * This class only supports basic numeric types (i.e., we support double and + * float but not automatically differentiated numbers). + * + * @note we test real_type here to get the underlying scalar type when using + * std::complex. + */ static_assert( - !Differentiation::AD::is_ad_number::value, - "The FullMatrix class does not support auto-differentiable numbers."); + std::is_arithmetic< + typename numbers::NumberTraits::real_type>::value, + "The FullMatrix class only supports basic numeric types. In particular, it " + "does not support automatically differentiated numbers."); + /** * A type of used to index into this container. diff --git a/include/deal.II/lac/vector.h b/include/deal.II/lac/vector.h index ee7cfbb37b..2e43459f2a 100644 --- a/include/deal.II/lac/vector.h +++ b/include/deal.II/lac/vector.h @@ -22,10 +22,9 @@ #include #include #include +#include #include -#include - #include #include @@ -109,11 +108,18 @@ template class Vector : public Subscriptor { public: - // The assertion in vector.templates.h for whether or not a number is - // finite is not compatible for AD number types. + /** + * This class only supports basic numeric types (i.e., we support double and + * float but not automatically differentiated numbers). + * + * @note we test real_type here to get the underlying scalar type when using + * std::complex. + */ static_assert( - !Differentiation::AD::is_ad_number::value, - "The Vector class does not support auto-differentiable numbers."); + std::is_arithmetic< + typename numbers::NumberTraits::real_type>::value, + "The Vector class only supports basic numeric types. In particular, it " + "does not support automatically differentiated numbers."); /** * Declare standard types used in all containers. These types parallel those