]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Fix a bug in hp DoF unification. 5068/head
authorWolfgang Bangerth <bangerth@colostate.edu>
Tue, 12 Sep 2017 22:47:30 +0000 (16:47 -0600)
committerWolfgang Bangerth <bangerth@colostate.edu>
Wed, 13 Sep 2017 13:41:27 +0000 (07:41 -0600)
Specifically, in the first phase of DoF distribution, we only
enumerate DoF indices on locally owned cells. Thus, after
unification when we renumber, we need to ignore DoFs on
ghost cells. In that case, we need to pass the correct
'check_validity' flag to the renumbering routines.

source/dofs/dof_handler_policy.cc

index ff966fe300866aea5dd1738bc2877e2a9594b367..d59731c8f55383aebf144f55fa3d0abc1d5883c5 100644 (file)
@@ -1022,7 +1022,8 @@ namespace internal
         static
         unsigned int
         unify_dof_indices (const DoFHandler<dim,spacedim> &,
-                           const unsigned int              n_dofs_before_identification)
+                           const unsigned int              n_dofs_before_identification,
+                           const bool)
         {
           return n_dofs_before_identification;
         }
@@ -1033,7 +1034,8 @@ namespace internal
         static
         unsigned int
         unify_dof_indices (hp::DoFHandler<dim,spacedim> &dof_handler,
-                           const unsigned int            n_dofs_before_identification)
+                           const unsigned int            n_dofs_before_identification,
+                           const bool                    check_validity)
         {
           // compute the constraints that correspond to unifying
           // dof indices on vertices, lines, and quads. do so
@@ -1103,12 +1105,13 @@ namespace internal
                       ExcInternalError());
             }
 
-          // finally, do the renumbering and set the number of actually
-          // used dof indices
+          // finally, do the renumbering. verify that previous dof indices
+          // were indeed all valid on all cells that we touch if we were
+          // told to do so
           renumber_dofs (new_dof_indices,
                          IndexSet(0),
                          dof_handler,
-                         true);
+                         check_validity);
 
 
           return next_free_dof;
@@ -1149,7 +1152,13 @@ namespace internal
                                                              next_free_dof);
 
           // Step 2: unify dof indices in case this is an hp DoFHandler
-          next_free_dof = unify_dof_indices (dof_handler, next_free_dof);
+          //
+          // during unification, we need to renumber DoF indices. there,
+          // we can check that all previous DoF indices were valid, but
+          // this only makes sense if we really distributed DoFs on
+          // all (non-artificial) cells above
+          next_free_dof = unify_dof_indices (dof_handler, next_free_dof,
+                                             /* check_validity = */ (subdomain_id == numbers::invalid_subdomain_id));
 
           update_all_active_cell_dof_indices_caches (dof_handler);
 
@@ -1569,6 +1578,16 @@ namespace internal
                 = dealii::internal::DoFAccessor::Implementation::
                   n_active_vertex_fe_indices (dof_handler, vertex_index);
 
+              // if this vertex is unused, then we really ought not to have allocated
+              // any space for it, i.e., n_active_fe_indices should be zero, and
+              // there is no space to actually store dof indices for this vertex
+              if (dof_handler.get_triangulation().vertex_used(vertex_index) == false)
+                Assert (n_active_fe_indices == 0,
+                        ExcInternalError());
+
+              // otherwise the vertex is used; it may still not hold any dof indices
+              // if it is located on an artificial cell and not adjacent to a ghost
+              // cell, but in that case there is simply nothing for us to do
               for (unsigned int f=0; f<n_active_fe_indices; ++f)
                 {
                   const unsigned int fe_index
@@ -1583,6 +1602,19 @@ namespace internal
                                                vertex_index,
                                                fe_index,
                                                d);
+
+                      // if check_validity was set, then we are to verify that the
+                      // previous indices were all valid. this really should be
+                      // the case: we allocated space for these vertex dofs,
+                      // i.e., at least one adjacent cell has a valid
+                      // active_fe_index, so there are DoFs that really live
+                      // on this vertex. if check_validity is set, then we
+                      // must make sure that they have been set to something
+                      // useful
+                      if (check_validity)
+                        Assert (old_dof_index != numbers::invalid_dof_index,
+                                ExcInternalError());
+
                       if (old_dof_index != numbers::invalid_dof_index)
                         dealii::internal::DoFAccessor::Implementation::
                         set_vertex_dof_index (dof_handler,
@@ -1592,13 +1624,6 @@ namespace internal
                                               (indices.size() == 0)?
                                               (new_numbers[old_dof_index]) :
                                               (new_numbers[indices.index_within_set(old_dof_index)]));
-                      else if (check_validity)
-                        // if index is invalid_dof_index: check if this one
-                        // really is unused
-                        Assert (dof_handler.get_triangulation()
-                                .vertex_used(vertex_index)
-                                == false,
-                                ExcInternalError ());
                     }
                 }
             }

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.