From 53bb61892b7e689df10a518f2509e5b282ef3a87 Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Tue, 26 Mar 2024 17:23:06 -0600 Subject: [PATCH] Remove/deprecate Tensor::begin/end_raw(). --- include/deal.II/base/array_view.h | 10 ++ include/deal.II/base/tensor.h | 108 +++++---------------- include/deal.II/grid/grid_tools_geometry.h | 2 + 3 files changed, 36 insertions(+), 84 deletions(-) diff --git a/include/deal.II/base/array_view.h b/include/deal.II/base/array_view.h index 3b553c78dc..8b020af5da 100644 --- a/include/deal.II/base/array_view.h +++ b/include/deal.II/base/array_view.h @@ -1055,6 +1055,11 @@ template DEAL_II_DEPRECATED inline ArrayView make_array_view(const Tensor &tensor) { + static_assert(rank == 1, + "This function is only available for rank-1 tensors " + "because higher-rank tensors may not store their elements " + "in a contiguous array."); + return make_array_view(tensor.begin_raw(), tensor.end_raw()); } @@ -1085,6 +1090,11 @@ template DEAL_II_DEPRECATED inline ArrayView make_array_view(Tensor &tensor) { + static_assert(rank == 1, + "This function is only available for rank-1 tensors " + "because higher-rank tensors may not store their elements " + "in a contiguous array."); + return make_array_view(tensor.begin_raw(), tensor.end_raw()); } diff --git a/include/deal.II/base/tensor.h b/include/deal.II/base/tensor.h index 5548dc4807..79de40fb95 100644 --- a/include/deal.II/base/tensor.h +++ b/include/deal.II/base/tensor.h @@ -191,55 +191,6 @@ public: Tensor(Tensor<0, dim, Number> &&other) noexcept; #endif - /** - * Return a pointer to the first element of the underlying storage. - * - * @deprecated This function suggests that the elements of a Tensor - * object are stored as a contiguous array, but this is not in fact true - * and one should not pretend that this so. As a consequence, this function - * is deprecated. - */ - DEAL_II_DEPRECATED - Number * - begin_raw(); - - /** - * Return a const pointer to the first element of the underlying storage. - * - * @deprecated This function suggests that the elements of a Tensor - * object are stored as a contiguous array, but this is not in fact true - * and one should not pretend that this so. As a consequence, this function - * is deprecated. - */ - DEAL_II_DEPRECATED - const Number * - begin_raw() const; - - /** - * Return a pointer to the element past the end of the underlying storage. - * - * @deprecated This function suggests that the elements of a Tensor - * object are stored as a contiguous array, but this is not in fact true - * and one should not pretend that this so. As a consequence, this function - * is deprecated. - */ - DEAL_II_DEPRECATED - Number * - end_raw(); - - /** - * Return a const pointer to the element past the end of the underlying - * storage. - * - * @deprecated This function suggests that the elements of a Tensor - * object are stored as a contiguous array, but this is not in fact true - * and one should not pretend that this so. As a consequence, this function - * is deprecated. - */ - DEAL_II_DEPRECATED - const Number * - end_raw() const; - /** * Return a reference to the encapsulated Number object. Since rank-0 * tensors are scalars, this is a natural operation. @@ -668,24 +619,28 @@ public: /** * Return a pointer to the first element of the underlying storage. */ + DEAL_II_DEPRECATED_EARLY Number * begin_raw(); /** * Return a const pointer to the first element of the underlying storage. */ + DEAL_II_DEPRECATED_EARLY const Number * begin_raw() const; /** * Return a pointer to the element past the end of the underlying storage. */ + DEAL_II_DEPRECATED_EARLY Number * end_raw(); /** * Return a pointer to the element past the end of the underlying storage. */ + DEAL_II_DEPRECATED_EARLY const Number * end_raw() const; @@ -1030,41 +985,6 @@ Tensor<0, dim, Number>::Tensor(Tensor<0, dim, Number> &&other) noexcept # endif -template -inline Number * -Tensor<0, dim, Number>::begin_raw() -{ - return std::addressof(value); -} - - - -template -inline const Number * -Tensor<0, dim, Number>::begin_raw() const -{ - return std::addressof(value); -} - - - -template -inline Number * -Tensor<0, dim, Number>::end_raw() -{ - return begin_raw() + n_independent_components; -} - - - -template -const Number * -Tensor<0, dim, Number>::end_raw() const -{ - return begin_raw() + n_independent_components; -} - - template constexpr DEAL_II_HOST_DEVICE_ALWAYS_INLINE @@ -1584,6 +1504,11 @@ template inline Number * Tensor::begin_raw() { + static_assert(rank_ == 1, + "This function is only available for rank-1 tensors " + "because higher-rank tensors may not store their elements " + "in a contiguous array."); + return std::addressof( this->operator[](this->unrolled_to_component_indices(0))); } @@ -1594,6 +1519,11 @@ template inline const Number * Tensor::begin_raw() const { + static_assert(rank_ == 1, + "This function is only available for rank-1 tensors " + "because higher-rank tensors may not store their elements " + "in a contiguous array."); + return std::addressof( this->operator[](this->unrolled_to_component_indices(0))); } @@ -1604,6 +1534,11 @@ template inline Number * Tensor::end_raw() { + static_assert(rank_ == 1, + "This function is only available for rank-1 tensors " + "because higher-rank tensors may not store their elements " + "in a contiguous array."); + return begin_raw() + n_independent_components; } @@ -1613,6 +1548,11 @@ template inline const Number * Tensor::end_raw() const { + static_assert(rank_ == 1, + "This function is only available for rank-1 tensors " + "because higher-rank tensors may not store their elements " + "in a contiguous array."); + return begin_raw() + n_independent_components; } diff --git a/include/deal.II/grid/grid_tools_geometry.h b/include/deal.II/grid/grid_tools_geometry.h index b7e29cea80..d1055ca1f1 100644 --- a/include/deal.II/grid/grid_tools_geometry.h +++ b/include/deal.II/grid/grid_tools_geometry.h @@ -593,6 +593,8 @@ namespace GridTools } } // namespace internal + + template Point project_to_object( -- 2.39.5