]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Simplify the implementation of an algorithm slightly.
authorWolfgang Bangerth <bangerth@colostate.edu>
Wed, 19 Jul 2017 18:06:30 +0000 (12:06 -0600)
committerWolfgang Bangerth <bangerth@colostate.edu>
Wed, 19 Jul 2017 22:16:52 +0000 (16:16 -0600)
Also make it cheaper: We really only need to loop over ghost cells,
but not locally owned cells.

source/dofs/dof_handler_policy.cc

index 7327a3cb20f2343ec95f06b6419917b7c9cdbf2c..83ba8970fe17cd108b2c55e168d0d24821eadf66 100644 (file)
@@ -4010,31 +4010,34 @@ namespace internal
                     ExcInternalError());
           }
 
-        // mark not locally active DoFs as invalid
+        // delete all knowledge of DoF indices that are not locally
+        // owned. we do so by getting DoF indices on cells, checking
+        // whether they are locally owned, if not, setting them to
+        // an invalid value, and then setting them again on the current
+        // cell
+        //
+        // DoFs we (i) know about, and (ii) don't own locally must be located
+        // either on ghost cells, or on the interface between a locally
+        // owned cell and a ghost cell. In any case, it is sufficient
+        // to kill them only from the ghost side cell, so loop only over
+        // ghost cells
         {
           std::vector<dealii::types::global_dof_index> local_dof_indices;
 
-          typename DoFHandlerType::active_cell_iterator
-          cell = dof_handler->begin_active(),
-          endc = dof_handler->end();
-
-          for (; cell != endc; ++cell)
-            if (!cell->is_artificial())
+          for (auto cell : dof_handler->active_cell_iterators())
+            if (cell->is_ghost())
               {
                 local_dof_indices.resize (cell->get_fe().dofs_per_cell);
                 cell->get_dof_indices (local_dof_indices);
-                for (unsigned int i=0; i<cell->get_fe().dofs_per_cell; ++i)
-                  {
-                    if (local_dof_indices[i] == numbers::invalid_dof_index)
-                      continue;
 
-                    if (!dof_handler->locally_owned_dofs().is_element(local_dof_indices[i]))
-                      {
-                        //this DoF is not owned by us, so set it to invalid.
-                        local_dof_indices[i]
-                          = numbers::invalid_dof_index;
-                      }
-                  }
+                for (unsigned int i=0; i<cell->get_fe().dofs_per_cell; ++i)
+                  // delete a DoF index if it has not already been deleted
+                  // (e.g., by visiting a neighboring cell, if it is on the
+                  // boundary), and if we don't own it
+                  if ((local_dof_indices[i] != numbers::invalid_dof_index)
+                      &&
+                      (!dof_handler->locally_owned_dofs().is_element(local_dof_indices[i])))
+                    local_dof_indices[i] = numbers::invalid_dof_index;
 
                 cell->set_dof_indices (local_dof_indices);
               }

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.