From ee3dbd73680c1c3109ccfb90569650aca1c60591 Mon Sep 17 00:00:00 2001 From: Sebastian Grimberg Date: Wed, 26 Jun 2024 10:07:55 -0700 Subject: [PATCH] Simplify search for single rank with non-zero number of true dofs --- palace/linalg/divfree.cpp | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/palace/linalg/divfree.cpp b/palace/linalg/divfree.cpp index 253d6d148..2cff9b054 100644 --- a/palace/linalg/divfree.cpp +++ b/palace/linalg/divfree.cpp @@ -64,10 +64,10 @@ DivFreeSolver::DivFreeSolver( Mpi::GlobalSum(1, &coarse_bdr_tdofs, comm); if (coarse_bdr_tdofs == 0) { - MPI_Comm split_comm = MPI_COMM_NULL; - int color = (h1_fespaces.GetFESpaceAtLevel(0).GetTrueVSize() > 0) ? 0 : MPI_UNDEFINED; - MPI_Comm_split(comm, color, Mpi::Rank(comm), &split_comm); - if (split_comm != MPI_COMM_NULL && Mpi::Root(split_comm)) + int root = (h1_fespaces.GetFESpaceAtLevel(0).GetTrueVSize() == 0) ? Mpi::Size(comm) : Mpi::Rank(comm); + Mpi::GlobalMin(1, &root, comm); + MFEM_VERIFY(root < Mpi::Size(comm), "No root process found for single true dof constraint!"); + if (root == Mpi::Rank(comm)) { aux_tdof_lists.reserve(h1_fespaces.GetNumLevels()); for (std::size_t l = 0; l < h1_fespaces.GetNumLevels(); l++) @@ -77,10 +77,6 @@ DivFreeSolver::DivFreeSolver( } ptr_h1_bdr_tdof_lists = &aux_tdof_lists; } - if (split_comm != MPI_COMM_NULL) - { - MPI_Comm_free(&split_comm); - } } }