From 243470c3227739bc04f4192a917aff25c1fa7001 Mon Sep 17 00:00:00 2001
From: Wolfgang Bangerth <bangerth@colostate.edu>
Date: Thu, 10 Aug 2017 12:47:10 -0600
Subject: [PATCH] Be careful for which cells and objects we enumerate DoFs.

---
 source/dofs/dof_handler_policy.cc | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/source/dofs/dof_handler_policy.cc b/source/dofs/dof_handler_policy.cc
index a5e5d20460..eb4fa1f43a 100644
--- a/source/dofs/dof_handler_policy.cc
+++ b/source/dofs/dof_handler_policy.cc
@@ -1126,20 +1126,22 @@ namespace internal
           Assert (dof_handler.get_triangulation().n_levels() > 0,
                   ExcMessage("Empty triangulation"));
 
-          // Step 1: distribute dofs on all cells
+          // Step 1: distribute dofs on all cells, but definitely
+          // exclude artificial cells
           types::global_dof_index next_free_dof = 0;
           typename DoFHandlerType::active_cell_iterator
           cell = dof_handler.begin_active(),
           endc = dof_handler.end();
 
           for (; cell != endc; ++cell)
-            if ((subdomain_id == numbers::invalid_subdomain_id)
-                ||
-                (cell->subdomain_id() == subdomain_id))
-              next_free_dof
-                = Implementation::distribute_dofs_on_cell (dof_handler,
-                                                           cell,
-                                                           next_free_dof);
+            if (! cell->is_artificial())
+              if ((subdomain_id == numbers::invalid_subdomain_id)
+                  ||
+                  (cell->subdomain_id() == subdomain_id))
+                next_free_dof
+                  = Implementation::distribute_dofs_on_cell (dof_handler,
+                                                             cell,
+                                                             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);
-- 
2.39.5