From 67968eaab8e24f9ea4249577030ef43f9c92da72 Mon Sep 17 00:00:00 2001 From: Jean-Paul Pelteret Date: Fri, 3 Nov 2017 19:56:01 +0100 Subject: [PATCH] Add support and implement ProductType for Trilinos Sacado::Rad numbers --- cmake/configure/configure_2_trilinos.cmake | 6 +- .../differentiation/ad/sacado_product_types.h | 139 +++++++++++++++++- 2 files changed, 142 insertions(+), 3 deletions(-) diff --git a/cmake/configure/configure_2_trilinos.cmake b/cmake/configure/configure_2_trilinos.cmake index f409ba96d2..5c252d69a5 100644 --- a/cmake/configure/configure_2_trilinos.cmake +++ b/cmake/configure/configure_2_trilinos.cmake @@ -198,7 +198,11 @@ MACRO(FEATURE_TRILINOS_CONFIGURE_EXTERNAL) "Sacado::Fad::DFad" "Sacado::Fad::DFad" "Sacado::Fad::DFad>" - "Sacado::Fad::DFad>") + "Sacado::Fad::DFad>" + "Sacado::Rad::ADvar" + "Sacado::Rad::ADvar" + "Sacado::Rad::ADvar>" + "Sacado::Rad::ADvar>") IF (TRILINOS_WITH_MPI) SET(DEAL_II_EXPAND_EPETRA_VECTOR "LinearAlgebra::EpetraWrappers::Vector") diff --git a/include/deal.II/differentiation/ad/sacado_product_types.h b/include/deal.II/differentiation/ad/sacado_product_types.h index 0ff6ce32fc..f5b0cf8d5f 100644 --- a/include/deal.II/differentiation/ad/sacado_product_types.h +++ b/include/deal.II/differentiation/ad/sacado_product_types.h @@ -1,6 +1,6 @@ // --------------------------------------------------------------------- // -// Copyright (C) 2015 by the deal.II authors +// Copyright (C) 2015, 2017 by the deal.II authors // // This file is part of the deal.II library. // @@ -25,10 +25,21 @@ DEAL_II_DISABLE_EXTRA_DIAGNOSTICS # include +// It appears that some versions of Trilinos do not directly or indirectly +// include all the headers for all forward and reverse Sacado AD types. +// So we directly include these both here as a precaution. +// Standard forward AD classes (templated) +# include +// Reverse AD classes (templated) +# include DEAL_II_ENABLE_EXTRA_DIAGNOSTICS DEAL_II_NAMESPACE_OPEN + +/* -------------- Sacado::Fad::DFad (Differentiation::AD::NumberTypes::[sacado_fad/sacado_fad_fad]) -------------- */ + + namespace internal { @@ -71,11 +82,12 @@ namespace internal template struct ProductTypeImpl, Sacado::Fad::DFad > { - typedef Sacado::Fad::DFad::type > type; + typedef Sacado::Fad::DFad::type> type; }; } + template struct EnableIfScalar > { @@ -83,6 +95,129 @@ struct EnableIfScalar > }; +/* -------------- Sacado::Rad::ADvar (Differentiation::AD::NumberTypes::[sacado_rad/sacado_rad_fad]) -------------- */ + + +namespace internal +{ + + template + struct ProductTypeImpl, float> + { + typedef Sacado::Rad::ADvar type; + }; + + template + struct ProductTypeImpl > + { + typedef Sacado::Rad::ADvar type; + }; + + template + struct ProductTypeImpl, double> + { + typedef Sacado::Rad::ADvar type; + }; + + template + struct ProductTypeImpl > + { + typedef Sacado::Rad::ADvar type; + }; + + template + struct ProductTypeImpl, int> + { + typedef Sacado::Rad::ADvar type; + }; + + template + struct ProductTypeImpl > + { + typedef Sacado::Rad::ADvar type; + }; + + template + struct ProductTypeImpl, Sacado::Rad::ADvar > + { + typedef Sacado::Rad::ADvar::type> type; + }; + + /* --- Sacado::Rad::ADvar: Temporary type --- */ + + template + struct ProductTypeImpl, float> + { + typedef Sacado::Rad::ADvari type; + }; + + template + struct ProductTypeImpl > + { + typedef Sacado::Rad::ADvari type; + }; + + template + struct ProductTypeImpl, double> + { + typedef Sacado::Rad::ADvari type; + }; + + template + struct ProductTypeImpl > + { + typedef Sacado::Rad::ADvari type; + }; + + template + struct ProductTypeImpl, int> + { + typedef Sacado::Rad::ADvari type; + }; + + template + struct ProductTypeImpl > + { + typedef Sacado::Rad::ADvari type; + }; + + template + struct ProductTypeImpl, Sacado::Rad::ADvari > + { + typedef Sacado::Rad::ADvari::type> type; + }; + + /* --- Sacado::Rad::ADvar: Main and temporary type --- */ + + template + struct ProductTypeImpl, Sacado::Rad::ADvari > + { + typedef Sacado::Rad::ADvar::type> type; + }; + + template + struct ProductTypeImpl, Sacado::Rad::ADvar > + { + typedef Sacado::Rad::ADvar::type> type; + }; + +} + + +template +struct EnableIfScalar > +{ + typedef Sacado::Rad::ADvar type; +}; + + +template +struct EnableIfScalar > +{ + typedef Sacado::Rad::ADvari type; +}; + + /** * Compute the scalar product $a:b=\sum_{i,j} a_{ij}b_{ij}$ between two -- 2.39.5