]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Update checks for AD-types.
authorDavid Wells <drwells@email.unc.edu>
Tue, 23 Aug 2022 12:29:10 +0000 (08:29 -0400)
committerDavid Wells <drwells@email.unc.edu>
Mon, 29 Aug 2022 17:49:25 +0000 (13:49 -0400)
At some point these stopped working and something like

#include <deal.II/lac/vector.h>
#include <deal.II/lac/vector.templates.h>

#include <adolc/adouble.h>

int
main()
{
  using namespace dealii;

  Vector<adouble> vec;
}

managed to compile (but compiling Vector<adouble>::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.

include/deal.II/lac/full_matrix.h
include/deal.II/lac/vector.h

index 03323f16ba7cbe245d4cfad3fd7c3d72b97d2979..3a628a558b0210ccba0c4691d9154fed3dd896a5 100644 (file)
@@ -23,8 +23,6 @@
 #include <deal.II/base/table.h>
 #include <deal.II/base/tensor.h>
 
-#include <deal.II/differentiation/ad/ad_number_traits.h>
-
 #include <deal.II/lac/exceptions.h>
 #include <deal.II/lac/identity_matrix.h>
 
@@ -80,11 +78,19 @@ template <typename number>
 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<number>::value,
-    "The FullMatrix class does not support auto-differentiable numbers.");
+    std::is_arithmetic<
+      typename numbers::NumberTraits<number>::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.
index ee7cfbb37bb891446a2e4606fad846d21fe4d3b0..2e43459f2a4fe96f4cf59e54aae8956fa6f5a88f 100644 (file)
 #include <deal.II/base/aligned_vector.h>
 #include <deal.II/base/exceptions.h>
 #include <deal.II/base/index_set.h>
+#include <deal.II/base/numbers.h>
 #include <deal.II/base/subscriptor.h>
 
-#include <deal.II/differentiation/ad/ad_number_traits.h>
-
 #include <deal.II/lac/vector_operation.h>
 #include <deal.II/lac/vector_type_traits.h>
 
@@ -109,11 +108,18 @@ template <typename Number>
 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<Number>::value,
-    "The Vector class does not support auto-differentiable numbers.");
+    std::is_arithmetic<
+      typename numbers::NumberTraits<Number>::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

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.