From fdc434ad2762245352cd970558fb13cb53bdfdda Mon Sep 17 00:00:00 2001 From: David Wells Date: Sat, 21 Jan 2023 13:16:40 -0500 Subject: [PATCH] Un-hardcode some more face and line orientations. --- include/deal.II/dofs/dof_accessor.templates.h | 3 ++- include/deal.II/grid/connectivity.h | 8 +++++-- include/deal.II/grid/reference_cell.h | 24 ++++++++++++++++++- .../deal.II/grid/tria_objects_orientations.h | 8 +++++-- source/grid/tria.cc | 14 +++++++---- 5 files changed, 47 insertions(+), 10 deletions(-) diff --git a/include/deal.II/dofs/dof_accessor.templates.h b/include/deal.II/dofs/dof_accessor.templates.h index f33d039e18..c24adfda4c 100644 --- a/include/deal.II/dofs/dof_accessor.templates.h +++ b/include/deal.II/dofs/dof_accessor.templates.h @@ -1088,7 +1088,8 @@ namespace internal const unsigned int raw_orientation = TriaAccessorImplementation:: Implementation::face_orientation_raw(accessor, quad); const unsigned int quad_index = accessor.quad_index(quad); - if (raw_orientation == 1) + if (raw_orientation == + ReferenceCell::default_combined_face_orientation()) dof_operation.process_dofs( accessor.get_dof_handler(), 0, diff --git a/include/deal.II/grid/connectivity.h b/include/deal.II/grid/connectivity.h index 1319163c65..882727b701 100644 --- a/include/deal.II/grid/connectivity.h +++ b/include/deal.II/grid/connectivity.h @@ -1317,7 +1317,8 @@ namespace internal const unsigned int f = con_cq.col[f_]; // only faces with default orientation have to do something - if (ori_cq.get_raw_orientation(f_) != 1u) + if (ori_cq.get_raw_orientation(f_) != + ReferenceCell::default_combined_face_orientation()) continue; // determine entity type of face @@ -1349,7 +1350,10 @@ namespace internal } // ... comparison gives orientation - ori_ql.set_raw_orientation(con_ql.ptr[f] + l, same ? 1u : 0u); + ori_ql.set_raw_orientation( + con_ql.ptr[f] + l, + same ? ReferenceCell::default_combined_face_orientation() : + ReferenceCell::reversed_combined_line_orientation()); } } } diff --git a/include/deal.II/grid/reference_cell.h b/include/deal.II/grid/reference_cell.h index 9dc0d5b27d..d6c4263377 100644 --- a/include/deal.II/grid/reference_cell.h +++ b/include/deal.II/grid/reference_cell.h @@ -356,6 +356,19 @@ public: static constexpr unsigned char default_combined_face_orientation(); + /** + * Return the reversed (non-default orientation) line orientation flag. As + * lines only have two possible orientations, this function and + * ReferenceCell::default_combined_face_orientation() encode all of its + * possible orientation states. + * + * @note Line orientations are typically stored as booleans, but to better + * enable dimension-independent programming relevant functions typically + * present these values as unsigned chars. + */ + static constexpr unsigned char + reversed_combined_line_orientation(); + /** * Return which child cells are adjacent to a certain face of the * mother cell. @@ -400,7 +413,8 @@ public: unsigned int child_cell_on_face(const unsigned int face, const unsigned int subface, - const unsigned char face_orientation = 1) const; + const unsigned char face_orientation = + default_combined_face_orientation()) const; /** * For a given vertex in a cell, return a pair of a face index and a @@ -1436,6 +1450,14 @@ ReferenceCell::default_combined_face_orientation() +inline constexpr unsigned char +ReferenceCell::reversed_combined_line_orientation() +{ + return 0u; +} + + + inline unsigned int ReferenceCell::child_cell_on_face( const unsigned int face, diff --git a/include/deal.II/grid/tria_objects_orientations.h b/include/deal.II/grid/tria_objects_orientations.h index 5ae0006bc1..6916f63df6 100644 --- a/include/deal.II/grid/tria_objects_orientations.h +++ b/include/deal.II/grid/tria_objects_orientations.h @@ -22,6 +22,8 @@ #include #include +#include + #include DEAL_II_NAMESPACE_OPEN @@ -195,7 +197,8 @@ namespace internal { n_stored_objects = n_objects; // Assign to the default orientation - flags.assign(n_objects, 1u); + flags.assign(n_objects, + ReferenceCell::default_combined_face_orientation()); } @@ -203,7 +206,8 @@ namespace internal inline void TriaObjectsOrientations::resize(const unsigned int n_objects) { - flags.resize(n_objects, 1u); + flags.resize(n_objects, + ReferenceCell::default_combined_face_orientation()); n_stored_objects = n_objects; } diff --git a/source/grid/tria.cc b/source/grid/tria.cc index d7e2e06b02..a5d70891d8 100644 --- a/source/grid/tria.cc +++ b/source/grid/tria.cc @@ -2354,11 +2354,16 @@ namespace internal k); // it doesn't make sense to set any flags except // orientation for a line - Assert(raw_orientation == 0u || raw_orientation == 1u, - ExcInternalError()); + Assert( + raw_orientation == + ReferenceCell::default_combined_face_orientation() || + raw_orientation == + ReferenceCell::reversed_combined_line_orientation(), + ExcInternalError()); faces.quads_line_orientations [q * GeometryInfo<3>::lines_per_face + j] = - raw_orientation == 1u; + raw_orientation == + ReferenceCell::default_combined_face_orientation(); } } } @@ -2381,7 +2386,8 @@ namespace internal { const auto &orientations = connectivity.entity_orientations(1); for (unsigned int i = 0; i < orientations.n_objects(); ++i) - if (orientations.get_raw_orientation(i) != 1u) + if (orientations.get_raw_orientation(i) != + ReferenceCell::default_combined_face_orientation()) { orientation_needed = true; break; -- 2.39.5