From 1c30941dabbfe8c72fbc64318ae255f081cc4f9e Mon Sep 17 00:00:00 2001 From: Daniel Arndt Date: Mon, 12 Dec 2022 20:22:53 +0000 Subject: [PATCH] Avoid more compiler warnings about array access --- source/base/data_out_base.cc | 18 ++++++++++++------ source/base/polynomials_rt_bubbles.cc | 9 ++++++++- 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/source/base/data_out_base.cc b/source/base/data_out_base.cc index 8826a607c0..60eaf78c4b 100644 --- a/source/base/data_out_base.cc +++ b/source/base/data_out_base.cc @@ -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(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); diff --git a/source/base/polynomials_rt_bubbles.cc b/source/base/polynomials_rt_bubbles.cc index 62fbcbdef3..edc10df6b9 100644 --- a/source/base/polynomials_rt_bubbles.cc +++ b/source/base/polynomials_rt_bubbles.cc @@ -114,8 +114,11 @@ PolynomialsRT_Bubbles::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::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) ] -- 2.39.5