From 5668324eefa01da966b6af42e2383e1ecf9da30f Mon Sep 17 00:00:00 2001 From: David Wells Date: Sat, 11 Nov 2023 11:04:48 -0500 Subject: [PATCH] SymmetricTensor: use if constexpr() to get rid of a function. --- include/deal.II/base/symmetric_tensor.h | 39 +++++-------------------- 1 file changed, 8 insertions(+), 31 deletions(-) diff --git a/include/deal.II/base/symmetric_tensor.h b/include/deal.II/base/symmetric_tensor.h index fa61cdf567..89ad3b399a 100644 --- a/include/deal.II/base/symmetric_tensor.h +++ b/include/deal.II/base/symmetric_tensor.h @@ -2333,41 +2333,16 @@ SymmetricTensor::end_raw() const -namespace internal -{ - namespace SymmetricTensorImplementation - { - template - constexpr unsigned int - entry_to_indices(const dealii::SymmetricTensor<2, dim, Number> &, - const unsigned int index) - { - return index; - } - - - template - constexpr dealii::TableIndices<2> - entry_to_indices(const dealii::SymmetricTensor<4, dim, Number> &, - const unsigned int index) - { - return internal::SymmetricTensorAccessors::StorageType<4, dim, Number>:: - base_tensor_type::unrolled_to_component_indices(index); - } - - } // namespace SymmetricTensorImplementation -} // namespace internal - - - template DEAL_II_HOST constexpr inline const Number & SymmetricTensor::access_raw_entry( const unsigned int index) const { AssertIndexRange(index, n_independent_components); - return data[internal::SymmetricTensorImplementation::entry_to_indices(*this, - index)]; + if constexpr (rank == 2) + return data[index]; + else + return data[decltype(data)::unrolled_to_component_indices(index)]; } @@ -2377,8 +2352,10 @@ DEAL_II_HOST constexpr inline Number & SymmetricTensor::access_raw_entry(const unsigned int index) { AssertIndexRange(index, n_independent_components); - return data[internal::SymmetricTensorImplementation::entry_to_indices(*this, - index)]; + if constexpr (rank == 2) + return data[index]; + else + return data[decltype(data)::unrolled_to_component_indices(index)]; } -- 2.39.5