From: Jean-Paul Pelteret Date: Thu, 12 Apr 2018 12:43:58 +0000 (+0200) Subject: Add ProductType for Sacado expression templates X-Git-Tag: v9.0.0-rc1~188^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F6230%2Fhead;p=dealii.git Add ProductType for Sacado expression templates --- diff --git a/doc/news/changes/minor/20180412Jean-PaulPelteret b/doc/news/changes/minor/20180412Jean-PaulPelteret new file mode 100644 index 0000000000..270756be0c --- /dev/null +++ b/doc/news/changes/minor/20180412Jean-PaulPelteret @@ -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. +
+(Jean-Paul Pelteret, 2018/04/12) diff --git a/include/deal.II/differentiation/ad/sacado_product_types.h b/include/deal.II/differentiation/ad/sacado_product_types.h index 6295a43f65..406e5ddd67 100644 --- a/include/deal.II/differentiation/ad/sacado_product_types.h +++ b/include/deal.II/differentiation/ad/sacado_product_types.h @@ -83,6 +83,31 @@ namespace internal typedef Sacado::Fad::DFad::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 + struct ProductTypeImpl, U> + { + typedef typename ProductType::value_type,U>::type type; + }; + + template + struct ProductTypeImpl > + { + typedef typename ProductType::value_type>::type type; + }; + + template + struct ProductTypeImpl, Sacado::Fad::Expr > + { + typedef typename ProductType::value_type,typename Sacado::Fad::Expr::value_type>::type type; + }; + } @@ -92,6 +117,12 @@ struct EnableIfScalar > typedef Sacado::Fad::DFad type; }; +template +struct EnableIfScalar > +{ + typedef typename Sacado::Fad::Expr::value_type type; +}; + /* -------------- Sacado::Rad::ADvar (Differentiation::AD::NumberTypes::[sacado_rad/sacado_rad_fad]) -------------- */