]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Add ProductType for Sacado expression templates 6230/head
authorJean-Paul Pelteret <jppelteret@gmail.com>
Thu, 12 Apr 2018 12:43:58 +0000 (14:43 +0200)
committerJean-Paul Pelteret <jppelteret@gmail.com>
Thu, 12 Apr 2018 16:43:11 +0000 (18:43 +0200)
doc/news/changes/minor/20180412Jean-PaulPelteret [new file with mode: 0644]
include/deal.II/differentiation/ad/sacado_product_types.h

diff --git a/doc/news/changes/minor/20180412Jean-PaulPelteret b/doc/news/changes/minor/20180412Jean-PaulPelteret
new file mode 100644 (file)
index 0000000..270756b
--- /dev/null
@@ -0,0 +1,5 @@
+Fixed: Some compile-times errors would previously appear for some arithmetic functions
+when using Sacado::Fad::DFad types (e.g. Physics::Elasticity::Kinematics::F_iso() ). 
+By defining the ProductType Sacado expression templates, this issue is now avoided.
+<br>
+(Jean-Paul Pelteret, 2018/04/12)
index 6295a43f654bbd1be876d65c889d26a1bbcef3f6..406e5ddd67b511c75c389bdeab5f5f0f06d328fa 100644 (file)
@@ -83,6 +83,31 @@ namespace internal
     typedef Sacado::Fad::DFad<typename ProductType<T,U>::type> type;
   };
 
+
+  // Sacado::Fad::Dfad expression templates
+  // We demote the result of the expression template operations
+  // to a Sacado::Fad::Dfad itself. This is the only way to retain
+  // consistency between the number type going into a complex chain of
+  // (potentially branching) operations and that coming out of them.
+
+  template <typename T, typename U>
+  struct ProductTypeImpl<Sacado::Fad::Expr<T>, U>
+  {
+    typedef typename ProductType<typename Sacado::Fad::Expr<T>::value_type,U>::type type;
+  };
+
+  template <typename T, typename U>
+  struct ProductTypeImpl<T, Sacado::Fad::Expr<U> >
+  {
+    typedef typename ProductType<T,typename Sacado::Fad::Expr<U>::value_type>::type type;
+  };
+
+  template <typename T, typename U>
+  struct ProductTypeImpl<Sacado::Fad::Expr<T>, Sacado::Fad::Expr<U> >
+  {
+    typedef typename ProductType<typename Sacado::Fad::Expr<T>::value_type,typename Sacado::Fad::Expr<U>::value_type>::type type;
+  };
+
 }
 
 
@@ -92,6 +117,12 @@ struct EnableIfScalar<Sacado::Fad::DFad<T> >
   typedef Sacado::Fad::DFad<T> type;
 };
 
+template <typename T>
+struct EnableIfScalar<Sacado::Fad::Expr<T> >
+{
+  typedef typename Sacado::Fad::Expr<T>::value_type type;
+};
+
 
 /* -------------- Sacado::Rad::ADvar (Differentiation::AD::NumberTypes::[sacado_rad/sacado_rad_fad]) -------------- */
 

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.