]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Replace some hard written constants by using GeometryInfo
authorPeter Munch <peterrmuench@gmail.com>
Tue, 10 Mar 2020 09:39:49 +0000 (10:39 +0100)
committerPeter Munch <peterrmuench@gmail.com>
Tue, 10 Mar 2020 09:39:49 +0000 (10:39 +0100)
include/deal.II/dofs/dof_accessor.templates.h
include/deal.II/grid/tria_accessor.templates.h

index aa30251af72eecbe8bbad460a460cb0b1c1a6fe7..02649b8da5f2684a17ba86db53bab1cde3a28493 100644 (file)
@@ -1814,7 +1814,8 @@ namespace internal
                          dofs_per_line =
                            accessor.get_fe(fe_index).dofs_per_line;
       std::vector<types::global_dof_index>::iterator next = dof_indices.begin();
-      for (unsigned int vertex = 0; vertex < 2; ++vertex)
+      for (unsigned int vertex = 0; vertex < GeometryInfo<1>::vertices_per_cell;
+           ++vertex)
         for (unsigned int d = 0; d < dofs_per_vertex; ++d)
           *next++ = accessor.vertex_dof_index(vertex, d, fe_index);
       for (unsigned int d = 0; d < dofs_per_line; ++d)
@@ -1837,7 +1838,8 @@ namespace internal
                          dofs_per_quad =
                            accessor.get_fe(fe_index).dofs_per_quad;
       std::vector<types::global_dof_index>::iterator next = dof_indices.begin();
-      for (unsigned int vertex = 0; vertex < 4; ++vertex)
+      for (unsigned int vertex = 0; vertex < GeometryInfo<2>::vertices_per_cell;
+           ++vertex)
         for (unsigned int d = 0; d < dofs_per_vertex; ++d)
           *next++ = accessor.vertex_dof_index(vertex, d, fe_index);
       // now copy dof numbers from the line. for
@@ -1851,7 +1853,8 @@ namespace internal
       // to adjust the shape function indices that
       // we see to correspond to the correct
       // (face-local) ordering.
-      for (unsigned int line = 0; line < 4; ++line)
+      for (unsigned int line = 0; line < GeometryInfo<2>::vertices_per_cell;
+           ++line)
         for (unsigned int d = 0; d < dofs_per_line; ++d)
           *next++ = accessor.line(line)->dof_index(
             accessor.get_fe(fe_index)
@@ -1879,7 +1882,8 @@ namespace internal
                            accessor.get_fe(fe_index).dofs_per_quad,
                          dofs_per_hex = accessor.get_fe(fe_index).dofs_per_hex;
       std::vector<types::global_dof_index>::iterator next = dof_indices.begin();
-      for (unsigned int vertex = 0; vertex < 8; ++vertex)
+      for (unsigned int vertex = 0; vertex < GeometryInfo<3>::vertices_per_cell;
+           ++vertex)
         for (unsigned int d = 0; d < dofs_per_vertex; ++d)
           *next++ = accessor.vertex_dof_index(vertex, d, fe_index);
       // now copy dof numbers from the line. for
@@ -1893,7 +1897,8 @@ namespace internal
       // adjust the shape function indices that we
       // see to correspond to the correct
       // (cell-local) ordering.
-      for (unsigned int line = 0; line < 12; ++line)
+      for (unsigned int line = 0; line < GeometryInfo<3>::lines_per_cell;
+           ++line)
         for (unsigned int d = 0; d < dofs_per_line; ++d)
           *next++ = accessor.line(line)->dof_index(
             accessor.get_fe(fe_index)
@@ -1913,7 +1918,8 @@ namespace internal
       // correct (cell-local) ordering. The same
       // applies, if the face_rotation or
       // face_orientation is non-standard
-      for (unsigned int quad = 0; quad < 6; ++quad)
+      for (unsigned int quad = 0; quad < GeometryInfo<3>::faces_per_cell;
+           ++quad)
         for (unsigned int d = 0; d < dofs_per_quad; ++d)
           *next++ = accessor.quad(quad)->dof_index(
             accessor.get_fe(fe_index)
@@ -2057,22 +2063,28 @@ DoFAccessor<structdim, DoFHandlerType, level_dof_access>::get_dof_indices(
     {
       case 1:
         Assert(dof_indices.size() ==
-                 (2 * this->dof_handler->get_fe(fe_index).dofs_per_vertex +
+                 (GeometryInfo<1>::vertices_per_cell *
+                    this->dof_handler->get_fe(fe_index).dofs_per_vertex +
                   this->dof_handler->get_fe(fe_index).dofs_per_line),
                ExcVectorDoesNotMatch());
         break;
       case 2:
         Assert(dof_indices.size() ==
-                 (4 * this->dof_handler->get_fe(fe_index).dofs_per_vertex +
-                  4 * this->dof_handler->get_fe(fe_index).dofs_per_line +
+                 (GeometryInfo<2>::vertices_per_cell *
+                    this->dof_handler->get_fe(fe_index).dofs_per_vertex +
+                  GeometryInfo<2>::lines_per_cell *
+                    this->dof_handler->get_fe(fe_index).dofs_per_line +
                   this->dof_handler->get_fe(fe_index).dofs_per_quad),
                ExcVectorDoesNotMatch());
         break;
       case 3:
         Assert(dof_indices.size() ==
-                 (8 * this->dof_handler->get_fe(fe_index).dofs_per_vertex +
-                  12 * this->dof_handler->get_fe(fe_index).dofs_per_line +
-                  6 * this->dof_handler->get_fe(fe_index).dofs_per_quad +
+                 (GeometryInfo<3>::vertices_per_cell *
+                    this->dof_handler->get_fe(fe_index).dofs_per_vertex +
+                  GeometryInfo<3>::lines_per_cell *
+                    this->dof_handler->get_fe(fe_index).dofs_per_line +
+                  GeometryInfo<3>::faces_per_cell *
+                    this->dof_handler->get_fe(fe_index).dofs_per_quad +
                   this->dof_handler->get_fe(fe_index).dofs_per_hex),
                ExcVectorDoesNotMatch());
         break;
@@ -2120,7 +2132,8 @@ DoFAccessor<structdim, DoFHandlerType, level_dof_access>::get_mg_dof_indices(
       case 1:
         {
           Assert(dof_indices.size() ==
-                   2 * this->dof_handler->get_fe(fe_index).dofs_per_vertex +
+                   GeometryInfo<1>::vertices_per_cell *
+                       this->dof_handler->get_fe(fe_index).dofs_per_vertex +
                      this->dof_handler->get_fe(fe_index).dofs_per_line,
                  ExcVectorDoesNotMatch());
           break;
@@ -2129,8 +2142,10 @@ DoFAccessor<structdim, DoFHandlerType, level_dof_access>::get_mg_dof_indices(
       case 2:
         {
           Assert(dof_indices.size() ==
-                   4 * (this->dof_handler->get_fe(fe_index).dofs_per_vertex +
-                        this->dof_handler->get_fe(fe_index).dofs_per_line) +
+                   GeometryInfo<2>::vertices_per_cell *
+                       this->dof_handler->get_fe(fe_index).dofs_per_vertex +
+                     GeometryInfo<2>::lines_per_cell *
+                       this->dof_handler->get_fe(fe_index).dofs_per_line +
                      this->dof_handler->get_fe(fe_index).dofs_per_quad,
                  ExcVectorDoesNotMatch());
           break;
@@ -2139,9 +2154,12 @@ DoFAccessor<structdim, DoFHandlerType, level_dof_access>::get_mg_dof_indices(
       case 3:
         {
           Assert(dof_indices.size() ==
-                   8 * this->dof_handler->get_fe(fe_index).dofs_per_vertex +
-                     12 * this->dof_handler->get_fe(fe_index).dofs_per_line +
-                     6 * this->dof_handler->get_fe(fe_index).dofs_per_quad +
+                   GeometryInfo<3>::vertices_per_cell *
+                       this->dof_handler->get_fe(fe_index).dofs_per_vertex +
+                     GeometryInfo<3>::lines_per_cell *
+                       this->dof_handler->get_fe(fe_index).dofs_per_line +
+                     GeometryInfo<3>::faces_per_cell *
+                       this->dof_handler->get_fe(fe_index).dofs_per_quad +
                      this->dof_handler->get_fe(fe_index).dofs_per_hex,
                  ExcVectorDoesNotMatch());
           break;
@@ -2172,7 +2190,8 @@ DoFAccessor<structdim, DoFHandlerType, level_dof_access>::set_mg_dof_indices(
       case 1:
         {
           Assert(dof_indices.size() ==
-                   2 * this->dof_handler->get_fe(fe_index).dofs_per_vertex +
+                   GeometryInfo<1>::vertices_per_cell *
+                       this->dof_handler->get_fe(fe_index).dofs_per_vertex +
                      this->dof_handler->get_fe(fe_index).dofs_per_line,
                  ExcVectorDoesNotMatch());
           break;
@@ -2181,8 +2200,10 @@ DoFAccessor<structdim, DoFHandlerType, level_dof_access>::set_mg_dof_indices(
       case 2:
         {
           Assert(dof_indices.size() ==
-                   4 * (this->dof_handler->get_fe(fe_index).dofs_per_vertex +
-                        this->dof_handler->get_fe(fe_index).dofs_per_line) +
+                   GeometryInfo<2>::vertices_per_cell *
+                       this->dof_handler->get_fe(fe_index).dofs_per_vertex +
+                     GeometryInfo<2>::lines_per_cell *
+                       this->dof_handler->get_fe(fe_index).dofs_per_line +
                      this->dof_handler->get_fe(fe_index).dofs_per_quad,
                  ExcVectorDoesNotMatch());
           break;
@@ -2191,9 +2212,12 @@ DoFAccessor<structdim, DoFHandlerType, level_dof_access>::set_mg_dof_indices(
       case 3:
         {
           Assert(dof_indices.size() ==
-                   8 * this->dof_handler->get_fe(fe_index).dofs_per_vertex +
-                     12 * this->dof_handler->get_fe(fe_index).dofs_per_line +
-                     6 * this->dof_handler->get_fe(fe_index).dofs_per_quad +
+                   GeometryInfo<3>::vertices_per_cell *
+                       this->dof_handler->get_fe(fe_index).dofs_per_vertex +
+                     GeometryInfo<3>::lines_per_cell *
+                       this->dof_handler->get_fe(fe_index).dofs_per_line +
+                     GeometryInfo<3>::faces_per_cell *
+                       this->dof_handler->get_fe(fe_index).dofs_per_quad +
                      this->dof_handler->get_fe(fe_index).dofs_per_hex,
                  ExcVectorDoesNotMatch());
           break;
@@ -2764,7 +2788,9 @@ namespace internal
              ->cell_dof_indices_cache.begin() +
            accessor.present_index * dofs_per_cell);
 
-        for (unsigned int vertex = 0; vertex < 2; ++vertex)
+        for (unsigned int vertex = 0;
+             vertex < GeometryInfo<1>::vertices_per_cell;
+             ++vertex)
           for (unsigned int d = 0; d < dofs_per_vertex; ++d)
             *next++ = accessor.vertex_dof_index(vertex, d);
         for (unsigned int d = 0; d < dofs_per_line; ++d)
@@ -2810,10 +2836,13 @@ namespace internal
              ->cell_dof_indices_cache.begin() +
            accessor.present_index * dofs_per_cell);
 
-        for (unsigned int vertex = 0; vertex < 4; ++vertex)
+        for (unsigned int vertex = 0;
+             vertex < GeometryInfo<2>::vertices_per_cell;
+             ++vertex)
           for (unsigned int d = 0; d < dofs_per_vertex; ++d)
             *next++ = accessor.vertex_dof_index(vertex, d);
-        for (unsigned int line = 0; line < 4; ++line)
+        for (unsigned int line = 0; line < GeometryInfo<2>::lines_per_cell;
+             ++line)
           for (unsigned int d = 0; d < dofs_per_line; ++d)
             *next++ = accessor.line(line)->dof_index(d);
         for (unsigned int d = 0; d < dofs_per_quad; ++d)
@@ -2859,7 +2888,9 @@ namespace internal
              ->cell_dof_indices_cache.begin() +
            accessor.present_index * dofs_per_cell);
 
-        for (unsigned int vertex = 0; vertex < 8; ++vertex)
+        for (unsigned int vertex = 0;
+             vertex < GeometryInfo<3>::vertices_per_cell;
+             ++vertex)
           for (unsigned int d = 0; d < dofs_per_vertex; ++d)
             *next++ = accessor.vertex_dof_index(vertex, d);
         // now copy dof numbers from the line. for
@@ -2873,7 +2904,8 @@ namespace internal
         // adjust the shape function indices that we
         // see to correspond to the correct
         // (cell-local) ordering.
-        for (unsigned int line = 0; line < 12; ++line)
+        for (unsigned int line = 0; line < GeometryInfo<3>::lines_per_cell;
+             ++line)
           for (unsigned int d = 0; d < dofs_per_line; ++d)
             *next++ = accessor.line(line)->dof_index(
               accessor.dof_handler->get_fe()
@@ -2892,7 +2924,8 @@ namespace internal
         // correct (cell-local) ordering. The same
         // applies, if the face_rotation or
         // face_orientation is non-standard
-        for (unsigned int quad = 0; quad < 6; ++quad)
+        for (unsigned int quad = 0; quad < GeometryInfo<3>::faces_per_cell;
+             ++quad)
           for (unsigned int d = 0; d < dofs_per_quad; ++d)
             *next++ = accessor.quad(quad)->dof_index(
               accessor.dof_handler->get_fe()
index a4b5d33003a96db7735a38e24e329b4e606ca5ca..b0832b3ca312946e87f3b37774b48d5205fdefb2 100644 (file)
@@ -640,21 +640,22 @@ namespace internal
         // quad to take it, b) which line
         // therein it is if the face is
         // oriented correctly
-        static const unsigned int lookup_table[12][2] = {
-          {4, 0}, // take first four lines from bottom face
-          {4, 1},
-          {4, 2},
-          {4, 3},
-
-          {5, 0}, // second four lines from top face
-          {5, 1},
-          {5, 2},
-          {5, 3},
-
-          {0, 0}, // the rest randomly
-          {1, 0},
-          {0, 1},
-          {1, 1}};
+        static const unsigned int
+          lookup_table[GeometryInfo<3>::lines_per_cell][2] = {
+            {4, 0}, // take first four lines from bottom face
+            {4, 1},
+            {4, 2},
+            {4, 3},
+
+            {5, 0}, // second four lines from top face
+            {5, 1},
+            {5, 2},
+            {5, 3},
+
+            {0, 0}, // the rest randomly
+            {1, 0},
+            {0, 1},
+            {1, 1}};
 
         // respect non-standard faces by calling the
         // reordering function from GeometryInfo
@@ -858,21 +859,22 @@ namespace internal
         // quad to take it, b) which line
         // therein it is if the face is
         // oriented correctly
-        static const unsigned int lookup_table[12][2] = {
-          {4, 0}, // take first four lines from bottom face
-          {4, 1},
-          {4, 2},
-          {4, 3},
-
-          {5, 0}, // second four lines from top face
-          {5, 1},
-          {5, 2},
-          {5, 3},
-
-          {0, 0}, // the rest randomly
-          {1, 0},
-          {0, 1},
-          {1, 1}};
+        static const unsigned int
+          lookup_table[GeometryInfo<3>::lines_per_cell][2] = {
+            {4, 0}, // take first four lines from bottom face
+            {4, 1},
+            {4, 2},
+            {4, 3},
+
+            {5, 0}, // second four lines from top face
+            {5, 1},
+            {5, 2},
+            {5, 3},
+
+            {0, 0}, // the rest randomly
+            {1, 0},
+            {0, 1},
+            {1, 1}};
 
         const unsigned int quad_index     = lookup_table[line][0];
         const unsigned int std_line_index = lookup_table[line][1];

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.