]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Add some specialized functions to Adol-C numbers
authorJean-Paul Pelteret <jppelteret@gmail.com>
Sun, 29 Apr 2018 09:17:58 +0000 (11:17 +0200)
committerJean-Paul Pelteret <jppelteret@gmail.com>
Sun, 29 Apr 2018 10:05:27 +0000 (12:05 +0200)
include/deal.II/base/tensor.h

index 2a16e8657b457114016ca94c817d46a4bc9bbb06..e53971427ceff0286dc96a08598ad05443d3c1e8 100644 (file)
 #include <deal.II/base/template_constraints.h>
 #include <deal.II/base/utilities.h>
 
+#ifdef DEAL_II_WITH_ADOLC
+#include <adolc/adouble.h> // Taped double
+#endif
+
 #include <cmath>
 #include <ostream>
 #include <vector>
@@ -2257,6 +2261,56 @@ linfty_norm (const Tensor<2,dim,Number> &t)
 
 //@}
 
+
+#ifndef DOXYGEN
+
+
+#ifdef DEAL_II_ADOLC_WITH_ADVANCED_BRANCHING
+
+// Specialization of functions for Adol-C number types when
+// the advanced branching feature is used
+template <int dim>
+inline
+adouble
+l1_norm (const Tensor<2,dim,adouble> &t)
+{
+  adouble max = internal::NumberType<adouble>::value(0.0);
+  for (unsigned int j=0; j<dim; ++j)
+    {
+      adouble sum = internal::NumberType<adouble>::value(0.0);
+      for (unsigned int i=0; i<dim; ++i)
+        sum += std::fabs(t[i][j]);
+
+      condassign(max, (sum > max), sum, max);
+    }
+
+  return max;
+}
+
+
+template <int dim>
+inline
+adouble
+linfty_norm (const Tensor<2,dim,adouble> &t)
+{
+  adouble max = internal::NumberType<adouble>::value(0.0);
+  for (unsigned int i=0; i<dim; ++i)
+    {
+      adouble sum = internal::NumberType<adouble>::value(0.0);
+      for (unsigned int j=0; j<dim; ++j)
+        sum += std::fabs(t[i][j]);
+
+      condassign(max, (sum > max), sum, max);
+    }
+
+  return max;
+}
+
+#endif // DEAL_II_ADOLC_WITH_ADVANCED_BRANCHING
+
+
+#endif // DOXYGEN
+
 DEAL_II_NAMESPACE_CLOSE
 
 // include deprecated non-member functions operating on Tensor

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.