From: Daniel Arndt Date: Tue, 4 Aug 2020 14:14:36 +0000 (-0400) Subject: Fix Warray-bounds warnings X-Git-Tag: v9.3.0-rc1~1212^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3a63817332c3b4267b732f168637cd466802ee8d;p=dealii.git Fix Warray-bounds warnings --- diff --git a/source/fe/mapping_fe.cc b/source/fe/mapping_fe.cc index e47f04d77d..746abb6785 100644 --- a/source/fe/mapping_fe.cc +++ b/source/fe/mapping_fe.cc @@ -175,68 +175,74 @@ MappingFE::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); }