From: Wolfgang Bangerth Date: Fri, 30 Jun 2017 17:45:05 +0000 (-0600) Subject: Let DoFHandler mg renumbering call the policy. X-Git-Tag: v9.0.0-rc1~1456^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8edaebfe3c602ebb2df6e7410ac3030d2b1ee4fd;p=dealii.git Let DoFHandler mg renumbering call the policy. Currently, the code is duplicated between the DoFHandler and the policy class. This makes no sense, and indeed the policy class code is more evolved, so let the former call the latter following exposing the interface in the previous patch. The existing code in DoFHandler looks like it did not actually support parallel triangulations (either shared or distributed). This was probably a bug, and consequently the implementation of the functionality in the ParallelDistributed policy class now just throws an error. This relates to the discussion in #4559. --- diff --git a/include/deal.II/dofs/dof_handler.h b/include/deal.II/dofs/dof_handler.h index fbb876662d..b687e91e65 100644 --- a/include/deal.II/dofs/dof_handler.h +++ b/include/deal.II/dofs/dof_handler.h @@ -1123,10 +1123,6 @@ private: template <> types::global_dof_index DoFHandler<1>::n_boundary_dofs () const; template <> types::global_dof_index DoFHandler<1>::n_boundary_dofs (const std::set &) const; -template <> void DoFHandler<1>::renumber_dofs(unsigned int,const std::vector &new_numbers); -template <> void DoFHandler<2>::renumber_dofs(unsigned int,const std::vector &new_numbers); -template <> void DoFHandler<3>::renumber_dofs(unsigned int,const std::vector &new_numbers); - /* ----------------------- Inline functions ---------------------------------- */ diff --git a/source/dofs/dof_handler.cc b/source/dofs/dof_handler.cc index 6022ac2af6..bbfd88d0a7 100644 --- a/source/dofs/dof_handler.cc +++ b/source/dofs/dof_handler.cc @@ -1221,203 +1221,19 @@ DoFHandler::renumber_dofs (const std::vector void -DoFHandler::renumber_dofs (const unsigned int, - const std::vector &) -{ - Assert(false, ExcNotImplemented()); -} - - -template <> -void DoFHandler<1>::renumber_dofs (const unsigned int level, - const std::vector &new_numbers) -{ - Assert(mg_levels.size()>0 && levels.size()>0, - ExcMessage("You need to distribute active and level DoFs before you can renumber level DoFs.")); - Assert (new_numbers.size() == n_dofs(level), DoFHandler<1>::ExcRenumberingIncomplete()); - - // note that we can not use cell iterators - // in this function since then we would - // renumber the dofs on the interface of - // two cells more than once. Anyway, this - // ways it's not only more correct but also - // faster - for (std::vector::iterator i=mg_vertex_dofs.begin(); - i!=mg_vertex_dofs.end(); ++i) - // if the present vertex lives on - // the present level - if ((i->get_coarsest_level() <= level) && - (i->get_finest_level() >= level)) - for (unsigned int d=0; dget_fe().dofs_per_vertex; ++d) - i->set_index (level, d, new_numbers[i->get_index (level, d)]); - - for (std::vector::iterator i=mg_levels[level]->dof_object.dofs.begin(); - i!=mg_levels[level]->dof_object.dofs.end(); ++i) - { - if (*i != numbers::invalid_dof_index) - { - Assert(*i -void DoFHandler<2>::renumber_dofs (const unsigned int level, - const std::vector &new_numbers) -{ - Assert(mg_levels.size()>0 && levels.size()>0, - ExcMessage("You need to distribute active and level DoFs before you can renumber level DoFs.")); - Assert (new_numbers.size() == n_dofs(level), - DoFHandler<2>::ExcRenumberingIncomplete()); - - for (std::vector::iterator i=mg_vertex_dofs.begin(); - i!=mg_vertex_dofs.end(); ++i) - // if the present vertex lives on - // the present level - if ((i->get_coarsest_level() <= level) && - (i->get_finest_level() >= level)) - for (unsigned int d=0; dget_fe().dofs_per_vertex; ++d) - i->set_index (level, d, new_numbers[i->get_index (level, d)]); - - if (this->get_fe().dofs_per_line > 0) - { - // save user flags as they will be modified - std::vector user_flags; - this->get_triangulation().save_user_flags(user_flags); - const_cast &>(this->get_triangulation()).clear_user_flags (); - - // flag all lines adjacent to cells of the current - // level, as those lines logically belong to the same - // level as the cell, at least for for isotropic - // refinement - level_cell_iterator cell, endc = end(level); - for (cell = begin(level); cell != endc; ++cell) - for (unsigned int line=0; line < GeometryInfo<2>::faces_per_cell; ++line) - cell->face(line)->set_user_flag(); - - for (cell_iterator cell = begin(); cell != end(); ++cell) - for (unsigned int l=0; l::lines_per_cell; ++l) - if (cell->line(l)->user_flag_set()) - { - for (unsigned int d=0; dget_fe().dofs_per_line; ++d) - cell->line(l)->set_mg_dof_index (level, d, - new_numbers[cell->line(l)->mg_dof_index(level, d)]); - cell->line(l)->clear_user_flag(); - } - // finally, restore user flags - const_cast &>(this->get_triangulation()).load_user_flags (user_flags); - } - - for (std::vector::iterator i=mg_levels[level]->dof_object.dofs.begin(); - i!=mg_levels[level]->dof_object.dofs.end(); ++i) - { - if (*i != numbers::invalid_dof_index) - { - Assert(*i -void DoFHandler<3>::renumber_dofs (const unsigned int level, - const std::vector &new_numbers) +DoFHandler::renumber_dofs (const unsigned int level, + const std::vector &new_numbers) { Assert(mg_levels.size()>0 && levels.size()>0, ExcMessage("You need to distribute active and level DoFs before you can renumber level DoFs.")); - Assert (new_numbers.size() == n_dofs(level), - DoFHandler<3>::ExcRenumberingIncomplete()); - - for (std::vector::iterator i=mg_vertex_dofs.begin(); - i!=mg_vertex_dofs.end(); ++i) - // if the present vertex lives on - // the present level - if ((i->get_coarsest_level() <= level) && - (i->get_finest_level() >= level)) - for (unsigned int d=0; dget_fe().dofs_per_vertex; ++d) - i->set_index (level, d, new_numbers[i->get_index (level, d)]); - - // LINE DoFs - if (this->get_fe().dofs_per_line > 0) - { - // save user flags as they will be modified - std::vector user_flags; - this->get_triangulation().save_user_flags(user_flags); - const_cast &>(this->get_triangulation()).clear_user_flags (); - - // flag all lines adjacent to cells of the current - // level, as those lines logically belong to the same - // level as the cell, at least for for isotropic - // refinement - level_cell_iterator cell, endc = end(level); - for (cell = begin(level) ; cell != endc ; ++cell) - for (unsigned int line=0; line < GeometryInfo<3>::lines_per_cell; ++line) - cell->line(line)->set_user_flag(); - - - for (cell = begin(level); cell != endc; ++cell) - for (unsigned int l=0; l::lines_per_cell; ++l) - if (cell->line(l)->user_flag_set()) - { - for (unsigned int d=0; dget_fe().dofs_per_line; ++d) - cell->line(l)->set_mg_dof_index (level, d, - new_numbers[cell->line(l)->mg_dof_index(level, d)]); - cell->line(l)->clear_user_flag(); - } - // finally, restore user flags - const_cast &>(this->get_triangulation()).load_user_flags (user_flags); - } - - // QUAD DoFs - if (this->get_fe().dofs_per_quad > 0) - { - // save user flags as they will be modified - std::vector user_flags; - this->get_triangulation().save_user_flags(user_flags); - const_cast &>(this->get_triangulation()).clear_user_flags (); - - // flag all quads adjacent to cells of the current - // level, as those lines logically belong to the same - // level as the cell, at least for for isotropic - // refinement - level_cell_iterator cell, endc = end(level); - for (cell = begin(level) ; cell != endc; ++cell) - for (unsigned int quad=0; quad < GeometryInfo<3>::faces_per_cell; ++quad) - cell->face(quad)->set_user_flag(); - - for (cell = begin(level); cell != endc; ++cell) - for (unsigned int q=0; q::quads_per_cell; ++q) - if (cell->quad(q)->user_flag_set()) - { - for (unsigned int d=0; dget_fe().dofs_per_quad; ++d) - cell->quad(q)->set_mg_dof_index (level, d, - new_numbers[cell->quad(q)->mg_dof_index(level, d)]); - cell->quad(q)->clear_user_flag(); - } - // finally, restore user flags - const_cast &>(this->get_triangulation()).load_user_flags (user_flags); - } + AssertIndexRange(level, levels.size()); + Assert (new_numbers.size() == n_dofs(level), ExcRenumberingIncomplete()); - // HEX DoFs - for (std::vector::iterator i=mg_levels[level]->dof_object.dofs.begin(); - i!=mg_levels[level]->dof_object.dofs.end(); ++i) - { - if (*i != numbers::invalid_dof_index) - { - Assert(*irenumber_mg_dofs (level, new_numbers); } - template unsigned int DoFHandler::max_couplings_between_dofs () const