]> https://gitweb.dealii.org/ - dealii.git/commitdiff
MGTransferMF: simplify code 16293/head
authorPeter Munch <peterrmuench@gmail.com>
Fri, 24 Nov 2023 20:31:49 +0000 (21:31 +0100)
committerPeter Munch <peterrmuench@gmail.com>
Fri, 24 Nov 2023 20:31:49 +0000 (21:31 +0100)
include/deal.II/multigrid/mg_transfer_global_coarsening.templates.h

index 3011e8ce1ffdf0bc1a9686ab9df87a596f562da4..ee4e7d4ef2aa61969dd85dde3c0cc537bc6d51bd 100644 (file)
@@ -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<dim>::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<unsigned int *> level_dof_indices_fine_(
-            fe_index_pairs.size());
-          std::vector<Number *> 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<unsigned int, unsigned int>(
-                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);

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.