]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Let DoFHandler mg renumbering call the policy. 4560/head
authorWolfgang Bangerth <bangerth@colostate.edu>
Fri, 30 Jun 2017 17:45:05 +0000 (11:45 -0600)
committerWolfgang Bangerth <bangerth@colostate.edu>
Fri, 30 Jun 2017 18:12:45 +0000 (12:12 -0600)
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.

include/deal.II/dofs/dof_handler.h
source/dofs/dof_handler.cc

index fbb876662d0b5b7619feeaaed061de0c89d0e7cb..b687e91e6572d196ff436653fc2453fab2bcc6bb 100644 (file)
@@ -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<types::boundary_id> &) const;
 
-template <> void DoFHandler<1>::renumber_dofs(unsigned int,const std::vector<types::global_dof_index>  &new_numbers);
-template <> void DoFHandler<2>::renumber_dofs(unsigned int,const std::vector<types::global_dof_index>  &new_numbers);
-template <> void DoFHandler<3>::renumber_dofs(unsigned int,const std::vector<types::global_dof_index>  &new_numbers);
-
 
 /* ----------------------- Inline functions ---------------------------------- */
 
index 6022ac2af6e18b7428049c783dee570e537e5633..bbfd88d0a7629ba2c9545ec2791cf1579a0e6e58 100644 (file)
@@ -1221,203 +1221,19 @@ DoFHandler<dim,spacedim>::renumber_dofs (const std::vector<types::global_dof_ind
 
 template <int dim, int spacedim>
 void
-DoFHandler<dim,spacedim>::renumber_dofs (const unsigned int,
-                                         const std::vector<types::global_dof_index> &)
-{
-  Assert(false, ExcNotImplemented());
-}
-
-
-template <>
-void DoFHandler<1>::renumber_dofs (const unsigned int level,
-                                   const std::vector<types::global_dof_index> &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<MGVertexDoFs>::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; d<this->get_fe().dofs_per_vertex; ++d)
-        i->set_index (level, d, new_numbers[i->get_index (level, d)]);
-
-  for (std::vector<types::global_dof_index>::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<new_numbers.size(), ExcInternalError());
-          *i = new_numbers[*i];
-        }
-    }
-}
-
-
-
-template <>
-void DoFHandler<2>::renumber_dofs (const unsigned int  level,
-                                   const std::vector<types::global_dof_index>  &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<MGVertexDoFs>::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; d<this->get_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<bool> user_flags;
-      this->get_triangulation().save_user_flags(user_flags);
-      const_cast<Triangulation<2> &>(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<GeometryInfo<2>::lines_per_cell; ++l)
-          if (cell->line(l)->user_flag_set())
-            {
-              for (unsigned int d=0; d<this->get_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<Triangulation<2> &>(this->get_triangulation()).load_user_flags (user_flags);
-    }
-
-  for (std::vector<types::global_dof_index>::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<new_numbers.size(), ExcInternalError());
-          *i = new_numbers[*i];
-        }
-    }
-}
-
-
-
-template <>
-void DoFHandler<3>::renumber_dofs (const unsigned int  level,
-                                   const std::vector<types::global_dof_index>  &new_numbers)
+DoFHandler<dim,spacedim>::renumber_dofs (const unsigned int                          level,
+                                         const std::vector<types::global_dof_index> &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<MGVertexDoFs>::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; d<this->get_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<bool> user_flags;
-      this->get_triangulation().save_user_flags(user_flags);
-      const_cast<Triangulation<3> &>(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<GeometryInfo<3>::lines_per_cell; ++l)
-          if (cell->line(l)->user_flag_set())
-            {
-              for (unsigned int d=0; d<this->get_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<Triangulation<3> &>(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<bool> user_flags;
-      this->get_triangulation().save_user_flags(user_flags);
-      const_cast<Triangulation<3> &>(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<GeometryInfo<3>::quads_per_cell; ++q)
-          if (cell->quad(q)->user_flag_set())
-            {
-              for (unsigned int d=0; d<this->get_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<Triangulation<3> &>(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<types::global_dof_index>::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<new_numbers.size(), ExcInternalError());
-          *i = new_numbers[*i];
-        }
-    }
+  mg_number_cache[level] = policy->renumber_mg_dofs (level, new_numbers);
 }
 
 
 
-
 template <int dim, int spacedim>
 unsigned int
 DoFHandler<dim,spacedim>::max_couplings_between_dofs () const

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.