]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Use DoFInvalidAccessor to unify three partial specializations into one.
authorWolfgang Bangerth <bangerth@colostate.edu>
Wed, 13 Sep 2017 18:46:29 +0000 (12:46 -0600)
committerWolfgang Bangerth <bangerth@colostate.edu>
Fri, 15 Sep 2017 19:49:41 +0000 (13:49 -0600)
include/deal.II/dofs/dof_accessor.templates.h

index 0954c4e75305f2ad973c9539f36232c243fb8570..c04fc4d8e91268ffe2870b85fd0bd0db5185a577 100644 (file)
@@ -2873,87 +2873,14 @@ namespace internal
 
 
       /**
-       * Implement setting dof indices on a cell. Currently not implemented
-       * for hp::DoFHandler objects.
+       * Implement setting dof indices on a cell.
        */
-      template <int spacedim, bool level_dof_access>
-      static
-      void
-      set_dof_indices (DoFCellAccessor<DoFHandler<1,spacedim>, level_dof_access> &accessor,
-                       const std::vector<types::global_dof_index>          &local_dof_indices)
-      {
-        Assert (accessor.has_children() == false,
-                ExcInternalError());
-
-        const unsigned int dofs_per_vertex = accessor.get_fe().dofs_per_vertex,
-                           dofs_per_line   = accessor.get_fe().dofs_per_line,
-                           dofs_per_cell   = accessor.get_fe().dofs_per_cell;
-        (void)dofs_per_cell;
-
-        Assert (local_dof_indices.size() == dofs_per_cell,
-                ExcInternalError());
-
-        unsigned int index = 0;
-
-        for (unsigned int vertex=0; vertex<2; ++vertex)
-          for (unsigned int d=0; d<dofs_per_vertex; ++d, ++index)
-            accessor.set_vertex_dof_index(vertex,d,
-                                          local_dof_indices[index]);
-
-        for (unsigned int d=0; d<dofs_per_line; ++d, ++index)
-          accessor.set_dof_index(d, local_dof_indices[index]);
-
-        Assert (index == dofs_per_cell,
-                ExcInternalError());
-      }
-
-
-
-      template <int spacedim, bool level_dof_access>
-      static
-      void
-      set_dof_indices (DoFCellAccessor<DoFHandler<2,spacedim>, level_dof_access> &accessor,
-                       const std::vector<types::global_dof_index>          &local_dof_indices)
-      {
-        Assert (accessor.has_children() == false,
-                ExcInternalError());
-
-        const unsigned int dofs_per_vertex = accessor.get_fe().dofs_per_vertex,
-                           dofs_per_line   = accessor.get_fe().dofs_per_line,
-                           dofs_per_quad   = accessor.get_fe().dofs_per_quad,
-                           dofs_per_cell   = accessor.get_fe().dofs_per_cell;
-        (void)dofs_per_cell;
-
-        Assert (local_dof_indices.size() == dofs_per_cell,
-                ExcInternalError());
-
-        unsigned int index = 0;
-
-        for (unsigned int vertex=0; vertex<4; ++vertex)
-          for (unsigned int d=0; d<dofs_per_vertex; ++d, ++index)
-            accessor.set_vertex_dof_index(vertex,d,
-                                          local_dof_indices[index]);
-        for (unsigned int line=0; line<4; ++line)
-          for (unsigned int d=0; d<dofs_per_line; ++d, ++index)
-            accessor.line(line)->set_dof_index(d, local_dof_indices[index]);
-
-        for (unsigned int d=0; d<dofs_per_quad; ++d, ++index)
-          accessor.set_dof_index(d, local_dof_indices[index]);
-
-        Assert (index == dofs_per_cell,
-                ExcInternalError());
-      }
-
-
-
-      template <int spacedim, bool level_dof_access>
+      template <int dim, int spacedim, bool level_dof_access>
       static
       void
-      set_dof_indices (DoFCellAccessor<DoFHandler<3,spacedim>, level_dof_access> &accessor,
-                       const std::vector<types::global_dof_index>          &local_dof_indices)
+      set_dof_indices (DoFCellAccessor<DoFHandler<dim,spacedim>, level_dof_access> &accessor,
+                       const std::vector<types::global_dof_index>                  &local_dof_indices)
       {
-        const unsigned int dim = 3;
-
         Assert (accessor.has_children() == false,
                 ExcInternalError());
 
@@ -2973,20 +2900,26 @@ namespace internal
           for (unsigned int d=0; d<dofs_per_vertex; ++d, ++index)
             accessor.set_vertex_dof_index(vertex,d,
                                           local_dof_indices[index]);
-        // now copy dof numbers into the line. for lines with the
+        // now copy dof numbers into the line. for lines in 3d with the
         // wrong orientation, we have already made sure that we're ok
         // by picking the correct vertices (this happens automatically
         // in the vertex() function). however, if the line is in wrong
         // orientation, we look at it in flipped orientation and we
         // will have to adjust the shape function indices that we see
         // to correspond to the correct (cell-local) ordering.
+        //
+        // of course, if dim<3, then there is nothing to adjust
         for (unsigned int line=0; line<GeometryInfo<dim>::lines_per_cell; ++line)
           for (unsigned int d=0; d<dofs_per_line; ++d, ++index)
-            accessor.line(line)->set_dof_index(accessor.dof_handler->get_fe().
+            accessor.line(line)->set_dof_index(dim < 3
+                                               ?
+                                               d
+                                               :
+                                               accessor.dof_handler->get_fe().
                                                adjust_line_dof_index_for_line_orientation(d,
                                                    accessor.line_orientation(line)),
                                                local_dof_indices[index]);
-        // now copy dof numbers into the face. for faces with the
+        // now copy dof numbers into the face. for faces in 3d with the
         // wrong orientation, we have already made sure that we're ok
         // by picking the correct lines and vertices (this happens
         // automatically in the line() and vertex()
@@ -2995,9 +2928,15 @@ namespace internal
         // adjust the shape function indices that we see to correspond
         // to the correct (cell-local) ordering. The same applies, if
         // the face_rotation or face_orientation is non-standard
+        //
+        // again, if dim<3, then there is nothing to adjust
         for (unsigned int quad=0; quad<GeometryInfo<dim>::quads_per_cell; ++quad)
           for (unsigned int d=0; d<dofs_per_quad; ++d, ++index)
-            accessor.quad(quad)->set_dof_index(accessor.dof_handler->get_fe().
+            accessor.quad(quad)->set_dof_index(dim < 3
+                                               ?
+                                               d
+                                               :
+                                               accessor.dof_handler->get_fe().
                                                adjust_quad_dof_index_for_face_orientation(d,
                                                    accessor.face_orientation(quad),
                                                    accessor.face_flip(quad),

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.