From d70ce0679570c41ed235df40f8f50be91e1c95f2 Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Wed, 8 Feb 2023 18:06:22 -0700 Subject: [PATCH] Make it clear that the remaining code below an if-else chain is really the 'else' case. --- source/base/qprojector.cc | 154 +++++++++++++++++++------------------- 1 file changed, 78 insertions(+), 76 deletions(-) diff --git a/source/base/qprojector.cc b/source/base/qprojector.cc index d42eedf21a..e7b59b3427 100644 --- a/source/base/qprojector.cc +++ b/source/base/qprojector.cc @@ -832,97 +832,99 @@ QProjector<3>::project_to_all_faces(const ReferenceCell & reference_cell, return process(face_vertex_locations); } + else + { + Assert(reference_cell == ReferenceCells::Hexahedron, ExcNotImplemented()); + const unsigned int dim = 3; - Assert(reference_cell == ReferenceCells::Hexahedron, ExcNotImplemented()); - - const unsigned int dim = 3; - - unsigned int n_points_total = 0; + unsigned int n_points_total = 0; - if (quadrature.size() == 1) - n_points_total = quadrature[0].size() * GeometryInfo::faces_per_cell; - else - { - AssertDimension(quadrature.size(), GeometryInfo::faces_per_cell); - for (unsigned int i = 0; i < quadrature.size(); ++i) - n_points_total += quadrature[i].size(); - } + if (quadrature.size() == 1) + n_points_total = + quadrature[0].size() * GeometryInfo::faces_per_cell; + else + { + AssertDimension(quadrature.size(), GeometryInfo::faces_per_cell); + for (unsigned int i = 0; i < quadrature.size(); ++i) + n_points_total += quadrature[i].size(); + } - n_points_total *= 8; + n_points_total *= 8; - // first fix quadrature points - std::vector> q_points; - q_points.reserve(n_points_total); - std::vector> help; - help.reserve(quadrature.max_n_quadrature_points()); + // first fix quadrature points + std::vector> q_points; + q_points.reserve(n_points_total); + std::vector> help; + help.reserve(quadrature.max_n_quadrature_points()); - std::vector weights; - weights.reserve(n_points_total); + std::vector weights; + weights.reserve(n_points_total); - // do the following for all possible - // mutations of a face (mutation==0 - // corresponds to a face with standard - // orientation, no flip and no rotation) - for (unsigned int i = 0; i < 8; ++i) - { - // project to each face and append - // results - for (unsigned int face = 0; face < GeometryInfo::faces_per_cell; - ++face) + // do the following for all possible + // mutations of a face (mutation==0 + // corresponds to a face with standard + // orientation, no flip and no rotation) + for (unsigned int i = 0; i < 8; ++i) { - SubQuadrature mutation; - - const auto &quadrature_f = - quadrature[quadrature.size() == 1 ? 0 : face]; - switch (i) + // project to each face and append + // results + for (unsigned int face = 0; face < GeometryInfo::faces_per_cell; + ++face) { - case 0: - mutation = quadrature_f; - break; - case 1: - mutation = internal::QProjector::rotate(quadrature_f, 1); - break; - case 2: - mutation = internal::QProjector::rotate(quadrature_f, 2); - break; - case 3: - mutation = internal::QProjector::rotate(quadrature_f, 3); - break; - case 4: - mutation = internal::QProjector::reflect(quadrature_f); - break; - case 5: - mutation = internal::QProjector::rotate( - internal::QProjector::reflect(quadrature_f), 3); - break; - case 6: - mutation = internal::QProjector::rotate( - internal::QProjector::reflect(quadrature_f), 2); - break; - case 7: - mutation = internal::QProjector::rotate( - internal::QProjector::reflect(quadrature_f), 1); - break; - default: - Assert(false, ExcInternalError()) - } + SubQuadrature mutation; - help.resize(quadrature[quadrature.size() == 1 ? 0 : face].size()); - project_to_face(reference_cell, mutation, face, help); - std::copy(help.begin(), help.end(), std::back_inserter(q_points)); + const auto &quadrature_f = + quadrature[quadrature.size() == 1 ? 0 : face]; + switch (i) + { + case 0: + mutation = quadrature_f; + break; + case 1: + mutation = internal::QProjector::rotate(quadrature_f, 1); + break; + case 2: + mutation = internal::QProjector::rotate(quadrature_f, 2); + break; + case 3: + mutation = internal::QProjector::rotate(quadrature_f, 3); + break; + case 4: + mutation = internal::QProjector::reflect(quadrature_f); + break; + case 5: + mutation = internal::QProjector::rotate( + internal::QProjector::reflect(quadrature_f), 3); + break; + case 6: + mutation = internal::QProjector::rotate( + internal::QProjector::reflect(quadrature_f), 2); + break; + case 7: + mutation = internal::QProjector::rotate( + internal::QProjector::reflect(quadrature_f), 1); + break; + default: + Assert(false, ExcInternalError()) + } + + help.resize(quadrature[quadrature.size() == 1 ? 0 : face].size()); + project_to_face(reference_cell, mutation, face, help); + std::copy(help.begin(), help.end(), std::back_inserter(q_points)); - std::copy(mutation.get_weights().begin(), - mutation.get_weights().end(), - std::back_inserter(weights)); + std::copy(mutation.get_weights().begin(), + mutation.get_weights().end(), + std::back_inserter(weights)); + } } - } - Assert(q_points.size() == n_points_total, ExcInternalError()); - Assert(weights.size() == n_points_total, ExcInternalError()); + Assert(q_points.size() == n_points_total, ExcInternalError()); + Assert(weights.size() == n_points_total, ExcInternalError()); - return Quadrature(q_points, weights); + return Quadrature(q_points, weights); + } } -- 2.39.5