From 1d893d9fda1c7c2db6990ed40ab87b5eb95e765e Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Thu, 19 Aug 2021 20:19:55 -0600 Subject: [PATCH] Avoid the use of ArrayView for Tensors in MPI::sum(). --- include/deal.II/base/mpi.templates.h | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) 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 -- 2.39.5