From b43eb688e9ef5f43891bbcdbeb2cdd127df0cf44 Mon Sep 17 00:00:00 2001 From: Peter Munch Date: Tue, 23 Jun 2020 23:23:50 +0200 Subject: [PATCH] Remove DoFHandlerType from dofs/dof_renumbering --- include/deal.II/dofs/dof_renumbering.h | 226 ++++++------ source/dofs/dof_renumbering.cc | 457 ++++++++++++------------- source/dofs/dof_renumbering.inst.in | 64 ++-- 3 files changed, 354 insertions(+), 393 deletions(-) diff --git a/include/deal.II/dofs/dof_renumbering.h b/include/deal.II/dofs/dof_renumbering.h index a6c1d0bb55..0ee1e4fb8c 100644 --- a/include/deal.II/dofs/dof_renumbering.h +++ b/include/deal.II/dofs/dof_renumbering.h @@ -436,21 +436,21 @@ namespace DoFRenumbering * comparison of various algorithms in the documentation of the * DoFRenumbering namespace. */ - template + template void - Cuthill_McKee(DoFHandlerType &dof_handler, - const bool reversed_numbering = false, - const bool use_constraints = false); + Cuthill_McKee(DoFHandler &dof_handler, + const bool reversed_numbering = false, + const bool use_constraints = false); /** * Compute the renumbering vector needed by the Cuthill_McKee() function. * Does not perform the renumbering on the DoFHandler dofs but returns the * renumbering vector. */ - template + template void compute_Cuthill_McKee(std::vector &new_dof_indices, - const DoFHandlerType &, + const DoFHandler &, const bool reversed_numbering = false, const bool use_constraints = false); @@ -466,20 +466,20 @@ namespace DoFRenumbering * * This algorithm is used in step-22. */ - template + template void - king_ordering(DoFHandlerType &dof_handler, - const bool reversed_numbering = false, - const bool use_constraints = false); + king_ordering(DoFHandler &dof_handler, + const bool reversed_numbering = false, + const bool use_constraints = false); /** * Compute the renumbering for the King algorithm but do not actually * renumber the degrees of freedom in the DoF handler argument. */ - template + template void compute_king_ordering(std::vector &new_dof_indices, - const DoFHandlerType &, + const DoFHandler &, const bool reversed_numbering = false, const bool use_constraints = false); @@ -494,21 +494,21 @@ namespace DoFRenumbering * comparison of various algorithms in the documentation of the * DoFRenumbering namespace. */ - template + template void - minimum_degree(DoFHandlerType &dof_handler, - const bool reversed_numbering = false, - const bool use_constraints = false); + minimum_degree(DoFHandler &dof_handler, + const bool reversed_numbering = false, + const bool use_constraints = false); /** * Compute the renumbering for the minimum degree algorithm but do not * actually renumber the degrees of freedom in the DoF handler argument. */ - template + template void compute_minimum_degree( std::vector &new_dof_indices, - const DoFHandlerType &, + const DoFHandler &, const bool reversed_numbering = false, const bool use_constraints = false); } // namespace boost @@ -577,11 +577,11 @@ namespace DoFRenumbering * starting indices even though it can only renumber them on a given * processor if they are also locally owned. */ - template + template void - Cuthill_McKee(DoFHandlerType &dof_handler, - const bool reversed_numbering = false, - const bool use_constraints = false, + Cuthill_McKee(DoFHandler &dof_handler, + const bool reversed_numbering = false, + const bool use_constraints = false, const std::vector &starting_indices = std::vector()); @@ -592,11 +592,11 @@ namespace DoFRenumbering * * See the Cuthill_McKee() function for an explanation of the arguments. */ - template + template void compute_Cuthill_McKee( std::vector &new_dof_indices, - const DoFHandlerType &, + const DoFHandler &, const bool reversed_numbering = false, const bool use_constraints = false, const std::vector &starting_indices = @@ -615,11 +615,11 @@ namespace DoFRenumbering * See the general documentation of this class for details on the different * methods. */ - template + template void - Cuthill_McKee(DoFHandlerType & dof_handler, - const unsigned int level, - const bool reversed_numbering = false, + Cuthill_McKee(DoFHandler &dof_handler, + const unsigned int level, + const bool reversed_numbering = false, const std::vector &starting_indices = std::vector()); @@ -654,9 +654,9 @@ namespace DoFRenumbering * For finite elements with only one component, or a single non-primitive * base element, this function is the identity operation. */ - template + template void - component_wise(DoFHandlerType & dof_handler, + component_wise(DoFHandler & dof_handler, const std::vector &target_component = std::vector()); @@ -667,9 +667,9 @@ namespace DoFRenumbering * multilevel discretization. The non-multigrid part of the DoFHandler * is not touched. */ - template + template void - component_wise(DoFHandlerType & dof_handler, + component_wise(DoFHandler & dof_handler, const unsigned int level, const std::vector &target_component = std::vector()); @@ -715,9 +715,9 @@ namespace DoFRenumbering * number of blocks and that subsequent blocks in one element have the same * meaning as in another element. */ - template + template void - block_wise(DoFHandlerType &dof_handler); + block_wise(DoFHandler &dof_handler); /** * Sort the degrees of freedom by vector block. It does the same thing as @@ -725,9 +725,9 @@ namespace DoFRenumbering * multilevel discretization. The non-multigrid part of the DoFHandler * is not touched. */ - template + template void - block_wise(DoFHandlerType &dof_handler, const unsigned int level); + block_wise(DoFHandler &dof_handler, const unsigned int level); /** * Compute the renumbering vector needed by the block_wise() functions. @@ -822,9 +822,9 @@ namespace DoFRenumbering * have been produced by a previous call to a renumbering function is * ignored. */ - template + template void - hierarchical(DoFHandlerType &dof_handler); + hierarchical(DoFHandler &dof_handler); /** * Renumber degrees of freedom by cell. The function takes a vector of cell @@ -850,11 +850,12 @@ namespace DoFRenumbering * iterator of that triangulation needs to be present in @p cell_order exactly * once. */ - template + template void - cell_wise(DoFHandlerType &dof_handler, - const std::vector - &cell_order); + cell_wise( + DoFHandler &dof_handler, + const std::vector::active_cell_iterator> + &cell_order); /** * Compute a renumbering of degrees of freedom by cell. The function takes a @@ -891,38 +892,39 @@ namespace DoFRenumbering * renumbering[inverse_renumbering[i]] == * dof_handler.locally_owned_dofs().nth_index_in_set(i) will hold. */ - template + template void compute_cell_wise( std::vector &renumbering, std::vector &inverse_renumbering, - const DoFHandlerType & dof_handler, - const std::vector + const DoFHandler & dof_handler, + const std::vector::active_cell_iterator> &cell_order); /** * Like the other cell_wise() function, but for one level of a multilevel * enumeration of degrees of freedom. */ - template + template void - cell_wise(DoFHandlerType & dof_handler, - const unsigned int level, - const std::vector - &cell_order); + cell_wise( + DoFHandler &dof_handler, + const unsigned int level, + const std::vector::level_cell_iterator> + &cell_order); /** * Like the other compute_cell_wise() function, but for one level of a * multilevel enumeration of degrees of freedom. */ - template + template void compute_cell_wise( std::vector &renumbering, std::vector &inverse_renumbering, - const DoFHandlerType & dof_handler, + const DoFHandler & dof_handler, const unsigned int level, - const std::vector + const std::vector::level_cell_iterator> &cell_order); /** @@ -960,11 +962,11 @@ namespace DoFRenumbering * downstream location (e.g. those parallel to the flow direction, or * several dofs within a FESystem) will be unaffected. */ - template + template void - downstream(DoFHandlerType & dof_handler, - const Tensor<1, DoFHandlerType::space_dimension> &direction, - const bool dof_wise_renumbering = false); + downstream(DoFHandler &dof_handler, + const Tensor<1, spacedim> &direction, + const bool dof_wise_renumbering = false); /** @@ -972,41 +974,39 @@ namespace DoFRenumbering * on one level of a multigrid hierarchy. See the other function with the same * name. */ - template + template void - downstream(DoFHandlerType & dof_handler, - const unsigned int level, - const Tensor<1, DoFHandlerType::space_dimension> &direction, - const bool dof_wise_renumbering = false); + downstream(DoFHandler &dof_handler, + const unsigned int level, + const Tensor<1, spacedim> &direction, + const bool dof_wise_renumbering = false); /** * Compute the set of renumbering indices needed by the downstream() function. * Does not perform the renumbering on the DoFHandler dofs but returns the * renumbering vector. */ - template + template void - compute_downstream( - std::vector & new_dof_indices, - std::vector & reverse, - const DoFHandlerType & dof_handler, - const Tensor<1, DoFHandlerType::space_dimension> &direction, - const bool dof_wise_renumbering); + compute_downstream(std::vector &new_dof_indices, + std::vector &reverse, + const DoFHandler & dof_handler, + const Tensor<1, spacedim> & direction, + const bool dof_wise_renumbering); /** * Compute the set of renumbering indices needed by the downstream() function. * Does not perform the renumbering on the DoFHandler dofs but returns the * renumbering vector. */ - template + template void - compute_downstream( - std::vector & new_dof_indices, - std::vector & reverse, - const DoFHandlerType & dof_handler, - const unsigned int level, - const Tensor<1, DoFHandlerType::space_dimension> &direction, - const bool dof_wise_renumbering); + compute_downstream(std::vector &new_dof_indices, + std::vector &reverse, + const DoFHandler & dof_handler, + const unsigned int level, + const Tensor<1, spacedim> & direction, + const bool dof_wise_renumbering); /** * Cell-wise clockwise numbering. @@ -1016,34 +1016,34 @@ namespace DoFRenumbering * only works with Discontinuous Galerkin Finite Elements, i.e. all degrees * of freedom have to be associated with the interior of the cell. */ - template + template void - clockwise_dg(DoFHandlerType & dof_handler, - const Point ¢er, - const bool counter = false); + clockwise_dg(DoFHandler &dof_handler, + const Point & center, + const bool counter = false); /** * Cell-wise clockwise numbering on one level of a multigrid * hierarchy. See the other function with the same name. */ - template + template void - clockwise_dg(DoFHandlerType & dof_handler, - const unsigned int level, - const Point ¢er, - const bool counter = false); + clockwise_dg(DoFHandler &dof_handler, + const unsigned int level, + const Point & center, + const bool counter = false); /** * Compute the renumbering vector needed by the clockwise_dg() functions. * Does not perform the renumbering on the DoFHandler dofs but returns the * renumbering vector. */ - template + template void compute_clockwise_dg(std::vector &new_dof_indices, - const DoFHandlerType & dof_handler, - const Point ¢er, - const bool counter); + const DoFHandler & dof_handler, + const Point & center, + const bool counter); /** * @} @@ -1063,10 +1063,10 @@ namespace DoFRenumbering * @pre The @p selected_dofs array must have as many elements as the @p * dof_handler has degrees of freedom. */ - template + template void - sort_selected_dofs_back(DoFHandlerType & dof_handler, - const std::vector &selected_dofs); + sort_selected_dofs_back(DoFHandler &dof_handler, + const std::vector & selected_dofs); /** * Sort those degrees of freedom which are tagged with @p true in the @p @@ -1078,11 +1078,11 @@ namespace DoFRenumbering * @pre The @p selected_dofs array must have as many elements as the @p * dof_handler has degrees of freedom on the given level. */ - template + template void - sort_selected_dofs_back(DoFHandlerType & dof_handler, - const std::vector &selected_dofs, - const unsigned int level); + sort_selected_dofs_back(DoFHandler &dof_handler, + const std::vector & selected_dofs, + const unsigned int level); /** * Compute the renumbering vector needed by the sort_selected_dofs_back() @@ -1092,11 +1092,11 @@ namespace DoFRenumbering * @pre The @p selected_dofs array must have as many elements as the @p * dof_handler has degrees of freedom. */ - template + template void compute_sort_selected_dofs_back( std::vector &new_dof_indices, - const DoFHandlerType & dof_handler, + const DoFHandler & dof_handler, const std::vector & selected_dofs); /** @@ -1108,11 +1108,11 @@ namespace DoFRenumbering * @pre The @p selected_dofs array must have as many elements as the @p * dof_handler has degrees of freedom on the given level. */ - template + template void compute_sort_selected_dofs_back( std::vector &new_dof_indices, - const DoFHandlerType & dof_handler, + const DoFHandler & dof_handler, const std::vector & selected_dofs, const unsigned int level); @@ -1126,9 +1126,9 @@ namespace DoFRenumbering * before this function (or, for that matter, whether other threads running * concurrently to this function also draw random numbers). */ - template + template void - random(DoFHandlerType &dof_handler); + random(DoFHandler &dof_handler); /** * Renumber the degrees of freedom in a random way. It does the same thing as @@ -1136,9 +1136,9 @@ namespace DoFRenumbering * multilevel discretization. The non-multigrid part of the DoFHandler * is not touched. */ - template + template void - random(DoFHandlerType &dof_handler, const unsigned int level); + random(DoFHandler &dof_handler, const unsigned int level); /** * Compute the renumbering vector needed by the random() function. See @@ -1147,20 +1147,20 @@ namespace DoFRenumbering * This function does not perform the renumbering on the DoFHandler dofs but * returns the renumbering vector. */ - template + template void compute_random(std::vector &new_dof_indices, - const DoFHandlerType & dof_handler); + const DoFHandler & dof_handler); /** * Compute the renumbering vector needed by the random() function. Same * as the above function but for a single level of a multilevel * discretization. */ - template + template void compute_random(std::vector &new_dof_indices, - const DoFHandlerType & dof_handler, + const DoFHandler & dof_handler, const unsigned int level); /** @@ -1194,19 +1194,19 @@ namespace DoFRenumbering * belong to the same subdomain, then they will be in this order also after * reordering. */ - template + template void - subdomain_wise(DoFHandlerType &dof_handler); + subdomain_wise(DoFHandler &dof_handler); /** * Compute the renumbering vector needed by the subdomain_wise() function. * Does not perform the renumbering on the @p DoFHandler dofs but returns * the renumbering vector. */ - template + template void compute_subdomain_wise(std::vector &new_dof_indices, - const DoFHandlerType & dof_handler); + const DoFHandler & dof_handler); /** * @} diff --git a/source/dofs/dof_renumbering.cc b/source/dofs/dof_renumbering.cc index 7577eca222..80932f51f4 100644 --- a/source/dofs/dof_renumbering.cc +++ b/source/dofs/dof_renumbering.cc @@ -88,11 +88,11 @@ namespace DoFRenumbering namespace internal { - template + template void - create_graph(const DoFHandlerType &dof_handler, - const bool use_constraints, - boosttypes::Graph & graph, + create_graph(const DoFHandler &dof_handler, + const bool use_constraints, + boosttypes::Graph & graph, boosttypes::property_map::type &graph_degree) @@ -123,11 +123,11 @@ namespace DoFRenumbering } // namespace internal - template + template void - Cuthill_McKee(DoFHandlerType &dof_handler, - const bool reversed_numbering, - const bool use_constraints) + Cuthill_McKee(DoFHandler &dof_handler, + const bool reversed_numbering, + const bool use_constraints) { std::vector renumbering( dof_handler.n_dofs(), numbers::invalid_dof_index); @@ -143,10 +143,10 @@ namespace DoFRenumbering } - template + template void compute_Cuthill_McKee(std::vector &new_dof_indices, - const DoFHandlerType & dof_handler, + const DoFHandler & dof_handler, const bool reversed_numbering, const bool use_constraints) { @@ -185,11 +185,11 @@ namespace DoFRenumbering - template + template void - king_ordering(DoFHandlerType &dof_handler, - const bool reversed_numbering, - const bool use_constraints) + king_ordering(DoFHandler &dof_handler, + const bool reversed_numbering, + const bool use_constraints) { std::vector renumbering( dof_handler.n_dofs(), numbers::invalid_dof_index); @@ -205,10 +205,10 @@ namespace DoFRenumbering } - template + template void compute_king_ordering(std::vector &new_dof_indices, - const DoFHandlerType & dof_handler, + const DoFHandler & dof_handler, const bool reversed_numbering, const bool use_constraints) { @@ -241,11 +241,11 @@ namespace DoFRenumbering - template + template void - minimum_degree(DoFHandlerType &dof_handler, - const bool reversed_numbering, - const bool use_constraints) + minimum_degree(DoFHandler &dof_handler, + const bool reversed_numbering, + const bool use_constraints) { std::vector renumbering( dof_handler.n_dofs(), numbers::invalid_dof_index); @@ -261,11 +261,11 @@ namespace DoFRenumbering } - template + template void compute_minimum_degree( std::vector &new_dof_indices, - const DoFHandlerType & dof_handler, + const DoFHandler & dof_handler, const bool reversed_numbering, const bool use_constraints) { @@ -291,11 +291,7 @@ namespace DoFRenumbering std::vector dofs_on_this_cell; - typename DoFHandlerType::active_cell_iterator cell = dof_handler - .begin_active(), - endc = dof_handler.end(); - - for (; cell != endc; ++cell) + for (const auto &cell : dof_handler.active_cell_iterators()) { const unsigned int dofs_per_cell = cell->get_fe().dofs_per_cell; @@ -364,9 +360,9 @@ namespace DoFRenumbering - template + template void - Cuthill_McKee(DoFHandlerType & dof_handler, + Cuthill_McKee(DoFHandler & dof_handler, const bool reversed_numbering, const bool use_constraints, const std::vector &starting_indices) @@ -388,11 +384,11 @@ namespace DoFRenumbering - template + template void compute_Cuthill_McKee( std::vector & new_indices, - const DoFHandlerType & dof_handler, + const DoFHandler & dof_handler, const bool reversed_numbering, const bool use_constraints, const std::vector &starting_indices) @@ -599,9 +595,9 @@ namespace DoFRenumbering - template + template void - Cuthill_McKee(DoFHandlerType & dof_handler, + Cuthill_McKee(DoFHandler & dof_handler, const unsigned int level, const bool reversed_numbering, const std::vector &starting_indices) @@ -628,22 +624,20 @@ namespace DoFRenumbering - template + template void - component_wise(DoFHandlerType & dof_handler, + component_wise(DoFHandler & dof_handler, const std::vector &component_order_arg) { std::vector renumbering( dof_handler.n_locally_owned_dofs(), numbers::invalid_dof_index); - typename DoFHandlerType::active_cell_iterator start = - dof_handler.begin_active(); - const typename DoFHandlerType::level_cell_iterator end = dof_handler.end(); - const types::global_dof_index result = - compute_component_wise( - renumbering, start, end, component_order_arg, false); + compute_component_wise(renumbering, + dof_handler.begin_active(), + dof_handler.end(), + component_order_arg, + false); if (result == 0) return; @@ -664,9 +658,9 @@ namespace DoFRenumbering - template + template void - component_wise(DoFHandlerType & dof_handler, + component_wise(DoFHandler & dof_handler, const unsigned int level, const std::vector &component_order_arg) { @@ -677,13 +671,13 @@ namespace DoFRenumbering dof_handler.locally_owned_mg_dofs(level).n_elements(), numbers::invalid_dof_index); - typename DoFHandlerType::level_cell_iterator start = + typename DoFHandler::level_cell_iterator start = dof_handler.begin(level); - typename DoFHandlerType::level_cell_iterator end = dof_handler.end(level); + typename DoFHandler::level_cell_iterator end = + dof_handler.end(level); const types::global_dof_index result = - compute_component_wise( + compute_component_wise( renumbering, start, end, component_order_arg, true); if (result == 0) @@ -946,23 +940,19 @@ namespace DoFRenumbering - template + template void - block_wise(DoFHandlerType &dof_handler) + block_wise(DoFHandler &dof_handler) { std::vector renumbering( dof_handler.n_locally_owned_dofs(), numbers::invalid_dof_index); - typename DoFHandlerType::active_cell_iterator start = - dof_handler.begin_active(); - const typename DoFHandlerType::level_cell_iterator end = dof_handler.end(); - - const types::global_dof_index result = - compute_block_wise( - renumbering, start, end, false); + const types::global_dof_index result = compute_block_wise< + dim, + spacedim, + typename DoFHandler::active_cell_iterator, + typename DoFHandler::level_cell_iterator>( + renumbering, dof_handler.begin_active(), dof_handler.end(), false); if (result == 0) return; @@ -983,9 +973,9 @@ namespace DoFRenumbering - template + template void - block_wise(DoFHandlerType &dof_handler, const unsigned int level) + block_wise(DoFHandler &dof_handler, const unsigned int level) { Assert(dof_handler.n_dofs(level) != numbers::invalid_dof_index, ExcDoFHandlerNotInitialized()); @@ -994,16 +984,19 @@ namespace DoFRenumbering dof_handler.locally_owned_mg_dofs(level).n_elements(), numbers::invalid_dof_index); - typename DoFHandlerType::level_cell_iterator start = + typename DoFHandler::level_cell_iterator start = dof_handler.begin(level); - typename DoFHandlerType::level_cell_iterator end = dof_handler.end(level); - - const types::global_dof_index result = - compute_block_wise( - renumbering, start, end, true); + typename DoFHandler::level_cell_iterator end = + dof_handler.end(level); + + const types::global_dof_index result = compute_block_wise< + dim, + spacedim, + typename DoFHandler::level_cell_iterator, + typename DoFHandler::level_cell_iterator>(renumbering, + start, + end, + true); if (result == 0) return; @@ -1308,13 +1301,10 @@ namespace DoFRenumbering - template + template void - hierarchical(DoFHandlerType &dof_handler) + hierarchical(DoFHandler &dof_handler) { - const int dim = DoFHandlerType::dimension; - const int spacedim = DoFHandlerType::space_dimension; - std::vector renumbering( dof_handler.n_locally_owned_dofs(), numbers::invalid_dof_index); @@ -1364,8 +1354,8 @@ namespace DoFRenumbering const unsigned int coarse_cell_index = tria->get_p4est_tree_to_coarse_cell_permutation()[c]; - const typename DoFHandlerType::level_cell_iterator this_cell( - tria, 0, coarse_cell_index, &dof_handler); + const typename DoFHandler::level_cell_iterator + this_cell(tria, 0, coarse_cell_index, &dof_handler); next_free_dof_offset = compute_hierarchical_recursive(next_free_dof_offset, @@ -1382,7 +1372,8 @@ namespace DoFRenumbering { // this is not a distributed Triangulation, so we can traverse coarse // cells in the normal order - for (typename DoFHandlerType::cell_iterator cell = dof_handler.begin(0); + for (typename DoFHandler::cell_iterator cell = + dof_handler.begin(0); cell != dof_handler.end(0); ++cell) next_free_dof_offset = @@ -1413,10 +1404,10 @@ namespace DoFRenumbering - template + template void - sort_selected_dofs_back(DoFHandlerType & dof_handler, - const std::vector &selected_dofs) + sort_selected_dofs_back(DoFHandler &dof_handler, + const std::vector & selected_dofs) { std::vector renumbering( dof_handler.n_dofs(), numbers::invalid_dof_index); @@ -1427,11 +1418,11 @@ namespace DoFRenumbering - template + template void - sort_selected_dofs_back(DoFHandlerType & dof_handler, - const std::vector &selected_dofs, - const unsigned int level) + sort_selected_dofs_back(DoFHandler &dof_handler, + const std::vector & selected_dofs, + const unsigned int level) { Assert(dof_handler.n_dofs(level) != numbers::invalid_dof_index, ExcDoFHandlerNotInitialized()); @@ -1448,11 +1439,11 @@ namespace DoFRenumbering - template + template void compute_sort_selected_dofs_back( std::vector &new_indices, - const DoFHandlerType & dof_handler, + const DoFHandler & dof_handler, const std::vector & selected_dofs) { const types::global_dof_index n_dofs = dof_handler.n_dofs(); @@ -1486,11 +1477,11 @@ namespace DoFRenumbering - template + template void compute_sort_selected_dofs_back( std::vector &new_indices, - const DoFHandlerType & dof_handler, + const DoFHandler & dof_handler, const std::vector & selected_dofs, const unsigned int level) { @@ -1528,11 +1519,12 @@ namespace DoFRenumbering - template + template void cell_wise( - DoFHandlerType & dof, - const std::vector &cells) + DoFHandler &dof, + const std::vector::active_cell_iterator> + &cells) { std::vector renumbering( dof.n_locally_owned_dofs()); @@ -1543,20 +1535,18 @@ namespace DoFRenumbering } - template + template void compute_cell_wise( std::vector &new_indices, std::vector &reverse, - const DoFHandlerType & dof, - const typename std::vector - &cells) + const DoFHandler & dof, + const typename std::vector< + typename DoFHandler::active_cell_iterator> &cells) { - if (const parallel::TriangulationBase *p = - dynamic_cast *>(&dof.get_triangulation())) + if (const parallel::TriangulationBase *p = + dynamic_cast *>( + &dof.get_triangulation())) { AssertDimension(cells.size(), p->n_locally_owned_active_cells()); } @@ -1619,13 +1609,12 @@ namespace DoFRenumbering - template + template void - cell_wise( - DoFHandlerType & dof, - const unsigned int level, - const typename std::vector - &cells) + cell_wise(DoFHandler &dof, + const unsigned int level, + const typename std::vector< + typename DoFHandler::level_cell_iterator> &cells) { Assert(dof.n_dofs(level) != numbers::invalid_dof_index, ExcDoFHandlerNotInitialized()); @@ -1639,15 +1628,15 @@ namespace DoFRenumbering - template + template void compute_cell_wise( std::vector &new_order, std::vector &reverse, - const DoFHandlerType & dof, + const DoFHandler & dof, const unsigned int level, - const typename std::vector - &cells) + const typename std::vector< + typename DoFHandler::level_cell_iterator> &cells) { Assert(cells.size() == dof.get_triangulation().n_cells(level), ExcDimensionMismatch(cells.size(), @@ -1693,11 +1682,11 @@ namespace DoFRenumbering - template + template void - downstream(DoFHandlerType & dof, - const Tensor<1, DoFHandlerType::space_dimension> &direction, - const bool dof_wise_renumbering) + downstream(DoFHandler &dof, + const Tensor<1, spacedim> &direction, + const bool dof_wise_renumbering) { std::vector renumbering(dof.n_dofs()); std::vector reverse(dof.n_dofs()); @@ -1709,39 +1698,31 @@ namespace DoFRenumbering - template + template void - compute_downstream( - std::vector & new_indices, - std::vector & reverse, - const DoFHandlerType & dof, - const Tensor<1, DoFHandlerType::space_dimension> &direction, - const bool dof_wise_renumbering) + compute_downstream(std::vector &new_indices, + std::vector &reverse, + const DoFHandler & dof, + const Tensor<1, spacedim> & direction, + const bool dof_wise_renumbering) { - Assert( - (dynamic_cast< - const parallel::TriangulationBase *>( - &dof.get_triangulation()) == nullptr), - ExcNotImplemented()); + Assert((dynamic_cast *>( + &dof.get_triangulation()) == nullptr), + ExcNotImplemented()); if (dof_wise_renumbering == false) { - std::vector + std::vector::active_cell_iterator> ordered_cells; ordered_cells.reserve(dof.get_triangulation().n_active_cells()); - const CompareDownstream + const CompareDownstream< + typename DoFHandler::active_cell_iterator, + spacedim> comparator(direction); - typename DoFHandlerType::active_cell_iterator p = dof.begin_active(); - typename DoFHandlerType::active_cell_iterator end = dof.end(); + for (const auto &cell : dof.active_cell_iterators()) + ordered_cells.push_back(cell); - while (p != end) - { - ordered_cells.push_back(p); - ++p; - } std::sort(ordered_cells.begin(), ordered_cells.end(), comparator); compute_cell_wise(new_indices, reverse, dof, ordered_cells); @@ -1750,50 +1731,42 @@ namespace DoFRenumbering { // similar code as for // DoFTools::map_dofs_to_support_points, but - // need to do this for general DoFHandlerType classes and + // need to do this for general DoFHandler classes and // want to be able to sort the result // (otherwise, could use something like // DoFTools::map_support_points_to_dofs) const unsigned int n_dofs = dof.n_dofs(); - std::vector< - std::pair, unsigned int>> + std::vector, unsigned int>> support_point_list(n_dofs); - const hp::FECollection &fe_collection = - dof.get_fe_collection(); + const hp::FECollection &fe_collection = dof.get_fe_collection(); Assert(fe_collection[0].has_support_points(), - typename FiniteElement< - DoFHandlerType::dimension>::ExcFEHasNoSupportPoints()); - hp::QCollection quadrature_collection; + typename FiniteElement::ExcFEHasNoSupportPoints()); + hp::QCollection quadrature_collection; for (unsigned int comp = 0; comp < fe_collection.size(); ++comp) { Assert(fe_collection[comp].has_support_points(), - typename FiniteElement< - DoFHandlerType::dimension>::ExcFEHasNoSupportPoints()); + typename FiniteElement::ExcFEHasNoSupportPoints()); quadrature_collection.push_back( - Quadrature( - fe_collection[comp].get_unit_support_points())); + Quadrature(fe_collection[comp].get_unit_support_points())); } - hp::FEValues - hp_fe_values(fe_collection, - quadrature_collection, - update_quadrature_points); + hp::FEValues hp_fe_values(fe_collection, + quadrature_collection, + update_quadrature_points); std::vector already_touched(n_dofs, false); - std::vector local_dof_indices; - typename DoFHandlerType::active_cell_iterator begin = - dof.begin_active(); - typename DoFHandlerType::active_cell_iterator end = dof.end(); - for (; begin != end; ++begin) + std::vector local_dof_indices; + + for (const auto &cell : dof.active_cell_iterators()) { - const unsigned int dofs_per_cell = begin->get_fe().dofs_per_cell; + const unsigned int dofs_per_cell = cell->get_fe().dofs_per_cell; local_dof_indices.resize(dofs_per_cell); - hp_fe_values.reinit(begin); - const FEValues &fe_values = + hp_fe_values.reinit(cell); + const FEValues &fe_values = hp_fe_values.get_present_fe_values(); - begin->get_active_or_mg_dof_indices(local_dof_indices); - const std::vector> &points = + cell->get_active_or_mg_dof_indices(local_dof_indices); + const std::vector> &points = fe_values.get_quadrature_points(); for (unsigned int i = 0; i < dofs_per_cell; ++i) if (!already_touched[local_dof_indices[i]]) @@ -1805,8 +1778,7 @@ namespace DoFRenumbering } } - ComparePointwiseDownstream comparator( - direction); + ComparePointwiseDownstream comparator(direction); std::sort(support_point_list.begin(), support_point_list.end(), comparator); @@ -1817,12 +1789,12 @@ namespace DoFRenumbering - template + template void - downstream(DoFHandlerType & dof, - const unsigned int level, - const Tensor<1, DoFHandlerType::space_dimension> &direction, - const bool dof_wise_renumbering) + downstream(DoFHandler &dof, + const unsigned int level, + const Tensor<1, spacedim> &direction, + const bool dof_wise_renumbering) { std::vector renumbering(dof.n_dofs(level)); std::vector reverse(dof.n_dofs(level)); @@ -1834,26 +1806,29 @@ namespace DoFRenumbering - template + template void - compute_downstream( - std::vector & new_indices, - std::vector & reverse, - const DoFHandlerType & dof, - const unsigned int level, - const Tensor<1, DoFHandlerType::space_dimension> &direction, - const bool dof_wise_renumbering) + compute_downstream(std::vector &new_indices, + std::vector &reverse, + const DoFHandler & dof, + const unsigned int level, + const Tensor<1, spacedim> & direction, + const bool dof_wise_renumbering) { if (dof_wise_renumbering == false) { - std::vector ordered_cells; + std::vector::level_cell_iterator> + ordered_cells; ordered_cells.reserve(dof.get_triangulation().n_cells(level)); - const CompareDownstream + const CompareDownstream< + typename DoFHandler::level_cell_iterator, + spacedim> comparator(direction); - typename DoFHandlerType::level_cell_iterator p = dof.begin(level); - typename DoFHandlerType::level_cell_iterator end = dof.end(level); + typename DoFHandler::level_cell_iterator p = + dof.begin(level); + typename DoFHandler::level_cell_iterator end = + dof.end(level); while (p != end) { @@ -1867,33 +1842,31 @@ namespace DoFRenumbering else { Assert(dof.get_fe().has_support_points(), - typename FiniteElement< - DoFHandlerType::dimension>::ExcFEHasNoSupportPoints()); + typename FiniteElement::ExcFEHasNoSupportPoints()); const unsigned int n_dofs = dof.n_dofs(level); - std::vector< - std::pair, unsigned int>> + std::vector, unsigned int>> support_point_list(n_dofs); - Quadrature q_dummy( - dof.get_fe().get_unit_support_points()); - FEValues - fe_values(dof.get_fe(), q_dummy, update_quadrature_points); + Quadrature q_dummy(dof.get_fe().get_unit_support_points()); + FEValues fe_values(dof.get_fe(), + q_dummy, + update_quadrature_points); std::vector already_touched(dof.n_dofs(), false); const unsigned int dofs_per_cell = dof.get_fe().dofs_per_cell; std::vector local_dof_indices(dofs_per_cell); - typename DoFHandlerType::level_cell_iterator begin = dof.begin(level); - typename DoFHandlerType::level_cell_iterator end = dof.end(level); + typename DoFHandler::level_cell_iterator begin = + dof.begin(level); + typename DoFHandler::level_cell_iterator end = + dof.end(level); for (; begin != end; ++begin) { - const typename Triangulation< - DoFHandlerType::dimension, - DoFHandlerType::space_dimension>::cell_iterator &begin_tria = - begin; + const typename Triangulation::cell_iterator + &begin_tria = begin; begin->get_active_or_mg_dof_indices(local_dof_indices); fe_values.reinit(begin_tria); - const std::vector> &points = + const std::vector> &points = fe_values.get_quadrature_points(); for (unsigned int i = 0; i < dofs_per_cell; ++i) if (!already_touched[local_dof_indices[i]]) @@ -1905,8 +1878,7 @@ namespace DoFRenumbering } } - ComparePointwiseDownstream comparator( - direction); + ComparePointwiseDownstream comparator(direction); std::sort(support_point_list.begin(), support_point_list.end(), comparator); @@ -1991,11 +1963,11 @@ namespace DoFRenumbering - template + template void - clockwise_dg(DoFHandlerType & dof, - const Point ¢er, - const bool counter) + clockwise_dg(DoFHandler &dof, + const Point & center, + const bool counter) { std::vector renumbering(dof.n_dofs()); compute_clockwise_dg(renumbering, dof, center, counter); @@ -2005,26 +1977,21 @@ namespace DoFRenumbering - template + template void compute_clockwise_dg(std::vector &new_indices, - const DoFHandlerType & dof, - const Point ¢er, - const bool counter) + const DoFHandler & dof, + const Point & center, + const bool counter) { - std::vector ordered_cells; + std::vector::active_cell_iterator> + ordered_cells; ordered_cells.reserve(dof.get_triangulation().n_active_cells()); - internal::ClockCells comparator(center, - counter); + internal::ClockCells comparator(center, counter); - typename DoFHandlerType::active_cell_iterator p = dof.begin_active(); - typename DoFHandlerType::active_cell_iterator end = dof.end(); + for (const auto &cell : dof.active_cell_iterators()) + ordered_cells.push_back(cell); - while (p != end) - { - ordered_cells.push_back(p); - ++p; - } std::sort(ordered_cells.begin(), ordered_cells.end(), comparator); std::vector reverse(new_indices.size()); @@ -2033,20 +2000,22 @@ namespace DoFRenumbering - template + template void - clockwise_dg(DoFHandlerType & dof, - const unsigned int level, - const Point ¢er, - const bool counter) + clockwise_dg(DoFHandler &dof, + const unsigned int level, + const Point & center, + const bool counter) { - std::vector ordered_cells; + std::vector::level_cell_iterator> + ordered_cells; ordered_cells.reserve(dof.get_triangulation().n_active_cells()); - internal::ClockCells comparator(center, - counter); + internal::ClockCells comparator(center, counter); - typename DoFHandlerType::level_cell_iterator p = dof.begin(level); - typename DoFHandlerType::level_cell_iterator end = dof.end(level); + typename DoFHandler::level_cell_iterator p = + dof.begin(level); + typename DoFHandler::level_cell_iterator end = + dof.end(level); while (p != end) { @@ -2060,9 +2029,9 @@ namespace DoFRenumbering - template + template void - random(DoFHandlerType &dof_handler) + random(DoFHandler &dof_handler) { std::vector renumbering( dof_handler.n_dofs(), numbers::invalid_dof_index); @@ -2073,9 +2042,9 @@ namespace DoFRenumbering - template + template void - random(DoFHandlerType &dof_handler, const unsigned int level) + random(DoFHandler &dof_handler, const unsigned int level) { Assert(dof_handler.n_dofs(level) != numbers::invalid_dof_index, ExcDoFHandlerNotInitialized()); @@ -2091,10 +2060,10 @@ namespace DoFRenumbering - template + template void compute_random(std::vector &new_indices, - const DoFHandlerType & dof_handler) + const DoFHandler & dof_handler) { const types::global_dof_index n_dofs = dof_handler.n_dofs(); Assert(new_indices.size() == n_dofs, @@ -2124,10 +2093,10 @@ namespace DoFRenumbering - template + template void compute_random(std::vector &new_indices, - const DoFHandlerType & dof_handler, + const DoFHandler & dof_handler, const unsigned int level) { const types::global_dof_index n_dofs = dof_handler.n_dofs(level); @@ -2158,14 +2127,12 @@ namespace DoFRenumbering - template + template void - subdomain_wise(DoFHandlerType &dof_handler) + subdomain_wise(DoFHandler &dof_handler) { Assert( - (!dynamic_cast< - const parallel::TriangulationBase *>( + (!dynamic_cast *>( &dof_handler.get_triangulation())), ExcMessage( "Parallel triangulations are already enumerated according to their MPI process id.")); @@ -2179,10 +2146,10 @@ namespace DoFRenumbering - template + template void compute_subdomain_wise(std::vector &new_dof_indices, - const DoFHandlerType & dof_handler) + const DoFHandler & dof_handler) { const types::global_dof_index n_dofs = dof_handler.n_dofs(); Assert(new_dof_indices.size() == n_dofs, diff --git a/source/dofs/dof_renumbering.inst.in b/source/dofs/dof_renumbering.inst.in index 6c6cc7bea5..064de36baa 100644 --- a/source/dofs/dof_renumbering.inst.in +++ b/source/dofs/dof_renumbering.inst.in @@ -14,8 +14,7 @@ // --------------------------------------------------------------------- -for (DoFHandler : DOFHANDLER_TEMPLATES; deal_II_dimension : DIMENSIONS; - deal_II_space_dimension : SPACE_DIMENSIONS) +for (deal_II_dimension : DIMENSIONS; deal_II_space_dimension : SPACE_DIMENSIONS) { #if deal_II_dimension <= deal_II_space_dimension namespace DoFRenumbering @@ -28,15 +27,14 @@ for (DoFHandler : DOFHANDLER_TEMPLATES; deal_II_dimension : DIMENSIONS; // non-boost functions: template void - Cuthill_McKee>( + Cuthill_McKee( DoFHandler &, const bool, const bool, const std::vector &); template void - compute_Cuthill_McKee< - DoFHandler>( + compute_Cuthill_McKee( std::vector &, const DoFHandler &, const bool, @@ -44,16 +42,16 @@ for (DoFHandler : DOFHANDLER_TEMPLATES; deal_II_dimension : DIMENSIONS; const std::vector &); template void - component_wise>( + component_wise( DoFHandler &, const std::vector &); template void - block_wise>( + block_wise( DoFHandler &); template void - subdomain_wise>( + subdomain_wise( DoFHandler &); template void @@ -72,8 +70,7 @@ for (DoFHandler : DOFHANDLER_TEMPLATES; deal_II_dimension : DIMENSIONS; // TODO[SP]: replace by // where applicable and move to codimension cases above also when applicable -for (DoFHandler : DOFHANDLER_TEMPLATES; deal_II_dimension : DIMENSIONS; - deal_II_space_dimension : SPACE_DIMENSIONS) +for (deal_II_dimension : DIMENSIONS; deal_II_space_dimension : SPACE_DIMENSIONS) { #if deal_II_dimension == deal_II_space_dimension namespace DoFRenumbering @@ -118,17 +115,17 @@ for (DoFHandler : DOFHANDLER_TEMPLATES; deal_II_dimension : DIMENSIONS; const std::vector &); template void - block_wise>(DoFHandler &, - unsigned int); + block_wise(DoFHandler &, + unsigned int); template void - cell_wise>( + cell_wise( DoFHandler &, const std::vector::active_cell_iterator> &); template void - compute_cell_wise>( + compute_cell_wise( std::vector &, std::vector &, const DoFHandler &, @@ -136,14 +133,14 @@ for (DoFHandler : DOFHANDLER_TEMPLATES; deal_II_dimension : DIMENSIONS; &); template void - cell_wise>( + cell_wise( DoFHandler &, unsigned int, const std::vector::level_cell_iterator> &); template void - compute_cell_wise>( + compute_cell_wise( std::vector &, std::vector &, const DoFHandler &, @@ -152,7 +149,7 @@ for (DoFHandler : DOFHANDLER_TEMPLATES; deal_II_dimension : DIMENSIONS; &); template void - compute_downstream>( + compute_downstream( std::vector &, std::vector &, const DoFHandler &, @@ -160,13 +157,12 @@ for (DoFHandler : DOFHANDLER_TEMPLATES; deal_II_dimension : DIMENSIONS; const bool); template void - clockwise_dg>( - DoFHandler &, - const Point &, - bool); + clockwise_dg(DoFHandler &, + const Point &, + bool); template void - compute_clockwise_dg>( + compute_clockwise_dg( std::vector &, const DoFHandler &, const Point &, @@ -199,36 +195,34 @@ for (DoFHandler : DOFHANDLER_TEMPLATES; deal_II_dimension : DIMENSIONS; // Generic numbering schemes template void - random>(DoFHandler &); + random(DoFHandler &); template void - compute_random>( - std::vector &, - const DoFHandler &); + compute_random(std::vector &, + const DoFHandler &); template void - random>(DoFHandler &, - const unsigned int); + random(DoFHandler &, + const unsigned int); template void - compute_random>( - std::vector &, - const DoFHandler &, - const unsigned int); + compute_random(std::vector &, + const DoFHandler &, + const unsigned int); template void - sort_selected_dofs_back>( + sort_selected_dofs_back( DoFHandler &, const std::vector &); template void - compute_sort_selected_dofs_back>( + compute_sort_selected_dofs_back( std::vector &, const DoFHandler &, const std::vector &); template void - Cuthill_McKee>( + Cuthill_McKee( DoFHandler &, const unsigned int, const bool, -- 2.39.5