From: Wolfgang Bangerth Date: Fri, 20 Aug 2021 02:19:55 +0000 (-0600) Subject: Avoid the use of ArrayView for Tensors in MPI::sum(). X-Git-Tag: v9.4.0-rc1~1042^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1d893d9fda1c7c2db6990ed40ab87b5eb95e765e;p=dealii.git Avoid the use of ArrayView for Tensors in MPI::sum(). --- diff --git a/include/deal.II/base/mpi.templates.h b/include/deal.II/base/mpi.templates.h index 6c9e2eb178..fe5d640253 100644 --- a/include/deal.II/base/mpi.templates.h +++ b/include/deal.II/base/mpi.templates.h @@ -323,12 +323,20 @@ namespace Utilities template Tensor - sum(const Tensor &local, - const MPI_Comm & mpi_communicator) + sum(const Tensor &t, const MPI_Comm &mpi_communicator) { - Tensor sums; - sum(local, mpi_communicator, sums); - return sums; + // Copy the tensor into a C-style array with which we can then + // call the other sum() function. + Number array[Tensor::n_independent_components]; + for (unsigned int i = 0; + i < Tensor::n_independent_components; + ++i) + array[i] = + t[Tensor::unrolled_to_component_indices(i)]; + + sum(array, mpi_communicator, array); + + return Tensor(make_array_view(array)); } @@ -338,6 +346,8 @@ namespace Utilities sum(const SymmetricTensor &local, const MPI_Comm & mpi_communicator) { + // Copy the tensor into a C-style array with which we can then + // call the other sum() function. const unsigned int n_entries = SymmetricTensor::n_independent_components; Number