From 5c5d009a4a78bcdad687905e0cc26e4bd84e6ce9 Mon Sep 17 00:00:00 2001 From: David Wells Date: Wed, 27 Dec 2023 20:24:52 -0500 Subject: [PATCH] Use the combined orientation in another FiniteElement function. --- .../changes/incompatibilities/20231221DavidWells | 9 +++++---- include/deal.II/fe/fe.h | 16 +++++++++------- include/deal.II/grid/tria_accessor.templates.h | 15 +++++++++------ source/fe/fe.cc | 12 +++++++++--- 4 files changed, 32 insertions(+), 20 deletions(-) diff --git a/doc/news/changes/incompatibilities/20231221DavidWells b/doc/news/changes/incompatibilities/20231221DavidWells index 4c1e189688..7714e394b4 100644 --- a/doc/news/changes/incompatibilities/20231221DavidWells +++ b/doc/news/changes/incompatibilities/20231221DavidWells @@ -1,6 +1,7 @@ -Changed: FiniteElement::adjust_quad_dof_index_for_face_orientation() and -FiniteElement::face_to_cell_index() now use the standardized -combined_orientation orientation encoding as input arguments rather -than three booleans. +Changed: FiniteElement::adjust_quad_dof_index_for_face_orientation(), +FiniteElement::face_to_cell_index(), and +FiniteElement::adjust_line_dof_index_for_line_orientation() now use the +standardized combined_orientation orientation encoding as input +arguments rather than one or three booleans.
(David Wells, 2023/12/21) diff --git a/include/deal.II/fe/fe.h b/include/deal.II/fe/fe.h index 3c448ee5c4..a44e0ca838 100644 --- a/include/deal.II/fe/fe.h +++ b/include/deal.II/fe/fe.h @@ -1524,15 +1524,17 @@ public: ReferenceCell::default_combined_face_orientation()) const; /** - * For lines with non-standard line_orientation in 3d, the dofs on lines - * have to be permuted in order to be combined with the correct shape - * functions. Given a local dof @p index on a line, return the local index, - * if the line has non-standard line_orientation. In 2d and 1d there is no - * need for permutation, so the given index is simply returned. + * Given a local dof @p index on a line and the orientation @p + * combined_orientation of that line, return the local dof which accounts for + * @p combined_orientation. + * + * @note In both 1d and all-quadrilateral meshes in 2d all lines have the + * standard orientation. */ unsigned int - adjust_line_dof_index_for_line_orientation(const unsigned int index, - const bool line_orientation) const; + adjust_line_dof_index_for_line_orientation( + const unsigned int index, + const unsigned char combined_orientation) const; /** * Return in which of the vector components of this finite element the @p diff --git a/include/deal.II/grid/tria_accessor.templates.h b/include/deal.II/grid/tria_accessor.templates.h index ddac77f8c7..2466498a59 100644 --- a/include/deal.II/grid/tria_accessor.templates.h +++ b/include/deal.II/grid/tria_accessor.templates.h @@ -1104,7 +1104,7 @@ namespace internal * cell->line_orientation(), 1d specialization */ template - static std::array + static std::array get_line_orientations_of_cell(const TriaAccessor<1, dim, spacedim> &) { Assert(false, ExcInternalError()); @@ -1118,14 +1118,17 @@ namespace internal * cell->line_orientation(), 2d specialization */ template - static std::array + static std::array get_line_orientations_of_cell(const TriaAccessor<2, dim, spacedim> &cell) { // For 2d cells the access cell->line_orientation() is already // efficient - std::array line_orientations = {}; + std::array line_orientations = {}; for (const unsigned int line : cell.line_indices()) - line_orientations[line] = cell.line_orientation(line); + line_orientations[line] = + cell.line_orientation(line) == true ? + ReferenceCell::default_combined_face_orientation() : + ReferenceCell::reversed_combined_line_orientation(); return line_orientations; } @@ -1136,10 +1139,10 @@ namespace internal * cell->line_orientation(), 3d specialization */ template - static std::array + static std::array get_line_orientations_of_cell(const TriaAccessor<3, dim, spacedim> &cell) { - std::array line_orientations = {}; + std::array line_orientations = {}; // For hexahedra, the classical access via quads -> lines is too // inefficient. Unroll this code here to allow the compiler to inline diff --git a/source/fe/fe.cc b/source/fe/fe.cc index aadcaf7bfa..91911b6113 100644 --- a/source/fe/fe.cc +++ b/source/fe/fe.cc @@ -683,14 +683,19 @@ FiniteElement::adjust_quad_dof_index_for_face_orientation( template unsigned int FiniteElement::adjust_line_dof_index_for_line_orientation( - const unsigned int index, - const bool line_orientation) const + const unsigned int index, + const unsigned char combined_orientation) const { // We orient quads (and 1D meshes are always oriented) so always skip those // cases // // TODO - we may want to change this in the future: see also the notes in // face_to_cell_index() + Assert(combined_orientation == + ReferenceCell::default_combined_face_orientation() || + combined_orientation == + ReferenceCell::reversed_combined_line_orientation(), + ExcInternalError()); if (this->reference_cell() == ReferenceCells::Line || this->reference_cell() == ReferenceCells::Quadrilateral) return index; @@ -699,7 +704,8 @@ FiniteElement::adjust_line_dof_index_for_line_orientation( Assert(adjust_line_dof_index_for_line_orientation_table.size() == this->n_dofs_per_line(), ExcInternalError()); - if (line_orientation) + if (combined_orientation == + ReferenceCell::default_combined_face_orientation()) return index; else return index + adjust_line_dof_index_for_line_orientation_table[index]; -- 2.39.5