From: Marc Fehling Date: Thu, 11 Mar 2021 05:13:39 +0000 (-0700) Subject: Simplify DoFHandler::prepare_coarsening_and_refinement(). X-Git-Tag: v9.3.0-rc1~348^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7f9be12dcf10e59062b5c0e17977e587924beb5f;p=dealii.git Simplify DoFHandler::prepare_coarsening_and_refinement(). --- diff --git a/source/dofs/dof_handler.cc b/source/dofs/dof_handler.cc index 2e36ac73e2..cf63d8d2c9 100644 --- a/source/dofs/dof_handler.cc +++ b/source/dofs/dof_handler.cc @@ -2672,21 +2672,30 @@ DoFHandler::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 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 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 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::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 future_levels; if (const auto parallel_tria = @@ -2720,16 +2724,8 @@ DoFHandler::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()]; //