From 91f704f163ec65be04636061784f82c9e2e393df Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Wed, 11 Sep 2024 19:06:04 -0600 Subject: [PATCH] Minor cleanups to AffineConstraints to make code easier to read. --- .../lac/affine_constraints.templates.h | 31 +++++++++---------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/include/deal.II/lac/affine_constraints.templates.h b/include/deal.II/lac/affine_constraints.templates.h index 4388705982..e75850c92d 100644 --- a/include/deal.II/lac/affine_constraints.templates.h +++ b/include/deal.II/lac/affine_constraints.templates.h @@ -258,29 +258,29 @@ AffineConstraints::is_consistent_in_parallel( unsigned int inconsistent = 0; // from each processor: - for (const auto &kv : received) + for (const auto &[sender, constraints] : received) { // for each incoming line: - for (const auto &lineit : kv.second) + for (const ConstraintLine &constraint : constraints) { - const ConstraintLine reference = get_line(lineit.index); + const ConstraintLine reference = get_line(constraint.index); - if (lineit.inhomogeneity != reference.inhomogeneity) + if (constraint.inhomogeneity != reference.inhomogeneity) { ++inconsistent; if (verbose) - std::cout << "Proc " << myid << " got line " << lineit.index - << " from " << kv.first << " inhomogeneity " - << lineit.inhomogeneity + std::cout << "Proc " << myid << " got line " << constraint.index + << " from " << sender << " inhomogeneity " + << constraint.inhomogeneity << " != " << reference.inhomogeneity << std::endl; } - else if (lineit.entries != reference.entries) + else if (constraint.entries != reference.entries) { ++inconsistent; if (verbose) - std::cout << "Proc " << myid << " got line " << lineit.index - << " from " << kv.first << " with wrong values!" + std::cout << "Proc " << myid << " got line " << constraint.index + << " from " << sender << " with wrong values!" << std::endl; } } @@ -476,14 +476,13 @@ namespace internal std::map> send_data; - for (const std::map::value_type - &rank_and_indices : locally_relevant_dofs_by_ranks) + for (const auto &[destination, indices] : locally_relevant_dofs_by_ranks) { - Assert(rank_and_indices.first != my_rank, ExcInternalError()); + Assert(destination != my_rank, ExcInternalError()); std::vector data; - for (const types::global_dof_index index : rank_and_indices.second) + for (const types::global_dof_index index : indices) { // note: at this stage locally_relevant_constraints still // contains only locally owned constraints @@ -497,14 +496,14 @@ namespace internal data.push_back(*ptr); } - send_data[rank_and_indices.first] = std::move(data); + send_data[destination] = std::move(data); } const std::map> received_data = Utilities::MPI::some_to_some(mpi_communicator, send_data); // Finally collate everything into one array, sort, and make it unique: - for (const auto &[rank, constraints] : received_data) + for (const auto &[sender, constraints] : received_data) locally_relevant_constraints.insert(locally_relevant_constraints.end(), constraints.begin(), constraints.end()); -- 2.39.5