From: Bruno Turcksin Date: Thu, 3 Oct 2024 01:08:07 +0000 (-0400) Subject: Replace std::array with Kokkos::Array in Tensor X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=12717807cf7c0c9b4abe486ad5e0500c9d202167;p=dealii.git Replace std::array with Kokkos::Array in Tensor --- diff --git a/include/deal.II/base/tensor.h b/include/deal.II/base/tensor.h index 114c68b964..cd0b06b7ed 100644 --- a/include/deal.II/base/tensor.h +++ b/include/deal.II/base/tensor.h @@ -24,21 +24,12 @@ #include #include +#include + #ifdef DEAL_II_WITH_ADOLC # include // Taped double #endif -// boost::serialization::make_array used to be in array.hpp, but was -// moved to a different file in BOOST 1.64 -#include -#if BOOST_VERSION >= 106400 -# include -#else -# include -#endif - - -#include #include #include #include @@ -849,8 +840,8 @@ private: * Otherwise, it is an array of tensors one rank lower. */ std::conditional_t, - std::array, dim>> + Kokkos::Array, + Kokkos::Array, dim>> values; /** @@ -1262,17 +1253,17 @@ template constexpr DEAL_II_HOST_DEVICE_ALWAYS_INLINE Tensor::Tensor() : values( - // In order to initialize the std::array, we would need a + // In order to initialize the Kokkos::Array, we would need a // brace-enclosed list of length 'dim'. There is no way in C++ to create // such a list in-place, but we can come up with a lambda function that // expands such a list via template-pack expansion, and then uses this - // list to initialize a std::array which it then returns. + // list to initialize a Kokkos:Array which it then returns. // // The trick to come up with such a lambda function is to have a function // that takes an argument that depends on a template-pack of integers. // We will call the function with an integer list of length 'dim', and // in the function itself expand that pack in a way that it serves as - // a brace-enclosed list of initializers for a std::array. + // a brace-enclosed list of initializers for a Kokkos::Array. // // Of course, we do not want to initialize the array with the integers, // but with zeros. (Or, more correctly, a zero of the element type.) @@ -1328,7 +1319,7 @@ namespace internal namespace TensorInitialization { template - constexpr std::array::value_type, dim> + constexpr Kokkos::Array::value_type, dim> make_zero_array(const std::index_sequence &) { static_assert(sizeof...(I) == dim, "This is bad."); @@ -1819,7 +1810,7 @@ Tensor::unroll(const Iterator begin, ExcMessage( "The provided iterator range must contain at least 'dim' " "elements.")); - std::copy(std::begin(values), std::end(values), begin); + std::copy(values.data(), values.data() + values.size(), begin); } } @@ -1895,10 +1886,10 @@ template inline void Tensor::serialize(Archive &ar, const unsigned int) { - if constexpr (rank_ > 1) - ar &values; - else - ar &boost::serialization::make_array(&values[0], dim); + for (int i = 0; i < dim; ++i) + { + ar &values[i]; + } } diff --git a/tests/serialization/tensor.output b/tests/serialization/tensor.output index 53f65710ea..b6cba334c8 100644 --- a/tests/serialization/tensor.output +++ b/tests/serialization/tensor.output @@ -1,4 +1,4 @@ -DEAL::0 0 0 0 3 0 0 1.00000000000000000e+00 2.00000000000000000e+00 3.00000000000000000e+00 4.00000000000000000e+00 5.00000000000000000e+00 6.00000000000000000e+00 7.00000000000000000e+00 8.00000000000000000e+00 9.00000000000000000e+00 +DEAL::0 0 0 0 1.00000000000000000e+00 2.00000000000000000e+00 3.00000000000000000e+00 4.00000000000000000e+00 5.00000000000000000e+00 6.00000000000000000e+00 7.00000000000000000e+00 8.00000000000000000e+00 9.00000000000000000e+00 DEAL::OK