]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Extend DoFRenumbering::hierarchical().
authorWolfgang Bangerth <bangerth@colostate.edu>
Thu, 6 Sep 2018 20:58:03 +0000 (14:58 -0600)
committerWolfgang Bangerth <bangerth@colostate.edu>
Thu, 6 Sep 2018 20:58:03 +0000 (14:58 -0600)
In particular, make it work for dim!=spacedim and for
hp::DoFHandler objects.

include/deal.II/dofs/dof_renumbering.h
source/dofs/dof_renumbering.cc
source/dofs/dof_renumbering.inst.in

index 0b317cb18f9d0c7be73253bbe9aacea4a6dcca53..d94420c66e7858921c577959d2c98c4641f413bb 100644 (file)
@@ -832,9 +832,9 @@ namespace DoFRenumbering
    * have been produced by a previous call to a renumbering function is
    * ignored.
    */
-  template <int dim>
+  template <typename DoFHandlerType>
   void
-  hierarchical(DoFHandler<dim> &dof_handler);
+  hierarchical(DoFHandlerType &dof_handler);
 
   /**
    * Renumber degrees of freedom by cell. The function takes a vector of cell
index 1e5ae0e4470385da60db005808812f7cd89a1ae5..6f1616d58fd317947c13ca48cc3a60b99da1f9b7 100644 (file)
@@ -1246,7 +1246,7 @@ namespace DoFRenumbering
 
   namespace
   {
-    // Helper function for DoFRenumbering::hierarchical(). this function
+    // Helper function for DoFRenumbering::hierarchical(). This function
     // recurses into the given cell or, if that should be an active (terminal)
     // cell, renumbers DoF indices on it. The function starts renumbering with
     // 'next_free_dof_index' and returns the first still unused DoF index at the
@@ -1341,10 +1341,13 @@ namespace DoFRenumbering
 
 
 
-  template <int dim>
+  template <typename DoFHandlerType>
   void
-  hierarchical(DoFHandler<dim> &dof_handler)
+  hierarchical(DoFHandlerType &dof_handler)
   {
+    const int dim      = DoFHandlerType::dimension;
+    const int spacedim = DoFHandlerType::space_dimension;
+
     std::vector<types::global_dof_index> renumbering(
       dof_handler.n_locally_owned_dofs(), numbers::invalid_dof_index);
 
@@ -1364,8 +1367,8 @@ namespace DoFRenumbering
     // DoFs for all previous processes
     types::global_dof_index my_starting_index = 0;
 
-    if (const parallel::Triangulation<dim> *tria =
-          dynamic_cast<const parallel::Triangulation<dim> *>(
+    if (const parallel::Triangulation<dim, spacedim> *tria =
+          dynamic_cast<const parallel::Triangulation<dim, spacedim> *>(
             &dof_handler.get_triangulation()))
       {
         const std::vector<types::global_dof_index>
@@ -1378,9 +1381,9 @@ namespace DoFRenumbering
                           types::global_dof_index(0));
       }
 
-    if (const parallel::distributed::Triangulation<dim> *tria =
-          dynamic_cast<const parallel::distributed::Triangulation<dim> *>(
-            &dof_handler.get_triangulation()))
+    if (const parallel::distributed::Triangulation<dim, spacedim> *tria =
+          dynamic_cast<const parallel::distributed::Triangulation<dim, spacedim>
+                         *>(&dof_handler.get_triangulation()))
       {
 #ifdef DEAL_II_WITH_P4EST
         // this is a distributed Triangulation. we need to traverse the coarse
@@ -1392,7 +1395,7 @@ namespace DoFRenumbering
             const unsigned int coarse_cell_index =
               tria->get_p4est_tree_to_coarse_cell_permutation()[c];
 
-            const typename DoFHandler<dim>::level_cell_iterator this_cell(
+            const typename DoFHandlerType::level_cell_iterator this_cell(
               tria, 0, coarse_cell_index, &dof_handler);
 
             next_free_dof_offset =
@@ -1410,8 +1413,7 @@ namespace DoFRenumbering
       {
         // this is not a distributed Triangulation, so we can traverse coarse
         // cells in the normal order
-        for (typename DoFHandler<dim>::cell_iterator cell =
-               dof_handler.begin(0);
+        for (typename DoFHandlerType::cell_iterator cell = dof_handler.begin(0);
              cell != dof_handler.end(0);
              ++cell)
           next_free_dof_offset =
index 1422db062aea4aba84327c29033cc0a688d9fe79..f7667f4b8316643cb37496cc0fd4bb5d5b80099b 100644 (file)
@@ -67,6 +67,12 @@ for (deal_II_dimension : DIMENSIONS; deal_II_space_dimension : SPACE_DIMENSIONS)
         const DoFHandler<deal_II_dimension, deal_II_space_dimension>
           &dof_handler);
 
+      template void
+      hierarchical(DoFHandler<deal_II_dimension, deal_II_space_dimension> &);
+
+      template void
+      hierarchical(
+        hp::DoFHandler<deal_II_dimension, deal_II_space_dimension> &);
     \}
 #endif
   }
@@ -168,9 +174,6 @@ for (deal_II_dimension : DIMENSIONS; deal_II_space_dimension : SPACE_DIMENSIONS)
       block_wise<deal_II_dimension>(DoFHandler<deal_II_dimension> &,
                                     unsigned int);
 
-      template void
-      hierarchical<deal_II_dimension>(DoFHandler<deal_II_dimension> &);
-
       template void
       cell_wise<DoFHandler<deal_II_dimension>>(
         DoFHandler<deal_II_dimension> &,

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.