From: Peter Munch Date: Fri, 5 Jun 2020 07:26:16 +0000 (+0200) Subject: Simplify line_orientation() X-Git-Tag: v9.3.0-rc1~1485^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F10464%2Fhead;p=dealii.git Simplify line_orientation() --- diff --git a/include/deal.II/grid/tria_accessor.templates.h b/include/deal.II/grid/tria_accessor.templates.h index bbd52503ee..20a7f6db38 100644 --- a/include/deal.II/grid/tria_accessor.templates.h +++ b/include/deal.II/grid/tria_accessor.templates.h @@ -753,71 +753,40 @@ namespace internal } - template + template inline static bool - line_orientation(const TriaAccessor<3, dim, spacedim> &accessor, - const unsigned int line) + line_orientation(const TriaAccessor<3, 3, spacedim> &accessor, + const unsigned int line) { Assert(accessor.used(), TriaAccessorExceptions::ExcCellNotUsed()); AssertIndexRange(line, GeometryInfo<3>::lines_per_cell); - // get the line index by asking the - // quads. first assume standard orientation - // - // set up a table that for each - // line describes a) from which - // quad to take it, b) which line - // therein it is if the face is - // oriented correctly - static const unsigned int - lookup_table[GeometryInfo<3>::lines_per_cell][2] = { - {4, 0}, // take first four lines from bottom face - {4, 1}, - {4, 2}, - {4, 3}, - - {5, 0}, // second four lines from top face - {5, 1}, - {5, 2}, - {5, 3}, - - {0, 0}, // the rest randomly - {1, 0}, - {0, 1}, - {1, 1}}; - - const unsigned int quad_index = lookup_table[line][0]; - const unsigned int std_line_index = lookup_table[line][1]; - - const unsigned int line_index = - GeometryInfo::standard_to_real_face_line( - std_line_index, - accessor.face_orientation(quad_index), - accessor.face_flip(quad_index), - accessor.face_rotation(quad_index)); - - // now we got to the correct line and ask - // the quad for its line_orientation. however, if - // the face is rotated, it might be possible, - // that a standard orientation of the line - // with respect to the face corresponds to a - // non-standard orientation for the line with + const auto pair = + GeometryInfo<3>::standard_hex_line_to_quad_line_index(line); + const auto quad_index = pair[0]; + const auto std_line_index = pair[1]; + const auto line_index = GeometryInfo<3>::standard_to_real_face_line( + std_line_index, + accessor.face_orientation(quad_index), + accessor.face_flip(quad_index), + accessor.face_rotation(quad_index)); + + // now we got to the correct line and ask the quad for its + // line_orientation. however, if the face is rotated, it might be + // possible, that a standard orientation of the line with respect to + // the face corresponds to a non-standard orientation for the line with // respect to the cell. // - // set up a table indicating if the two - // standard orientations coincide + // set up a table indicating if the two standard orientations coincide // - // first index: two pairs of lines 0(lines - // 0/1) and 1(lines 2/3) + // first index: two pairs of lines 0(lines 0/1) and 1(lines 2/3) // - // second index: face_orientation; 0: - // opposite normal, 1: standard + // second index: face_orientation; 0: opposite normal, 1: standard // - // third index: face_flip; 0: standard, 1: - // face rotated by 180 degrees + // third index: face_flip; 0: standard, 1: face rotated by 180 degrees // - // forth index: face_rotation: 0: standard, - // 1: face rotated by 90 degrees + // forth index: face_rotation: 0: standard, 1: face rotated by 90 + // degrees static const bool bool_table[2][2][2][2] = { {{{true, false}, // lines 0/1, face_orientation=false,