From e1a86af3614716be34370626bcd299a4658af902 Mon Sep 17 00:00:00 2001 From: David Wells Date: Wed, 25 Oct 2023 08:11:20 -0400 Subject: [PATCH] Use the standardized orientation functions in a few more places. --- source/base/qprojector.cc | 36 +++++++++++++++++++++++++----------- source/fe/fe.cc | 24 +++++++++++++----------- 2 files changed, 38 insertions(+), 22 deletions(-) diff --git a/source/base/qprojector.cc b/source/base/qprojector.cc index bdcb8bf7b2..5203a7eb85 100644 --- a/source/base/qprojector.cc +++ b/source/base/qprojector.cc @@ -1323,21 +1323,29 @@ QProjector::DataSetDescriptor::face(const ReferenceCell &reference_cell, const bool face_rotation, const unsigned int n_quadrature_points) { + const unsigned char combined_orientation = + internal::combined_face_orientation(face_orientation, + face_rotation, + face_flip); + // TODO: once we move to representing the default orientation as 0 (instead of + // 1) we can get rid of the dim = 1 check + Assert(dim == 1 || + (combined_orientation < reference_cell.n_face_orientations(face_no)), + ExcInternalError()); if (reference_cell == ReferenceCells::Triangle || reference_cell == ReferenceCells::Tetrahedron) { if (dim == 2) - return {(2 * face_no + (face_orientation ? 1 : 0)) * + return {(2 * face_no + + (combined_orientation == + ReferenceCell::default_combined_face_orientation() ? + 1 : + 0)) * n_quadrature_points}; else if (dim == 3) { - const unsigned char orientation = - internal::combined_face_orientation(face_orientation, - face_rotation, - face_flip); - Assert(orientation < 6, ExcInternalError()); return {(reference_cell.n_face_orientations(face_no) * face_no + - orientation) * + combined_orientation) * n_quadrature_points}; } } @@ -1424,6 +1432,13 @@ QProjector::DataSetDescriptor::face( { unsigned int offset = 0; + const unsigned char combined_orientation = + internal::combined_face_orientation(face_orientation, + face_rotation, + face_flip); + Assert(combined_orientation < reference_cell.n_face_orientations(face_no), + ExcInternalError()); + static const unsigned int X = numbers::invalid_unsigned_int; static const std::array scale_tri = {{2, 2, 2, X, X}}; static const std::array scale_tet = {{6, 6, 6, 6, X}}; @@ -1447,14 +1462,13 @@ QProjector::DataSetDescriptor::face( if (dim == 2) return {offset + - face_orientation * + (combined_orientation == + ReferenceCell::default_combined_face_orientation()) * quadrature[quadrature.size() == 1 ? 0 : face_no].size()}; else if (dim == 3) { return {offset + - internal::combined_face_orientation(face_orientation, - face_rotation, - face_flip) * + combined_orientation * quadrature[quadrature.size() == 1 ? 0 : face_no].size()}; } } diff --git a/source/fe/fe.cc b/source/fe/fe.cc index 9dd634495c..749566788a 100644 --- a/source/fe/fe.cc +++ b/source/fe/fe.cc @@ -25,6 +25,7 @@ #include #include +#include #include #include @@ -608,8 +609,9 @@ FiniteElement::face_to_cell_index(const unsigned int face_index, return (this->reference_cell().face_to_cell_vertices( face, face_vertex, - (face_orientation ? 1 : 0) + (face_rotation ? 2 : 0) + - (face_flip ? 4 : 0)) * + internal::combined_face_orientation(face_orientation, + face_rotation, + face_flip)) * this->n_dofs_per_vertex() + dof_index_on_vertex); } @@ -624,15 +626,15 @@ FiniteElement::face_to_cell_index(const unsigned int face_index, const unsigned int face_line = index / this->n_dofs_per_line(); const unsigned int dof_index_on_line = index % this->n_dofs_per_line(); - return ( - this->get_first_line_index() + - this->reference_cell().face_to_cell_lines(face, - face_line, - (face_orientation ? 1 : 0) + - (face_rotation ? 2 : 0) + - (face_flip ? 4 : 0)) * - this->n_dofs_per_line() + - dof_index_on_line); + return (this->get_first_line_index() + + this->reference_cell().face_to_cell_lines( + face, + face_line, + internal::combined_face_orientation(face_orientation, + face_rotation, + face_flip)) * + this->n_dofs_per_line() + + dof_index_on_line); } else // DoF is on a quad -- 2.39.5