From 33c0b6fce52655f8824d1622a4cc95f60dda617f Mon Sep 17 00:00:00 2001 From: David Wells Date: Wed, 22 Jan 2025 20:04:31 -0500 Subject: [PATCH] Introduce numbers::reverse_line_orientation. It is useful to have this value since lines only have two possible orientations. --- include/deal.II/base/types.h | 13 ++++++ include/deal.II/grid/connectivity.h | 2 +- include/deal.II/grid/reference_cell.h | 12 ++++-- include/deal.II/grid/tria_accessor.h | 16 +++---- source/fe/fe.cc | 3 +- source/fe/fe_poly_tensor.cc | 4 +- source/grid/tria.cc | 61 +++++++++++++-------------- tests/dofs/dof_tools_21_b_x.cc | 11 +++-- tests/dofs/dof_tools_21_b_x_q3.cc | 11 +++-- tests/simplex/orientation_04.cc | 3 +- 10 files changed, 72 insertions(+), 64 deletions(-) diff --git a/include/deal.II/base/types.h b/include/deal.II/base/types.h index cd6863fe0a..2b3e726d3f 100644 --- a/include/deal.II/base/types.h +++ b/include/deal.II/base/types.h @@ -347,6 +347,19 @@ namespace numbers const types::geometric_orientation default_geometric_orientation = static_cast(0b001); + /** + * Value indicating that a line is in the reverse orientation. Since lines can + * only have two possible orientations, this value and + * default_geometric_orientation completely encode the possible values for + * line orientations. + * + * See the + * @ref GlossFaceOrientation "glossary" + * for more information. + */ + const types::geometric_orientation reverse_line_orientation = + static_cast(0b000); + /** * A special id for an invalid subdomain id. This value may not be used as a * valid id but is used, for example, for default arguments to indicate a diff --git a/include/deal.II/grid/connectivity.h b/include/deal.II/grid/connectivity.h index 8ca6d35cfc..17884852a4 100644 --- a/include/deal.II/grid/connectivity.h +++ b/include/deal.II/grid/connectivity.h @@ -1341,7 +1341,7 @@ namespace internal ori_ql.set_combined_orientation( con_ql.ptr[f] + l, same ? numbers::default_geometric_orientation : - ReferenceCell::reversed_combined_line_orientation()); + numbers::reverse_line_orientation); } } } diff --git a/include/deal.II/grid/reference_cell.h b/include/deal.II/grid/reference_cell.h index b5119fc401..ed9bd6c832 100644 --- a/include/deal.II/grid/reference_cell.h +++ b/include/deal.II/grid/reference_cell.h @@ -444,7 +444,11 @@ public: * lines only have two possible orientations, this function and * ReferenceCell::default_combined_face_orientation() encode all of its * possible orientation states. + * + * @deprecated Use numbers::reverse_line_orientation instead. */ + DEAL_II_DEPRECATED_EARLY_WITH_COMMENT( + "Use numbers::reverse_line_orientation instead.") static constexpr types::geometric_orientation reversed_combined_line_orientation(); @@ -2075,7 +2079,7 @@ ReferenceCell::reversed_combined_line_orientation() { // For a reversed line 'orientation' is false and neither flip nor rotate are // defined. - return 0b000; + return numbers::reverse_line_orientation; } @@ -3274,7 +3278,7 @@ ReferenceCell::face_to_cell_line_orientation( const types::geometric_orientation line_orientation) const { constexpr auto D = numbers::default_geometric_orientation; - constexpr auto R = ReferenceCell::reversed_combined_line_orientation(); + constexpr auto R = numbers::reverse_line_orientation; if (*this == ReferenceCells::Hexahedron) { static constexpr dealii::ndarray @@ -3285,7 +3289,7 @@ ReferenceCell::face_to_cell_line_orientation( line_orientation == table[face_line_no / 2][combined_face_orientation]; return match ? numbers::default_geometric_orientation : - ReferenceCell::reversed_combined_line_orientation(); + numbers::reverse_line_orientation; } else if (*this == ReferenceCells::Tetrahedron) { @@ -3307,7 +3311,7 @@ ReferenceCell::face_to_cell_line_orientation( line_orientation == table[combined_line][combined_face_orientation]; return match ? numbers::default_geometric_orientation : - ReferenceCell::reversed_combined_line_orientation(); + numbers::reverse_line_orientation; } else // TODO: This might actually be wrong for some of the other diff --git a/include/deal.II/grid/tria_accessor.h b/include/deal.II/grid/tria_accessor.h index fd9d3bd634..3c3d5ffeff 100644 --- a/include/deal.II/grid/tria_accessor.h +++ b/include/deal.II/grid/tria_accessor.h @@ -2169,7 +2169,7 @@ public: face_rotation(const unsigned int face); /** - * @brief Always return ReferenceCell::reversed_combined_line_orientation() + * @brief Always return numbers::reverse_line_orientation */ static types::geometric_orientation line_orientation(const unsigned int line); @@ -2838,7 +2838,7 @@ public: face_rotation(const unsigned int face); /** - * @brief Always return ReferenceCell::reversed_combined_line_orientation() + * @brief Always return numbers::reverse_line_orientation */ static types::geometric_orientation line_orientation(const unsigned int line); @@ -4912,8 +4912,7 @@ namespace internal else if (dim == 2) Assert(combined_orientation == numbers::default_geometric_orientation || - combined_orientation == - ReferenceCell::reversed_combined_line_orientation(), + combined_orientation == numbers::reverse_line_orientation, ExcMessage( "In 2d, the only valid values of the combined orientation " "are the standard orientation or the reversed line " @@ -5535,8 +5534,7 @@ TriaAccessor::line_orientation( { const auto combined_orientation = combined_face_orientation(line); Assert(combined_orientation == numbers::default_geometric_orientation || - combined_orientation == - ReferenceCell::reversed_combined_line_orientation(), + combined_orientation == numbers::reverse_line_orientation, ExcInternalError()); return combined_orientation; } @@ -5551,7 +5549,7 @@ TriaAccessor::line_orientation( ExcInternalError()); return this->tria->faces->quads_line_orientations[index] ? numbers::default_geometric_orientation : - ReferenceCell::reversed_combined_line_orientation(); + numbers::reverse_line_orientation; } else if constexpr (structdim == 3 && dim == 3) { @@ -6912,7 +6910,7 @@ template inline types::geometric_orientation TriaAccessor<0, dim, spacedim>::line_orientation(const unsigned int /*line*/) { - return ReferenceCell::reversed_combined_line_orientation(); + return numbers::reverse_line_orientation; } @@ -7360,7 +7358,7 @@ template inline types::geometric_orientation TriaAccessor<0, 1, spacedim>::line_orientation(const unsigned int /*line*/) { - return ReferenceCell::reversed_combined_line_orientation(); + return numbers::reverse_line_orientation; } diff --git a/source/fe/fe.cc b/source/fe/fe.cc index adfd95a439..d1e918d19f 100644 --- a/source/fe/fe.cc +++ b/source/fe/fe.cc @@ -678,8 +678,7 @@ FiniteElement::adjust_line_dof_index_for_line_orientation( const types::geometric_orientation combined_orientation) const { Assert(combined_orientation == numbers::default_geometric_orientation || - combined_orientation == - ReferenceCell::reversed_combined_line_orientation(), + combined_orientation == numbers::reverse_line_orientation, ExcInternalError()); AssertIndexRange(index, this->n_dofs_per_line()); diff --git a/source/fe/fe_poly_tensor.cc b/source/fe/fe_poly_tensor.cc index 846e87be37..5f27d831a0 100644 --- a/source/fe/fe_poly_tensor.cc +++ b/source/fe/fe_poly_tensor.cc @@ -148,7 +148,7 @@ namespace internal // TODO: This fixes only lowest order for (unsigned int l = 0; l < GeometryInfo::lines_per_cell; ++l) if ((cell->line_orientation(l) == - ReferenceCell::reversed_combined_line_orientation()) && + numbers::reverse_line_orientation) && mapping_kind[0] == mapping_nedelec) line_dof_sign[l] = -1.0; } @@ -167,7 +167,7 @@ namespace internal // which all dofs are face dofs for (unsigned int l = 0; l < GeometryInfo::lines_per_cell; ++l) if ((cell->line_orientation(l) == - ReferenceCell::reversed_combined_line_orientation()) && + numbers::reverse_line_orientation) && mapping_kind[0] == mapping_nedelec) line_dof_sign[l] = -1.0; } diff --git a/source/grid/tria.cc b/source/grid/tria.cc index 987fe0d0ff..9390242464 100644 --- a/source/grid/tria.cc +++ b/source/grid/tria.cc @@ -1837,8 +1837,7 @@ namespace { AssertIndexRange(child_no, ReferenceCells::Line.template n_children<1>()); Assert(line_orientation == numbers::default_geometric_orientation || - line_orientation == - ReferenceCell::reversed_combined_line_orientation(), + line_orientation == numbers::reverse_line_orientation, ExcInternalError()); constexpr auto D = numbers::default_geometric_orientation; if (child_no == 0) @@ -3326,12 +3325,11 @@ namespace internal .get_combined_orientation(k); // it doesn't make sense to set any flags except // orientation for a line - Assert( - combined_orientation == - numbers::default_geometric_orientation || - combined_orientation == - ReferenceCell::reversed_combined_line_orientation(), - ExcInternalError()); + Assert(combined_orientation == + numbers::default_geometric_orientation || + combined_orientation == + numbers::reverse_line_orientation, + ExcInternalError()); // Same convention as TriaAccessor::set_line_orientation(): // store true for the default orientation and false for // reversed. @@ -5189,7 +5187,7 @@ namespace internal // the last one. std::fill(inherited_orientations.begin() + lmin, inherited_orientations.begin() + lmax, - ReferenceCell::reversed_combined_line_orientation()); + numbers::reverse_line_orientation); } else if (cell->reference_cell() == ReferenceCells::Quadrilateral) { @@ -5224,7 +5222,7 @@ namespace internal Assert(combined_orientation == numbers::default_geometric_orientation || combined_orientation == - ReferenceCell::reversed_combined_line_orientation(), + numbers::reverse_line_orientation, ExcInternalError()); for (unsigned int c = 0; c < 2; ++c) { @@ -5232,8 +5230,7 @@ namespace internal inherited_orientations[2 * face_no + c] = cell->combined_face_orientation(face_no); } - if (combined_orientation == - ReferenceCell::reversed_combined_line_orientation()) + if (combined_orientation == numbers::reverse_line_orientation) std::swap(new_lines[2 * face_no], new_lines[2 * face_no + 1]); } @@ -8782,8 +8779,8 @@ namespace internal Assert(lines[i]->vertex_index((i + 1) % 2) == middle_vertices[i % 2], ExcInternalError()); - line_orientation[i] = ReferenceCell:: - reversed_combined_line_orientation(); + line_orientation[i] = + numbers::reverse_line_orientation; } // set up the new quad, line numbering is as @@ -9010,8 +9007,8 @@ namespace internal Assert(lines[i]->vertex_index((i + 1) % 2) == middle_vertices[i % 2], ExcInternalError()); - line_orientation[i] = ReferenceCell:: - reversed_combined_line_orientation(); + line_orientation[i] = + numbers::reverse_line_orientation; } // set up the new quad, line numbering is as @@ -9240,8 +9237,8 @@ namespace internal Assert(lines[i]->vertex_index((i + 1) % 2) == middle_vertices[i % 2], ExcInternalError()); - line_orientation[i] = ReferenceCell:: - reversed_combined_line_orientation(); + line_orientation[i] = + numbers::reverse_line_orientation; } // set up the new quad, line numbering is as @@ -9558,8 +9555,8 @@ namespace internal Assert(lines[i]->vertex_index(1) == middle_vertices[i], ExcInternalError()); - line_orientation[i] = ReferenceCell:: - reversed_combined_line_orientation(); + line_orientation[i] = + numbers::reverse_line_orientation; } // note: for lines 4 to 11 (inner lines of the @@ -9581,8 +9578,8 @@ namespace internal (middle_vertex_index( hex->face(3 + i / 4))), ExcInternalError()); - line_orientation[i] = ReferenceCell:: - reversed_combined_line_orientation(); + line_orientation[i] = + numbers::reverse_line_orientation; } // for the last line the line orientation is // always true, since it was just constructed @@ -9995,8 +9992,8 @@ namespace internal Assert(lines[i]->vertex_index(1) == middle_vertices[i], ExcInternalError()); - line_orientation[i] = ReferenceCell:: - reversed_combined_line_orientation(); + line_orientation[i] = + numbers::reverse_line_orientation; } // note: for lines 4 to 11 (inner lines of the @@ -10019,8 +10016,8 @@ namespace internal (middle_vertex_index( hex->face(1 + i / 4))), ExcInternalError()); - line_orientation[i] = ReferenceCell:: - reversed_combined_line_orientation(); + line_orientation[i] = + numbers::reverse_line_orientation; } // for the last line the line orientation is // always true, since it was just constructed @@ -10448,8 +10445,8 @@ namespace internal Assert(lines[i]->vertex_index(1) == middle_vertices[i], ExcInternalError()); - line_orientation[i] = ReferenceCell:: - reversed_combined_line_orientation(); + line_orientation[i] = + numbers::reverse_line_orientation; } // note: for lines 4 to 11 (inner lines of the @@ -10471,8 +10468,8 @@ namespace internal (middle_vertex_index( hex->face(i / 4 - 1))), ExcInternalError()); - line_orientation[i] = ReferenceCell:: - reversed_combined_line_orientation(); + line_orientation[i] = + numbers::reverse_line_orientation; } // for the last line the line orientation is always // the default, since it was just constructed that way @@ -11038,8 +11035,8 @@ namespace internal Assert(lines[i]->vertex_index(i % 2) == vertex_indices[i / 4], ExcInternalError()); - line_orientation[i] = ReferenceCell:: - reversed_combined_line_orientation(); + line_orientation[i] = + numbers::reverse_line_orientation; } // for the last 6 lines the line orientation is // always true, since they were just constructed diff --git a/tests/dofs/dof_tools_21_b_x.cc b/tests/dofs/dof_tools_21_b_x.cc index a6f8798b6e..22e58c02fe 100644 --- a/tests/dofs/dof_tools_21_b_x.cc +++ b/tests/dofs/dof_tools_21_b_x.cc @@ -195,12 +195,11 @@ print_matching(DoFHandler &dof_handler) deallog << dofs_2[i] << " is located at " << support_points[dofs_2[i]] << std::endl; - DoFTools::make_periodicity_constraints( - face_1, - face_2, - constraint_matrix, - ComponentMask(), - ReferenceCell::reversed_combined_line_orientation()); + DoFTools::make_periodicity_constraints(face_1, + face_2, + constraint_matrix, + ComponentMask(), + numbers::reverse_line_orientation); constraint_matrix.print(deallog.get_file_stream()); constraint_matrix.close(); deallog << "Matching:" << std::endl; diff --git a/tests/dofs/dof_tools_21_b_x_q3.cc b/tests/dofs/dof_tools_21_b_x_q3.cc index 0280a5b65c..e6ac2f4060 100644 --- a/tests/dofs/dof_tools_21_b_x_q3.cc +++ b/tests/dofs/dof_tools_21_b_x_q3.cc @@ -229,12 +229,11 @@ print_matching(DoFHandler &dof_handler) deallog << dofs_2[i] << " is located at " << support_points[dofs_2[i]] << std::endl; - DoFTools::make_periodicity_constraints( - face_1, - face_2, - constraint_matrix, - ComponentMask(), - ReferenceCell::reversed_combined_line_orientation()); + DoFTools::make_periodicity_constraints(face_1, + face_2, + constraint_matrix, + ComponentMask(), + numbers::reverse_line_orientation); constraint_matrix.print(deallog.get_file_stream()); constraint_matrix.close(); deallog << "Matching:" << std::endl; diff --git a/tests/simplex/orientation_04.cc b/tests/simplex/orientation_04.cc index ff4f4c2d84..fae603c31d 100644 --- a/tests/simplex/orientation_04.cc +++ b/tests/simplex/orientation_04.cc @@ -161,8 +161,7 @@ test() p1.first = cell->line(l)->vertex_index(0); p1.second = cell->line(l)->vertex_index(1); - if (orientation_exp == - ReferenceCell::reversed_combined_line_orientation()) + if (orientation_exp == numbers::reverse_line_orientation) std::swap(p1.first, p1.second); success &= (p0 == p1); -- 2.39.5