From 7252bbce8c1aa00736476831d58065b7ce49c8c9 Mon Sep 17 00:00:00 2001 From: Peter Munch Date: Fri, 24 Nov 2023 21:31:49 +0100 Subject: [PATCH] MGTransferMF: simplify code --- .../mg_transfer_global_coarsening.templates.h | 74 +++---------------- 1 file changed, 10 insertions(+), 64 deletions(-) diff --git a/include/deal.II/multigrid/mg_transfer_global_coarsening.templates.h b/include/deal.II/multigrid/mg_transfer_global_coarsening.templates.h index 3011e8ce1f..ee4e7d4ef2 100644 --- a/include/deal.II/multigrid/mg_transfer_global_coarsening.templates.h +++ b/include/deal.II/multigrid/mg_transfer_global_coarsening.templates.h @@ -2244,42 +2244,11 @@ namespace internal // ... and store them cell-wise a DG format transfer.weights.resize(n_dof_indices_fine.back()); - Number *weights_0 = transfer.weights.data() + n_dof_indices_fine[0]; - Number *weights_1 = transfer.weights.data() + n_dof_indices_fine[1]; - unsigned int *dof_indices_fine_0 = - transfer.constraint_info_fine.dof_indices.data() + - n_dof_indices_fine[0]; - unsigned int *dof_indices_fine_1 = - transfer.constraint_info_fine.dof_indices.data() + - n_dof_indices_fine[1]; - - process_cells( - [&](const auto &, const auto &) { - for (unsigned int i = 0; - i < transfer.schemes[0].n_dofs_per_cell_fine; - ++i) - weights_0[i] = - weight_vector.local_element(dof_indices_fine_0[i]); - - dof_indices_fine_0 += transfer.schemes[0].n_dofs_per_cell_fine; - weights_0 += transfer.schemes[0].n_dofs_per_cell_fine; - }, - [&](const auto &, const auto &, const auto c) { - for (unsigned int i = 0; - i < transfer.schemes[1].n_dofs_per_cell_coarse; - ++i) - weights_1[cell_local_children_indices[c][i]] = - weight_vector.local_element( - dof_indices_fine_1[cell_local_children_indices[c][i]]); - - // move pointers (only once at the end) - if (c + 1 == GeometryInfo::max_children_per_cell) - { - dof_indices_fine_1 += - transfer.schemes[1].n_dofs_per_cell_fine; - weights_1 += transfer.schemes[1].n_dofs_per_cell_fine; - } - }); + for (unsigned int i = 0; + i < transfer.constraint_info_fine.dof_indices.size(); + ++i) + transfer.weights[i] = weight_vector.local_element( + transfer.constraint_info_fine.dof_indices[i]); if (is_feq) compress_weights(transfer); @@ -2753,34 +2722,11 @@ namespace internal // ... and store them cell-wise a DG format transfer.weights.resize(n_dof_indices_fine.back()); - std::vector level_dof_indices_fine_( - fe_index_pairs.size()); - std::vector weights_(fe_index_pairs.size()); - - for (unsigned int i = 0; i < fe_index_pairs.size(); ++i) - { - level_dof_indices_fine_[i] = - transfer.constraint_info_fine.dof_indices.data() + - n_dof_indices_fine[i]; - weights_[i] = transfer.weights.data() + n_dof_indices_fine[i]; - } - - process_cells([&](const auto &cell_coarse, const auto &cell_fine) { - const auto fe_pair_no = - fe_index_pairs[std::pair( - cell_coarse->active_fe_index(), cell_fine->active_fe_index())]; - - for (unsigned int i = 0; - i < transfer.schemes[fe_pair_no].n_dofs_per_cell_fine; - i++) - weights_[fe_pair_no][i] = weight_vector.local_element( - level_dof_indices_fine_[fe_pair_no][i]); - - level_dof_indices_fine_[fe_pair_no] += - transfer.schemes[fe_pair_no].n_dofs_per_cell_fine; - weights_[fe_pair_no] += - transfer.schemes[fe_pair_no].n_dofs_per_cell_fine; - }); + for (unsigned int i = 0; + i < transfer.constraint_info_fine.dof_indices.size(); + ++i) + transfer.weights[i] = weight_vector.local_element( + transfer.constraint_info_fine.dof_indices[i]); if (is_feq) compress_weights(transfer); -- 2.39.5