From: David Wells Date: Sat, 6 Apr 2024 17:17:54 +0000 (-0400) Subject: TriaAccessor: permit calling set_combined_face_orientation() in 2d. X-Git-Tag: v9.6.0-rc1~382^2~4 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d00345ce47125e5261f861402e6f7eb0a529c4b1;p=dealii.git TriaAccessor: permit calling set_combined_face_orientation() in 2d. --- 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); } /**