From 5a1971dee43620b19580b7911b9f6495be53cd05 Mon Sep 17 00:00:00 2001 From: Daniel Arndt Date: Mon, 18 Nov 2019 22:38:51 -0500 Subject: [PATCH] Fix ADOL-C warnings --- .../deal.II/base/symmetric_tensor.templates.h | 74 ---------- source/base/symmetric_tensor.cc | 139 ++++++++++++++++++ source/base/symmetric_tensor.inst.in | 8 - 3 files changed, 139 insertions(+), 82 deletions(-) diff --git a/include/deal.II/base/symmetric_tensor.templates.h b/include/deal.II/base/symmetric_tensor.templates.h index 64c1886d26..8658673329 100644 --- a/include/deal.II/base/symmetric_tensor.templates.h +++ b/include/deal.II/base/symmetric_tensor.templates.h @@ -1001,80 +1001,6 @@ eigenvectors(const SymmetricTensor<2, dim, Number> &T, -#ifdef DEAL_II_ADOLC_WITH_ADVANCED_BRANCHING - -// Specializations of the above functions for taped ADOL-C numbers -// when the advanced branching feature is activated. -// We could copy-paste all of these functions and add the appropriate -// conditional assignments (see the ADOL-C manual, section 1.8). -// However, some of the conditions are quite complicated (with possibly -// no 1-1 correspondence for the operations along each branch) so this -// needs some careful attention. For the sake of simplicity and until -// this can be rigourously checked, at this point in time we simply -// disable these functions. - -namespace internal -{ - namespace SymmetricTensorImplementation - { - template <> - struct Inverse<4, 3, adouble> - { - static dealii::SymmetricTensor<4, 3, adouble> - value(const dealii::SymmetricTensor<4, 3, adouble> & /*t*/) - { - AssertThrow(false, ExcADOLCAdvancedBranching()); - return dealii::SymmetricTensor<4, 3, adouble>(); - } - }; - } // namespace SymmetricTensorImplementation -} // namespace internal - -template <> -std::array -eigenvalues(const SymmetricTensor<2, 1, adouble> & /*T*/) -{ - AssertThrow(false, ExcADOLCAdvancedBranching()); - return std::array(); -} - - - -template <> -std::array -eigenvalues(const SymmetricTensor<2, 2, adouble> & /*T*/) -{ - AssertThrow(false, ExcADOLCAdvancedBranching()); - return std::array(); -} - - - -template <> -std::array -eigenvalues(const SymmetricTensor<2, 3, adouble> & /*T*/) -{ - AssertThrow(false, ExcADOLCAdvancedBranching()); - return std::array(); -} - - - -template -std::array>, - std::integral_constant::value> -eigenvectors(const SymmetricTensor<2, dim, adouble> & /*T*/, - const SymmetricTensorEigenvectorMethod /*method*/) -{ - AssertThrow(false, ExcADOLCAdvancedBranching()); - return std::array>, - std::integral_constant::value>(); -} - -#endif - - - DEAL_II_NAMESPACE_CLOSE #endif diff --git a/source/base/symmetric_tensor.cc b/source/base/symmetric_tensor.cc index ac98f1d475..e0995d383e 100644 --- a/source/base/symmetric_tensor.cc +++ b/source/base/symmetric_tensor.cc @@ -23,6 +23,145 @@ #include DEAL_II_NAMESPACE_OPEN +#ifdef DEAL_II_WITH_ADOLC +# ifdef DEAL_II_ADOLC_WITH_ADVANCED_BRANCHING + +// Specializations of the above functions for taped ADOL-C numbers +// when the advanced branching feature is activated. +// We could copy-paste all of these functions and add the appropriate +// conditional assignments (see the ADOL-C manual, section 1.8). +// However, some of the conditions are quite complicated (with possibly +// no 1-1 correspondence for the operations along each branch) so this +// needs some careful attention. For the sake of simplicity and until +// this can be rigourously checked, at this point in time we simply +// disable these functions. +namespace internal +{ + namespace SymmetricTensorImplementation + { + template <> + struct Inverse<4, 3, adouble> + { + static dealii::SymmetricTensor<4, 3, adouble> + value(const dealii::SymmetricTensor<4, 3, adouble> & /*t*/) + { + AssertThrow(false, ExcADOLCAdvancedBranching()); + return dealii::SymmetricTensor<4, 3, adouble>(); + } + }; + } // namespace SymmetricTensorImplementation +} // namespace internal + +template <> +std::array +eigenvalues(const SymmetricTensor<2, 1, adouble> & /*T*/) +{ + AssertThrow(false, ExcADOLCAdvancedBranching()); + return std::array(); +} + + + +template <> +std::array +eigenvalues(const SymmetricTensor<2, 2, adouble> & /*T*/) +{ + AssertThrow(false, ExcADOLCAdvancedBranching()); + return std::array(); +} + + + +template <> +std::array +eigenvalues(const SymmetricTensor<2, 3, adouble> & /*T*/) +{ + AssertThrow(false, ExcADOLCAdvancedBranching()); + return std::array(); +} + + + +template <> +std::array>, 1> +eigenvectors(const SymmetricTensor<2, 1, adouble> & /*T*/, + const SymmetricTensorEigenvectorMethod /*method*/) +{ + AssertThrow(false, ExcADOLCAdvancedBranching()); + return std::array>, 1>(); +} + + + +template <> +std::array>, 2> +eigenvectors(const SymmetricTensor<2, 2, adouble> & /*T*/, + const SymmetricTensorEigenvectorMethod /*method*/) +{ + AssertThrow(false, ExcADOLCAdvancedBranching()); + return std::array>, 2>(); +} + + + +template <> +std::array>, 3> +eigenvectors(const SymmetricTensor<2, 3, adouble> & /*T*/, + const SymmetricTensorEigenvectorMethod /*method*/) +{ + AssertThrow(false, ExcADOLCAdvancedBranching()); + return std::array>, 3>(); +} +# else +template std::array +eigenvalues(const SymmetricTensor<2, 1, adouble> &); + +template std::array +eigenvalues(const SymmetricTensor<2, 2, adouble> &); + +template std::array +eigenvalues(const SymmetricTensor<2, 3, adouble> &); + +template <> +std::array>, 1> +eigenvectors(const SymmetricTensor<2, 1, adouble> &, + const SymmetricTensorEigenvectorMethod); + +template <> +std::array>, 2> +eigenvectors(const SymmetricTensor<2, 2, adouble> &, + const SymmetricTensorEigenvectorMethod); + +template <> +std::array>, 3> +eigenvectors(const SymmetricTensor<2, 3, adouble> &, + const SymmetricTensorEigenvectorMethod); +# endif + +template std::array +eigenvalues(const SymmetricTensor<2, 1, adtl::adouble> &); + +template std::array +eigenvalues(const SymmetricTensor<2, 2, adtl::adouble> &); + +template std::array +eigenvalues(const SymmetricTensor<2, 3, adtl::adouble> &); + +template <> +std::array>, 1> +eigenvectors(const SymmetricTensor<2, 1, adtl::adouble> &, + const SymmetricTensorEigenvectorMethod); + +template <> +std::array>, 2> +eigenvectors(const SymmetricTensor<2, 2, adtl::adouble> &, + const SymmetricTensorEigenvectorMethod); + +template <> +std::array>, 3> +eigenvectors(const SymmetricTensor<2, 3, adtl::adouble> &, + const SymmetricTensorEigenvectorMethod); +#endif // explicit instantiations #include "symmetric_tensor.inst" diff --git a/source/base/symmetric_tensor.inst.in b/source/base/symmetric_tensor.inst.in index 1729ec17b0..1f4a580d1f 100644 --- a/source/base/symmetric_tensor.inst.in +++ b/source/base/symmetric_tensor.inst.in @@ -34,14 +34,6 @@ for (deal_II_dimension : DIMENSIONS; number : DIFFERENTIABLE_ADOLC_REAL_SCALARS) template class SymmetricTensor<2, deal_II_dimension, number>; template class SymmetricTensor<4, deal_II_dimension, number>; - - template std::array eigenvalues( - const SymmetricTensor<2, deal_II_dimension, number> &); - - template std::array>, - std::integral_constant::value> - eigenvectors(const SymmetricTensor<2, deal_II_dimension, number> &, - const SymmetricTensorEigenvectorMethod); } for (deal_II_dimension : DIMENSIONS; -- 2.39.5