]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Instantiate ADHelpers classes with AD::NumberTypes::none.
authorJean-Paul Pelteret <jppelteret@gmail.com>
Fri, 10 May 2019 20:35:00 +0000 (22:35 +0200)
committerJean-Paul Pelteret <jppelteret@gmail.com>
Fri, 10 May 2019 20:37:43 +0000 (22:37 +0200)
The creation of a concrete instance of this class is, however, disabled.
This is because the class will not be able to do anything useful.

source/differentiation/ad/CMakeLists.txt
source/differentiation/ad/ad_helpers.cc
source/differentiation/ad/ad_helpers.inst.in [new file with mode: 0644]

index 532ce9d291e3f72c17279bc3848b9c12bf1952dc..c73400db0c3f5414fda31849ba8d27a89a407d9f 100644 (file)
@@ -26,6 +26,7 @@ SET(_inst
   ad_drivers.inst.in
   ad_drivers.inst1.in
   ad_drivers.inst2.in
+  ad_helpers.inst.in
   ad_helpers.inst1.in
   ad_helpers.inst2.in
   adolc_number_types.inst.in
index 948f00ba2f4cbdf67a20e42b12a91aa51df30cad..08d7d1acd2d3a5e5fe287f93d68052cedea9bc84 100644 (file)
@@ -45,6 +45,19 @@ namespace Differentiation
       , registered_marked_independent_variables(n_independent_variables, false)
       , registered_marked_dependent_variables(n_dependent_variables, false)
     {
+      // We have enabled the compilation of this class for arithmetic
+      // types (i.e. ADNumberTypeCode == NumberTypes::none), but we
+      // can't actually do anything with them. Lets not advance any further
+      // and seemingly allow any operations that will not give any
+      // sensible results.
+      Assert(ADNumberTypeCode != NumberTypes::none,
+             ExcMessage(
+               "Floating point/arithmetic numbers have no derivatives."));
+      Assert(
+        AD::ADNumberTraits<ad_type>::n_supported_derivative_levels >= 1,
+        ExcMessage(
+          "The AD number type does not support the calculation of any derivatives."));
+
       // Tapeless mode must be configured before any active live
       // variables are created.
       if (AD::is_tapeless_ad_number<ad_type>::value)
@@ -1878,6 +1891,8 @@ namespace Differentiation
 
 
 /* --- Explicit instantiations --- */
+#  include "ad_helpers.inst"
+
 #  ifdef DEAL_II_WITH_ADOLC
 #    include "ad_helpers.inst1"
 #  endif
diff --git a/source/differentiation/ad/ad_helpers.inst.in b/source/differentiation/ad/ad_helpers.inst.in
new file mode 100644 (file)
index 0000000..2a0aa9d
--- /dev/null
@@ -0,0 +1,71 @@
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 2019 by the deal.II authors
+//
+// This file is part of the deal.II library.
+//
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
+// TODO: Include complex types
+
+for (number : REAL_SCALARS)
+  {
+    namespace Differentiation
+    \{
+      namespace AD
+      \{
+        // -------------------------- HelperBase ----------------------
+
+        template class HelperBase<NumberTypes::none, number>;
+
+        // -------------------------- CellLevelBase ----------------------
+
+        template class CellLevelBase<NumberTypes::none, number>;
+
+        // -------------------------- EnergyFunctional ----------------------
+
+        template class EnergyFunctional<NumberTypes::none, number>;
+
+        // ------------------------ ResidualLinearization --------------------
+
+        template class ResidualLinearization<NumberTypes::none, number>;
+
+      \}
+    \}
+  }
+
+
+for (deal_II_dimension : DIMENSIONS; number : REAL_SCALARS)
+  {
+    namespace Differentiation
+    \{
+      namespace AD
+      \{
+        // ----------------------- PointLevelFunctionsBase -------------------
+
+        template class PointLevelFunctionsBase<deal_II_dimension,
+                                               NumberTypes::none,
+                                               number>;
+
+        // -------------------------- ScalarFunction ----------------------
+
+        template class ScalarFunction<deal_II_dimension,
+                                      NumberTypes::none,
+                                      number>;
+
+        // -------------------------- VectorFunction ----------------------
+
+        template class VectorFunction<deal_II_dimension,
+                                      NumberTypes::none,
+                                      number>;
+
+      \}
+    \}
+  }

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.