]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Avoid more compiler warnings about array access
authorDaniel Arndt <arndtd@ornl.gov>
Mon, 12 Dec 2022 20:22:53 +0000 (20:22 +0000)
committerDaniel Arndt <arndtd@ornl.gov>
Mon, 12 Dec 2022 20:31:25 +0000 (15:31 -0500)
source/base/data_out_base.cc
source/base/polynomials_rt_bubbles.cc

index 8826a607c020b4ba09f27d5961e8d300bbf47a15..60eaf78c4b6892134986118ee53a8de7cada0bfd 100644 (file)
@@ -3690,6 +3690,12 @@ namespace DataOutBase
             const unsigned int n1              = (dim > 0) ? n : 1;
             const unsigned int n2              = (dim > 1) ? n : 1;
             const unsigned int n3              = (dim > 2) ? n : 1;
+            const unsigned int x_minus         = (dim > 0) ? 0 : 0;
+            const unsigned int x_plus          = (dim > 0) ? 1 : 0;
+            const unsigned int y_minus         = (dim > 1) ? 2 : 0;
+            const unsigned int y_plus          = (dim > 1) ? 3 : 0;
+            const unsigned int z_minus         = (dim > 2) ? 4 : 0;
+            const unsigned int z_plus          = (dim > 2) ? 5 : 0;
             unsigned int       cells_per_patch = Utilities::fixed_power<dim>(n);
             unsigned int       dx              = 1;
             unsigned int       dy              = n;
@@ -3716,7 +3722,7 @@ namespace DataOutBase
                     // Direction -x Last cell in row of other patch
                     if (i1 == 0)
                       {
-                        const unsigned int nn = patch.neighbors[0];
+                        const unsigned int nn = patch.neighbors[x_minus];
                         out << '\t';
                         if (nn != patch.no_neighbor)
                           out
@@ -3731,7 +3737,7 @@ namespace DataOutBase
                     // Direction +x First cell in row of other patch
                     if (i1 == n - 1)
                       {
-                        const unsigned int nn = patch.neighbors[1];
+                        const unsigned int nn = patch.neighbors[x_plus];
                         out << '\t';
                         if (nn != patch.no_neighbor)
                           out << (nn * cells_per_patch + ny + nz);
@@ -3747,7 +3753,7 @@ namespace DataOutBase
                     // Direction -y
                     if (i2 == 0)
                       {
-                        const unsigned int nn = patch.neighbors[2];
+                        const unsigned int nn = patch.neighbors[y_minus];
                         out << '\t';
                         if (nn != patch.no_neighbor)
                           out
@@ -3762,7 +3768,7 @@ namespace DataOutBase
                     // Direction +y
                     if (i2 == n - 1)
                       {
-                        const unsigned int nn = patch.neighbors[3];
+                        const unsigned int nn = patch.neighbors[y_plus];
                         out << '\t';
                         if (nn != patch.no_neighbor)
                           out << (nn * cells_per_patch + nx + nz);
@@ -3779,7 +3785,7 @@ namespace DataOutBase
                     // Direction -z
                     if (i3 == 0)
                       {
-                        const unsigned int nn = patch.neighbors[4];
+                        const unsigned int nn = patch.neighbors[z_minus];
                         out << '\t';
                         if (nn != patch.no_neighbor)
                           out
@@ -3794,7 +3800,7 @@ namespace DataOutBase
                     // Direction +z
                     if (i3 == n - 1)
                       {
-                        const unsigned int nn = patch.neighbors[5];
+                        const unsigned int nn = patch.neighbors[z_plus];
                         out << '\t';
                         if (nn != patch.no_neighbor)
                           out << (nn * cells_per_patch + nx + ny);
index 62fbcbdef310302d30bffd9572dfb83eb35d3512..edc10df6b93a03233f9397e3c912a50cc9f17782 100644 (file)
@@ -114,8 +114,11 @@ PolynomialsRT_Bubbles<dim>::evaluate(
   double monoval_jplus[dim][n_derivatives + 1];
 
   unsigned int start = n_sub;
-
+#ifdef DEAL_II_HAVE_CXX17
+  if constexpr (dim == 2)
+#else
   if (dim == 2)
+#endif
     {
       // In 2d the curl part of the space is spanned by the vectors
       // of two types. The first one is
@@ -198,7 +201,11 @@ PolynomialsRT_Bubbles<dim>::evaluate(
         }
       Assert(start == this->n() - my_degree - 1, ExcInternalError());
     }
+#ifdef DEAL_II_HAVE_CXX17
+  else if constexpr (dim == 3)
+#else
   else if (dim == 3)
+#endif
     {
       // In 3d the first type of basis vector is
       //  [ x^i * y^j * z^k * (j+k+2) ]

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.