From: David Wells Date: Sat, 4 May 2024 16:00:05 +0000 (-0400) Subject: Consolidate face_orientation() functions. X-Git-Tag: v9.6.0-rc1~309^2~2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=97c821d944fa417c5acfd23c1c4dd53273eefab8;p=dealii.git Consolidate face_orientation() functions. --- diff --git a/include/deal.II/grid/tria_accessor.templates.h b/include/deal.II/grid/tria_accessor.templates.h index d4f5c4722d..3c737dadec 100644 --- a/include/deal.II/grid/tria_accessor.templates.h +++ b/include/deal.II/grid/tria_accessor.templates.h @@ -651,44 +651,6 @@ namespace internal - /** - * Implementation of the function of some name in the mother class - */ - template - inline static bool - face_orientation(const TriaAccessor &, - const unsigned int) - { - /* - * Default implementation used in 1d - * - * In 1d, face_orientation is always true - */ - - return true; - } - - - template - inline static bool - face_orientation(const TriaAccessor<2, 2, spacedim> &accessor, - const unsigned int face) - { - return line_orientation(accessor, face); - } - - - inline static bool - face_orientation(const TriaAccessor<3, 3, 3> &accessor, - const unsigned int face) - { - return accessor.tria->levels[accessor.present_level] - ->face_orientations.get_orientation( - accessor.present_index * GeometryInfo<3>::faces_per_cell + face); - } - - - template inline static unsigned char combined_face_orientation( @@ -1369,9 +1331,23 @@ TriaAccessor::face_orientation( const unsigned int face) const { Assert(used(), TriaAccessorExceptions::ExcCellNotUsed()); + AssertIndexRange(face, n_faces()); + Assert(structdim == dim, + ExcMessage("This function can only be used on objects " + "that are cells, but not on faces or edges " + "that bound cells.")); + // work around a bogus GCC-9 warning which considers face unused in 1d + (void)face; - return dealii::internal::TriaAccessorImplementation::Implementation:: - face_orientation(*this, face); + if constexpr (structdim == 1) + // in 1d 'faces' are vertices and those are always consistently oriented + return true; + else if constexpr (structdim == 2) + return this->line_orientation(face); + else + return this->tria->levels[this->present_level] + ->face_orientations.get_orientation( + this->present_index * GeometryInfo::faces_per_cell + face); }