From 356bea36c1c8f6a818e9bdc8bfe2c7b0c1cc1ddd Mon Sep 17 00:00:00 2001 From: David Wells Date: Fri, 27 Dec 2024 13:50:44 -0500 Subject: [PATCH] Combine the line_index() functions. --- include/deal.II/grid/tria_accessor.h | 67 ++++++++++------------------ 1 file changed, 23 insertions(+), 44 deletions(-) diff --git a/include/deal.II/grid/tria_accessor.h b/include/deal.II/grid/tria_accessor.h index fd278c1e0e..ff818bec0e 100644 --- a/include/deal.II/grid/tria_accessor.h +++ b/include/deal.II/grid/tria_accessor.h @@ -4893,48 +4893,6 @@ namespace internal */ struct Implementation { - /** - * Implementation of the function of some name in the parent class. - */ - template - inline static unsigned int - line_index(const TriaAccessor<1, dim, spacedim> &, const unsigned int) - { - Assert(false, - ExcMessage("You can't ask for the index of a line bounding " - "a one-dimensional cell because it is not " - "bounded by lines.")); - return numbers::invalid_unsigned_int; - } - - - template - inline static unsigned int - line_index(const TriaAccessor<2, dim, spacedim> &accessor, - const unsigned int i) - { - constexpr unsigned int max_faces_per_cell = 4; - return accessor.objects() - .cells[accessor.present_index * max_faces_per_cell + i]; - } - - - inline static unsigned int - line_index(const TriaAccessor<3, 3, 3> &accessor, const unsigned int i) - { - const auto [face_index, line_index] = - accessor.reference_cell().standard_line_to_face_and_line_index(i); - const auto line_within_face_index = - accessor.reference_cell().standard_to_real_face_line( - line_index, - face_index, - accessor.combined_face_orientation(face_index)); - - return accessor.quad(face_index)->line_index(line_within_face_index); - } - - - /** * Implementation of the function of some name in the parent class. */ @@ -5491,9 +5449,30 @@ inline unsigned int TriaAccessor::line_index(const unsigned int i) const { AssertIndexRange(i, this->n_lines()); + Assert(structdim != 1, + ExcMessage("You can't ask for the index of a line bounding a " + "one-dimensional cell because it is not bounded by " + "lines.")); - return dealii::internal::TriaAccessorImplementation::Implementation:: - line_index(*this, i); + if constexpr (structdim == 2) + { + constexpr unsigned int max_faces_per_cell = 4; + return this->objects() + .cells[this->present_index * max_faces_per_cell + i]; + } + else if constexpr (structdim == 3) + { + const auto [face_index, line_index] = + this->reference_cell().standard_line_to_face_and_line_index(i); + const auto line_within_face_index = + this->reference_cell().standard_to_real_face_line( + line_index, face_index, this->combined_face_orientation(face_index)); + + return this->quad(face_index)->line_index(line_within_face_index); + } + + DEAL_II_ASSERT_UNREACHABLE(); + return numbers::invalid_unsigned_int; } -- 2.39.5