From: David Wells Date: Sat, 21 Jan 2023 18:24:04 +0000 (-0500) Subject: ReferenceCell: Introduce an alias for std::equal(). X-Git-Tag: v9.5.0-rc1~612^2~3 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1b7023716ca017c47f1f7717c3ee3bd934dfbe5b;p=dealii.git ReferenceCell: Introduce an alias for std::equal(). This makes this a lot easier to read. --- diff --git a/include/deal.II/grid/reference_cell.h b/include/deal.II/grid/reference_cell.h index a633d5910c..d8a6e4e7d8 100644 --- a/include/deal.II/grid/reference_cell.h +++ b/include/deal.II/grid/reference_cell.h @@ -2689,127 +2689,86 @@ ReferenceCell::get_orientation_index(const ArrayView &vertices_0, "the number of vertices of the cell " "referenced by this object.")); + const auto v0_equals = [&](const std::initializer_list &list) { + Assert(list.size() == n_vertices(), ExcInternalError()); + return std::equal(vertices_0.begin(), vertices_0.end(), std::begin(list)); + }; + switch (this->kind) { case ReferenceCells::Line: // line_orientation=true - if (std::equal(vertices_0.begin(), - vertices_0.end(), - std::begin({vertices_1[0], vertices_1[1]}))) + if (v0_equals({vertices_1[0], vertices_1[1]})) return 1; // line_orientation=false - if (std::equal(vertices_0.begin(), - vertices_0.end(), - std::begin({vertices_1[1], vertices_1[0]}))) + if (v0_equals({vertices_1[1], vertices_1[0]})) return 0; break; case ReferenceCells::Triangle: // face_orientation=true, face_rotation=false, face_flip=false - if (std::equal(vertices_0.begin(), - vertices_0.end(), - std::begin( - {vertices_1[0], vertices_1[1], vertices_1[2]}))) + if (v0_equals({vertices_1[0], vertices_1[1], vertices_1[2]})) return 1; // face_orientation=true, face_rotation=true, face_flip=false - if (std::equal(vertices_0.begin(), - vertices_0.end(), - std::begin( - {vertices_1[1], vertices_1[2], vertices_1[0]}))) + if (v0_equals({vertices_1[1], vertices_1[2], vertices_1[0]})) return 3; // face_orientation=true, face_rotation=false, face_flip=true - if (std::equal(vertices_0.begin(), - vertices_0.end(), - std::begin( - {vertices_1[2], vertices_1[0], vertices_1[1]}))) + if (v0_equals({vertices_1[2], vertices_1[0], vertices_1[1]})) return 5; // face_orientation=false, face_rotation=false, face_flip=false - if (std::equal(vertices_0.begin(), - vertices_0.end(), - std::begin( - {vertices_1[0], vertices_1[2], vertices_1[1]}))) + if (v0_equals({vertices_1[0], vertices_1[2], vertices_1[1]})) return 0; // face_orientation=false, face_rotation=true, face_flip=false - if (std::equal(vertices_0.begin(), - vertices_0.end(), - std::begin( - {vertices_1[2], vertices_1[1], vertices_1[0]}))) + if (v0_equals({vertices_1[2], vertices_1[1], vertices_1[0]})) return 2; // face_orientation=false, face_rotation=false, face_flip=true - if (std::equal(vertices_0.begin(), - vertices_0.end(), - std::begin( - {vertices_1[1], vertices_1[0], vertices_1[2]}))) + if (v0_equals({vertices_1[1], vertices_1[0], vertices_1[2]})) return 4; break; case ReferenceCells::Quadrilateral: // face_orientation=true, face_rotation=false, face_flip=false - if (std::equal( - vertices_0.begin(), - vertices_0.end(), - std::begin( - {vertices_1[0], vertices_1[1], vertices_1[2], vertices_1[3]}))) + if (v0_equals( + {vertices_1[0], vertices_1[1], vertices_1[2], vertices_1[3]})) return 1; // face_orientation=true, face_rotation=true, face_flip=false - if (std::equal( - vertices_0.begin(), - vertices_0.end(), - std::begin( - {vertices_1[2], vertices_1[0], vertices_1[3], vertices_1[1]}))) + if (v0_equals( + {vertices_1[2], vertices_1[0], vertices_1[3], vertices_1[1]})) return 3; // face_orientation=true, face_rotation=false, face_flip=true - if (std::equal( - vertices_0.begin(), - vertices_0.end(), - std::begin( - {vertices_1[3], vertices_1[2], vertices_1[1], vertices_1[0]}))) + if (v0_equals( + {vertices_1[3], vertices_1[2], vertices_1[1], vertices_1[0]})) return 5; // face_orientation=true, face_rotation=true, face_flip=true - if (std::equal( - vertices_0.begin(), - vertices_0.end(), - std::begin( - {vertices_1[1], vertices_1[3], vertices_1[0], vertices_1[2]}))) + if (v0_equals( + {vertices_1[1], vertices_1[3], vertices_1[0], vertices_1[2]})) return 7; // face_orientation=false, face_rotation=false, face_flip=false - if (std::equal( - vertices_0.begin(), - vertices_0.end(), - std::begin( - {vertices_1[0], vertices_1[2], vertices_1[1], vertices_1[3]}))) + if (v0_equals( + {vertices_1[0], vertices_1[2], vertices_1[1], vertices_1[3]})) return 0; // face_orientation=false, face_rotation=true, face_flip=false - if (std::equal( - vertices_0.begin(), - vertices_0.end(), - std::begin( - {vertices_1[2], vertices_1[3], vertices_1[0], vertices_1[1]}))) + if (v0_equals( + {vertices_1[2], vertices_1[3], vertices_1[0], vertices_1[1]})) return 2; // face_orientation=false, face_rotation=false, face_flip=true - if (std::equal( - vertices_0.begin(), - vertices_0.end(), - std::begin( - {vertices_1[3], vertices_1[1], vertices_1[2], vertices_1[0]}))) + if (v0_equals( + {vertices_1[3], vertices_1[1], vertices_1[2], vertices_1[0]})) return 4; // face_orientation=false, face_rotation=true, face_flip=true - if (std::equal( - vertices_0.begin(), - vertices_0.end(), - std::begin( - {vertices_1[1], vertices_1[0], vertices_1[3], vertices_1[2]}))) + if (v0_equals( + {vertices_1[1], vertices_1[0], vertices_1[3], vertices_1[2]})) return 6; break; default: