From 964935dc0ef8df8bb1447d2ba6456f2d5c756625 Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Thu, 14 Dec 2023 22:48:10 -0700 Subject: [PATCH] Correct a condition. --- include/deal.II/lac/sparse_matrix_tools.h | 30 ++++++++++++----------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/include/deal.II/lac/sparse_matrix_tools.h b/include/deal.II/lac/sparse_matrix_tools.h index c4832c3107..f5002984e8 100644 --- a/include/deal.II/lac/sparse_matrix_tools.h +++ b/include/deal.II/lac/sparse_matrix_tools.h @@ -151,23 +151,25 @@ namespace SparseMatrixTools (void)comm; return {0, value}; # else - if (comm == MPI_COMM_SELF) - return {0, value}; // serial triangulation - - T prefix = {}; + if (Utilities::MPI::n_mpi_processes(comm) == 1) + return {0, value}; + else + { + T prefix = {}; - int ierr = - MPI_Exscan(&value, - &prefix, - 1, - Utilities::MPI::mpi_type_id_for_type, - MPI_SUM, - comm); - AssertThrowMPI(ierr); + int ierr = + MPI_Exscan(&value, + &prefix, + 1, + Utilities::MPI::mpi_type_id_for_type, + MPI_SUM, + comm); + AssertThrowMPI(ierr); - T sum = Utilities::MPI::sum(value, comm); + T sum = Utilities::MPI::sum(value, comm); - return {prefix, sum}; + return {prefix, sum}; + } # endif } -- 2.39.5