]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Simplify DoFHandler::prepare_coarsening_and_refinement(). 11881/head
authorMarc Fehling <mafehling.git@gmail.com>
Thu, 11 Mar 2021 05:13:39 +0000 (22:13 -0700)
committerMarc Fehling <mafehling.git@gmail.com>
Thu, 11 Mar 2021 05:13:39 +0000 (22:13 -0700)
source/dofs/dof_handler.cc

index 2e36ac73e2a3617f4a065c02ab5f0636f9992c7b..cf63d8d2c9d595b6817f8398c18a81ec812d2e85 100644 (file)
@@ -2672,21 +2672,30 @@ DoFHandler<dim, spacedim>::prepare_coarsening_and_refinement(
     // nothing to do
     return false;
 
+
   //
   // establish hierarchy
   //
   // - create bimap between hierarchy levels and FE indices
 
+  // there can be as many levels in the hierarchy as active FE indices are
+  // possible
+  using level_type                      = active_fe_index_type;
+  static const level_type invalid_level = invalid_active_fe_index;
+
   // map from FE index to level in hierarchy
   // FE indices that are not covered in the hierarchy are not in the map
   const std::vector<unsigned int> fe_index_for_hierarchy_level =
     fe_collection.get_hierarchy_sequence(contains_fe_index);
 
   // map from level in hierarchy to FE index
-  // FE indices that are not covered in the hierarchy are not in the map
-  std::map<unsigned int, unsigned int> hierarchy_level_for_fe_index;
-  for (unsigned int i = 0; i < fe_index_for_hierarchy_level.size(); ++i)
-    hierarchy_level_for_fe_index[fe_index_for_hierarchy_level[i]] = i;
+  // FE indices that are not covered in the hierarchy will be mapped to
+  // invalid_level
+  std::vector<unsigned int> hierarchy_level_for_fe_index(fe_collection.size(),
+                                                         invalid_level);
+  for (unsigned int l = 0; l < fe_index_for_hierarchy_level.size(); ++l)
+    hierarchy_level_for_fe_index[fe_index_for_hierarchy_level[l]] = l;
+
 
   //
   // parallelization
@@ -2696,11 +2705,6 @@ DoFHandler<dim, spacedim>::prepare_coarsening_and_refinement(
   // - no need to compress, since the owning processor will have the correct
   //   level index
 
-  // there can be as many levels in the hierarchy as active FE indices are
-  // possible
-  using level_type                      = active_fe_index_type;
-  static const level_type invalid_level = invalid_active_fe_index;
-
   // HOTFIX: dealii::Vector does not accept integral types
   LinearAlgebra::distributed::Vector<float> future_levels;
   if (const auto parallel_tria =
@@ -2720,16 +2724,8 @@ DoFHandler<dim, spacedim>::prepare_coarsening_and_refinement(
 
   for (const auto &cell : active_cell_iterators())
     if (cell->is_locally_owned())
-      {
-        // set level if FE is part of hierarchy
-        const auto cell_fe_and_level =
-          hierarchy_level_for_fe_index.find(cell->future_fe_index());
-
-        future_levels[cell->global_active_cell_index()] =
-          (cell_fe_and_level != hierarchy_level_for_fe_index.end()) ?
-            cell_fe_and_level->second :
-            invalid_level;
-      }
+      future_levels[cell->global_active_cell_index()] =
+        hierarchy_level_for_fe_index[cell->future_fe_index()];
 
 
   //

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.