From d00345ce47125e5261f861402e6f7eb0a529c4b1 Mon Sep 17 00:00:00 2001 From: David Wells Date: Sat, 6 Apr 2024 13:17:54 -0400 Subject: [PATCH] TriaAccessor: permit calling set_combined_face_orientation() in 2d. --- include/deal.II/grid/tria_accessor.h | 6 +-- .../deal.II/grid/tria_accessor.templates.h | 45 ++++++++++++------- 2 files changed, 30 insertions(+), 21 deletions(-) diff --git a/include/deal.II/grid/tria_accessor.h b/include/deal.II/grid/tria_accessor.h index ebc3dbd051..1b783c7d26 100644 --- a/include/deal.II/grid/tria_accessor.h +++ b/include/deal.II/grid/tria_accessor.h @@ -1818,10 +1818,8 @@ private: /** * Set the combined face orientation (i.e., the integer that uniquely encodes - * the orientation, flip, and rotation). - * - * It is only possible to set the face_orientation of cells in 3d (i.e. - * structdim==3 && dim==3). + * the orientation, flip, and rotation). This function is only implemented for + * objects which have faces, i.e., for structdim == dim. * * @ingroup reordering */ diff --git a/include/deal.II/grid/tria_accessor.templates.h b/include/deal.II/grid/tria_accessor.templates.h index 6538ea24ce..6fd99cee44 100644 --- a/include/deal.II/grid/tria_accessor.templates.h +++ b/include/deal.II/grid/tria_accessor.templates.h @@ -862,25 +862,36 @@ namespace internal template inline static void set_combined_face_orientation( - const TriaAccessor &, - const unsigned int, - const unsigned char) - { - DEAL_II_ASSERT_UNREACHABLE(); - } - - - - inline static void - set_combined_face_orientation(const TriaAccessor<3, 3, 3> &accessor, - const unsigned int face, - const unsigned char combined_orientation) + const TriaAccessor &accessor, + const unsigned int face, + const unsigned char combined_orientation) { + Assert(structdim == dim, + ExcMessage("This function can only be used on objects that are " + "cells and not on objects which bound cells.")); AssertIndexRange(face, accessor.n_faces()); - accessor.tria->levels[accessor.present_level] - ->face_orientations.set_combined_orientation( - accessor.present_index * GeometryInfo<3>::faces_per_cell + face, - combined_orientation); + + if (dim == 1) + Assert(combined_orientation == + ReferenceCell::default_combined_face_orientation(), + ExcMessage("In 1d, faces do not have an orientation, so the " + "only valid value is the default.")); + else if (dim == 2) + Assert(combined_orientation == + ReferenceCell::default_combined_face_orientation() || + combined_orientation == + ReferenceCell::reversed_combined_line_orientation(), + ExcMessage( + "In 2d, the only valid values of the combined orientation " + "are the standard orientation or the reversed line " + "orientation.")); + + // face_orientations is not set up in 1d + if (dim != 1) + accessor.tria->levels[accessor.present_level] + ->face_orientations.set_combined_orientation( + accessor.present_index * GeometryInfo::faces_per_cell + face, + combined_orientation); } /** -- 2.39.5