From cdab73a14e77eb7322996f1cd17bcdd75cb0251b Mon Sep 17 00:00:00 2001 From: Daniel Arndt Date: Fri, 2 Aug 2019 16:10:31 -0400 Subject: [PATCH] Cleanup workarounds for VectorizedArray --- include/deal.II/base/numbers.h | 15 ++---- include/deal.II/base/tensor.h | 42 +-------------- include/deal.II/base/vectorization.h | 77 +++++----------------------- 3 files changed, 19 insertions(+), 115 deletions(-) diff --git a/include/deal.II/base/numbers.h b/include/deal.II/base/numbers.h index 10b41a36b0..e264687af3 100644 --- a/include/deal.II/base/numbers.h +++ b/include/deal.II/base/numbers.h @@ -708,18 +708,9 @@ namespace internal static bool const value = test(0); }; - /** - * The structs below are needed since VectorizedArray is a POD-type - * without a constructor and can be a template argument for - * SymmetricTensor<...,T2> where T2 would equal VectorizedArray. - * Internally, in previous versions of deal.II, SymmetricTensor<...,T2> would - * make use of the constructor of T2 leading to a compile-time error. However - * simply adding a constructor for VectorizedArray breaks the POD-idioms - * needed elsewhere. Calls to constructors of T2 subsequently got replaced by - * a call to internal::NumberType which then determines the right function - * to use by template deduction. A detailed discussion can be found at - * https://github.com/dealii/dealii/pull/3967 . Also see numbers.h for another - * specialization. + /* + * The structs below are needed to convert between some special number types. + * Also see tensor.h for another specialization. */ template struct NumberType diff --git a/include/deal.II/base/tensor.h b/include/deal.II/base/tensor.h index c2fd168fcb..90fc129269 100644 --- a/include/deal.II/base/tensor.h +++ b/include/deal.II/base/tensor.h @@ -743,17 +743,8 @@ private: namespace internal { /** - * The structs below are needed since VectorizedArray is a POD-type - * without a constructor and can be a template argument for Tensor<...,T2> - * where T2 would equal Tensor<1, dim, VectorizedArray >. Internally, in - * previous versions of deal.II, Tensor<...,T2> would make use of the - * constructor of T2 leading to a compile-time error. However simply adding a - * constructor for VectorizedArray breaks the POD-idioms needed elsewhere. - * Calls to constructors of T2 subsequently got replaced by a call to - * internal::NumberType which then determines the right function to use by - * template deduction. A detailed discussion can be found at - * https://github.com/dealii/dealii/pull/3967 . Also see numbers.h for another - * specialization. + * The structs below are needed to initialize nested Tensor objects. + * Also see numbers.h for another specialization. */ template struct NumberType> @@ -772,35 +763,6 @@ namespace internal return tmp; } }; - - template - struct NumberType>> - { - static constexpr DEAL_II_ALWAYS_INLINE const - Tensor> & - value(const Tensor> &t) - { - return t; - } - - static DEAL_II_CONSTEXPR - DEAL_II_ALWAYS_INLINE Tensor> - value(const T &t) - { - Tensor> tmp; - tmp = internal::NumberType>::value(t); - return tmp; - } - - static DEAL_II_CONSTEXPR - DEAL_II_ALWAYS_INLINE Tensor> - value(const VectorizedArray &t) - { - Tensor> tmp; - tmp = t; - return tmp; - } - }; } // namespace internal diff --git a/include/deal.II/base/vectorization.h b/include/deal.II/base/vectorization.h index a795d955d8..51a0ffb657 100644 --- a/include/deal.II/base/vectorization.h +++ b/include/deal.II/base/vectorization.h @@ -73,41 +73,6 @@ DEAL_II_NAMESPACE_OPEN -namespace internal -{ - /** - * The structs below are needed since VectorizedArray is a POD-type - * without a constructor and can be a template argument for - * SymmetricTensor<...,T2> where T2 would equal VectorizedArray. - * Internally, in previous versions of deal.II, SymmetricTensor<...,T2> would - * make use of the constructor of T2 leading to a compile-time error. However - * simply adding a constructor for VectorizedArray breaks the POD-idioms - * needed elsewhere. Calls to constructors of T2 subsequently got replaced by - * a call to internal::NumberType which then determines the right function - * to use by template deduction. A detailed discussion can be found at - * https://github.com/dealii/dealii/pull/3967 . Also see numbers.h for other - * specializations. - */ - template - struct NumberType> - { - static const VectorizedArray & - value(const VectorizedArray &t) - { - return t; - } - - static VectorizedArray - value(const T &t) - { - VectorizedArray tmp; - tmp = t; - return tmp; - } - }; -} // namespace internal - - // Enable the EnableIfScalar type trait for VectorizedArray such // that it can be used as a Number type in Tensor, etc. @@ -526,8 +491,7 @@ template < inline DEAL_II_ALWAYS_INLINE VectorizedArray make_vectorized_array(const Number &u) { - VectorizedArray result; - result = u; + VectorizedArray result = u; return result; } @@ -549,8 +513,7 @@ inline DEAL_II_ALWAYS_INLINE VectorizedArrayType VectorizedArrayType::n_array_elements>>::value, "VectorizedArrayType is not a VectorizedArray."); - VectorizedArrayType result; - result = u; + VectorizedArrayType result = u; return result; } @@ -3703,8 +3666,7 @@ template inline DEAL_II_ALWAYS_INLINE VectorizedArray operator+(const Number &u, const VectorizedArray &v) { - VectorizedArray tmp; - tmp = u; + VectorizedArray tmp = u; return tmp += v; } @@ -3720,8 +3682,7 @@ template inline DEAL_II_ALWAYS_INLINE VectorizedArray operator+(const double u, const VectorizedArray &v) { - VectorizedArray tmp; - tmp = u; + VectorizedArray tmp = u; return tmp += v; } @@ -3763,8 +3724,7 @@ template inline DEAL_II_ALWAYS_INLINE VectorizedArray operator-(const Number &u, const VectorizedArray &v) { - VectorizedArray tmp; - tmp = u; + VectorizedArray tmp = u; return tmp -= v; } @@ -3780,8 +3740,7 @@ template inline DEAL_II_ALWAYS_INLINE VectorizedArray operator-(const double u, const VectorizedArray &v) { - VectorizedArray tmp; - tmp = float(u); + VectorizedArray tmp = static_cast(u); return tmp -= v; } @@ -3795,8 +3754,7 @@ template inline DEAL_II_ALWAYS_INLINE VectorizedArray operator-(const VectorizedArray &v, const Number &u) { - VectorizedArray tmp; - tmp = u; + VectorizedArray tmp = u; return v - tmp; } @@ -3812,8 +3770,7 @@ template inline DEAL_II_ALWAYS_INLINE VectorizedArray operator-(const VectorizedArray &v, const double u) { - VectorizedArray tmp; - tmp = float(u); + VectorizedArray tmp = static_cast(u); return v - tmp; } @@ -3827,8 +3784,7 @@ template inline DEAL_II_ALWAYS_INLINE VectorizedArray operator*(const Number &u, const VectorizedArray &v) { - VectorizedArray tmp; - tmp = u; + VectorizedArray tmp = u; return tmp *= v; } @@ -3844,8 +3800,7 @@ template inline DEAL_II_ALWAYS_INLINE VectorizedArray operator*(const double u, const VectorizedArray &v) { - VectorizedArray tmp; - tmp = float(u); + VectorizedArray tmp = static_cast(u); return tmp *= v; } @@ -3887,8 +3842,7 @@ template inline DEAL_II_ALWAYS_INLINE VectorizedArray operator/(const Number &u, const VectorizedArray &v) { - VectorizedArray tmp; - tmp = u; + VectorizedArray tmp = u; return tmp /= v; } @@ -3904,8 +3858,7 @@ template inline DEAL_II_ALWAYS_INLINE VectorizedArray operator/(const double u, const VectorizedArray &v) { - VectorizedArray tmp; - tmp = float(u); + VectorizedArray tmp = static_cast(u); return tmp /= v; } @@ -3919,8 +3872,7 @@ template inline DEAL_II_ALWAYS_INLINE VectorizedArray operator/(const VectorizedArray &v, const Number &u) { - VectorizedArray tmp; - tmp = u; + VectorizedArray tmp = u; return v / tmp; } @@ -3936,8 +3888,7 @@ template inline DEAL_II_ALWAYS_INLINE VectorizedArray operator/(const VectorizedArray &v, const double u) { - VectorizedArray tmp; - tmp = float(u); + VectorizedArray tmp = static_cast(u); return v / tmp; } -- 2.39.5