]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Fix Warray-bounds warnings 10796/head
authorDaniel Arndt <arndtd@ornl.gov>
Tue, 4 Aug 2020 14:14:36 +0000 (10:14 -0400)
committerDaniel Arndt <arndtd@ornl.gov>
Tue, 4 Aug 2020 15:11:59 +0000 (11:11 -0400)
source/fe/mapping_fe.cc

index e47f04d77d8c5d922a4e64ca60d0467089c82439..746abb6785733e7157ca25adf210a0a983eefe61 100644 (file)
@@ -175,68 +175,74 @@ MappingFE<dim, spacedim>::InternalData::initialize_face(
       else if (this->fe.reference_cell_type() == ReferenceCell::Type::Tri)
         {
           Tensor<1, dim> t1;
-          t1[0] = 1;
-          t1[1] = 0;
+          constexpr int  d0 = 0;
+          constexpr int  d1 = 1 % dim;
+
+          t1[d0] = 1;
+          t1[d1] = 0;
           for (unsigned int i = 0; i < n_original_q_points; i++)
             unit_tangentials[0].emplace_back(t1);
-          t1[0] = -std::sqrt(0.5);
-          t1[1] = +std::sqrt(0.5);
+          t1[d0] = -std::sqrt(0.5);
+          t1[d1] = +std::sqrt(0.5);
           for (unsigned int i = 0; i < n_original_q_points; i++)
             unit_tangentials[1].emplace_back(t1);
-          t1[0] = 0;
-          t1[1] = -1;
+          t1[d0] = 0;
+          t1[d1] = -1;
           for (unsigned int i = 0; i < n_original_q_points; i++)
             unit_tangentials[2].emplace_back(t1);
         }
       else if (this->fe.reference_cell_type() == ReferenceCell::Type::Tet)
         {
           Tensor<1, dim> t1;
+          constexpr int  d0 = 0;
+          constexpr int  d1 = 1 % dim;
+          constexpr int  d2 = 2 % dim;
 
-          t1[0] = 0;
-          t1[1] = 1;
-          t1[2] = 0; // face 0
+          t1[d0] = 0;
+          t1[d1] = 1;
+          t1[d2] = 0; // face 0
           for (unsigned int i = 0; i < n_original_q_points; i++)
             unit_tangentials[0].emplace_back(t1);
 
-          t1[0] = 1;
-          t1[1] = 0;
-          t1[2] = 0; // face 0
+          t1[d0] = 1;
+          t1[d1] = 0;
+          t1[d2] = 0; // face 0
           for (unsigned int i = 0; i < n_original_q_points; i++)
             unit_tangentials[4].emplace_back(t1);
 
-          t1[0] = 1;
-          t1[1] = 0;
-          t1[2] = 0; // face 1
+          t1[d0] = 1;
+          t1[d1] = 0;
+          t1[d2] = 0; // face 1
           for (unsigned int i = 0; i < n_original_q_points; i++)
             unit_tangentials[1].emplace_back(t1);
 
-          t1[0] = 0;
-          t1[1] = 0;
-          t1[2] = 1; // face 1
+          t1[d0] = 0;
+          t1[d1] = 0;
+          t1[d2] = 1; // face 1
           for (unsigned int i = 0; i < n_original_q_points; i++)
             unit_tangentials[5].emplace_back(t1);
 
-          t1[0] = 0;
-          t1[1] = 0;
-          t1[2] = 1; // face 2
+          t1[d0] = 0;
+          t1[d1] = 0;
+          t1[d2] = 1; // face 2
           for (unsigned int i = 0; i < n_original_q_points; i++)
             unit_tangentials[2].emplace_back(t1);
 
-          t1[0] = 0;
-          t1[1] = 1;
-          t1[2] = 0; // face 2
+          t1[d0] = 0;
+          t1[d1] = 1;
+          t1[d2] = 0; // face 2
           for (unsigned int i = 0; i < n_original_q_points; i++)
             unit_tangentials[6].emplace_back(t1);
 
-          t1[0] = -std::pow(1.0 / 3.0, 1.0 / 4.0);
-          t1[1] = +std::pow(1.0 / 3.0, 1.0 / 4.0);
-          t1[2] = +0; // face 3
+          t1[d0] = -std::pow(1.0 / 3.0, 1.0 / 4.0);
+          t1[d1] = +std::pow(1.0 / 3.0, 1.0 / 4.0);
+          t1[d2] = +0; // face 3
           for (unsigned int i = 0; i < n_original_q_points; i++)
             unit_tangentials[3].emplace_back(t1);
 
-          t1[0] = -std::pow(1.0 / 3.0, 1.0 / 4.0);
-          t1[1] = +0;
-          t1[2] = +std::pow(1.0 / 3.0, 1.0 / 4.0); // face 3
+          t1[d0] = -std::pow(1.0 / 3.0, 1.0 / 4.0);
+          t1[d1] = +0;
+          t1[d2] = +std::pow(1.0 / 3.0, 1.0 / 4.0); // face 3
           for (unsigned int i = 0; i < n_original_q_points; i++)
             unit_tangentials[7].emplace_back(t1);
         }

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.