]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Correct type stored in one offset array. Remove some code duplication in hp::DoFHandler.
authorWolfgang Bangerth <bangerth@math.tamu.edu>
Wed, 28 Aug 2013 15:01:45 +0000 (15:01 +0000)
committerWolfgang Bangerth <bangerth@math.tamu.edu>
Wed, 28 Aug 2013 15:01:45 +0000 (15:01 +0000)
git-svn-id: https://svn.dealii.org/trunk@30518 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/include/deal.II/hp/dof_objects.h
deal.II/source/hp/dof_handler.cc

index 1eb9a0e47158017395881e0aaede915a37bb66b8..15bae95dad4587d0e1c427f424c85ddc89d0c2e1 100644 (file)
@@ -104,6 +104,9 @@ namespace internal
        * Store the start index for
        * the degrees of freedom of each
        * object in the @p dofs array.
+       *
+       * The type we store is then obviously the type the @p dofs array
+       * uses for indexing.
        */
       std::vector<std::vector<types::global_dof_index>::size_type> dof_offsets;
 
index b05e51e69593e0431d6c48850d092ea75820f5b4..205071413ea1d10bfb00256d13a3864e2720adab 100644 (file)
@@ -577,7 +577,7 @@ namespace internal
           for (unsigned int level=0; level<dof_handler.tria->n_levels(); ++level)
             {
               dof_handler.levels[level]->dof_object.dof_offsets
-                = std::vector<types::global_dof_index> (
+                = std::vector<std::vector<types::global_dof_index>::size_type> (
                     dof_handler.tria->n_raw_lines(level),
                     DoFHandler<dim,spacedim>::invalid_dof_index);
 
@@ -694,7 +694,7 @@ namespace internal
           for (unsigned int level=0; level<dof_handler.tria->n_levels(); ++level)
             {
               dof_handler.levels[level]->dof_object.dof_offsets
-                = std::vector<types::global_dof_index> (
+                = std::vector<std::vector<types::global_dof_index>::size_type> (
                     dof_handler.tria->n_raw_quads(level),
                     DoFHandler<dim,spacedim>::invalid_dof_index);
 
@@ -846,7 +846,8 @@ namespace internal
             // active ones will have a
             // non-invalid value later on
             dof_handler.faces->lines.dof_offsets
-              = std::vector<types::global_dof_index> (dof_handler.tria->n_raw_lines(),
+              = std::vector<std::vector<types::global_dof_index>::size_type>
+                                                     (dof_handler.tria->n_raw_lines(),
                                                       DoFHandler<dim,spacedim>::invalid_dof_index);
             dof_handler.faces->lines.dofs
               = std::vector<types::global_dof_index> (n_line_slots,
@@ -1059,7 +1060,8 @@ namespace internal
           for (unsigned int level=0; level<dof_handler.tria->n_levels(); ++level)
             {
               dof_handler.levels[level]->dof_object.dof_offsets
-                = std::vector<types::global_dof_index> (dof_handler.tria->n_raw_hexs(level),
+                = std::vector<std::vector<types::global_dof_index>::size_type>
+                                                       (dof_handler.tria->n_raw_hexs(level),
                                                         DoFHandler<dim,spacedim>::invalid_dof_index);
 
               types::global_dof_index next_free_dof = 0;
@@ -1214,7 +1216,8 @@ namespace internal
             if (true)
               {
                 dof_handler.faces->quads.dof_offsets
-                  = std::vector<types::global_dof_index> (dof_handler.tria->n_raw_quads(),
+                  = std::vector<std::vector<types::global_dof_index>::size_type>
+                                                         (dof_handler.tria->n_raw_quads(),
                                                           DoFHandler<dim,spacedim>::invalid_dof_index);
                 dof_handler.faces->quads.dofs
                   = std::vector<types::global_dof_index> (n_quad_slots,
@@ -3130,101 +3133,20 @@ namespace hp
         std::vector<bool> *has_children_level =
           new std::vector<bool> (cells_on_level);
 
-        // Check for each cell, if it has children.
-        std::transform (tria->levels[i]->cells.refinement_cases.begin (),
-                        tria->levels[i]->cells.refinement_cases.end (),
-                        has_children_level->begin (),
-                        std::bind2nd (std::not_equal_to<unsigned char>(),
-                                      static_cast<unsigned char>(RefinementCase<dim>::no_refinement)));
-
-        has_children.push_back (has_children_level);
-      }
-  }
-
-
-
-  template <>
-  void DoFHandler<1>::pre_refinement_action ()
-  {
-    create_active_fe_table ();
-
-    // Remember if the cells already have
-    // children. That will make the transfer
-    // of the active_fe_index to the finer
-    // levels easier.
-    Assert (has_children.size () == 0, ExcInternalError ());
-    for (unsigned int i=0; i<levels.size(); ++i)
-      {
-        const unsigned int cells_on_level = tria->n_raw_cells (i);
-        std::vector<bool> *has_children_level =
-          new std::vector<bool> (cells_on_level);
-
-        // Check for each cell, if it has
-        // children. here we cannot use
-        // refinement_cases, since it is unused in
-        // 1d (as there is only one choice
-        // anyway). use the 'children' vector
-        // instead
-        std::transform (tria->levels[i]->cells.children.begin (),
-                        tria->levels[i]->cells.children.end (),
-                        has_children_level->begin (),
-                        std::bind2nd (std::not_equal_to<int>(), -1));
-
-        has_children.push_back (has_children_level);
-      }
-  }
-
-
-
-  template <>
-  void DoFHandler<1,2>::pre_refinement_action ()
-  {
-    create_active_fe_table ();
-
-    // Remember if the cells have already
-    // children. That will make the transfer
-    // of the active_fe_index to the finer
-    // levels easier.
-    Assert (has_children.size () == 0, ExcInternalError ());
-    for (unsigned int i=0; i<levels.size(); ++i)
-      {
-        const unsigned int lines_on_level = tria->n_raw_lines(i);
-        std::vector<bool> *has_children_level =
-          new std::vector<bool> (lines_on_level);
-
-        // Check for each cell, if it has children.
-        std::transform (tria->levels[i]->cells.children.begin (),
-                        tria->levels[i]->cells.children.end (),
-                        has_children_level->begin (),
-                        std::bind2nd (std::not_equal_to<int>(), -1));
-
-        has_children.push_back (has_children_level);
-      }
-  }
-
-
-
-  template <>
-  void DoFHandler<1,3>::pre_refinement_action ()
-  {
-    create_active_fe_table ();
-
-    // Remember if the cells have already
-    // children. That will make the transfer
-    // of the active_fe_index to the finer
-    // levels easier.
-    Assert (has_children.size () == 0, ExcInternalError ());
-    for (unsigned int i=0; i<levels.size(); ++i)
-      {
-        const unsigned int lines_on_level = tria->n_raw_lines(i);
-        std::vector<bool> *has_children_level =
-          new std::vector<bool> (lines_on_level);
-
-        // Check for each cell, if it has children.
-        std::transform (tria->levels[i]->cells.children.begin (),
-                        tria->levels[i]->cells.children.end (),
-                        has_children_level->begin (),
-                        std::bind2nd (std::not_equal_to<int>(), -1));
+        // Check for each cell, if it has children. in 1d,
+        // we don't store refinement cases, so use the 'children'
+        // vector instead
+        if (dim == 1)
+          std::transform (tria->levels[i]->cells.children.begin (),
+                          tria->levels[i]->cells.children.end (),
+                          has_children_level->begin (),
+                          std::bind2nd (std::not_equal_to<int>(), -1));
+        else
+          std::transform (tria->levels[i]->cells.refinement_cases.begin (),
+                          tria->levels[i]->cells.refinement_cases.end (),
+                          has_children_level->begin (),
+                          std::bind2nd (std::not_equal_to<unsigned char>(),
+                                        static_cast<unsigned char>(RefinementCase<dim>::no_refinement)));
 
         has_children.push_back (has_children_level);
       }

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.