From: David Wells Date: Wed, 18 Jan 2023 02:42:10 +0000 (-0500) Subject: Switch to setting the combined orientation. X-Git-Tag: v9.5.0-rc1~610^2~1 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=46ae0f1ff06101434d228527eeec1f86d05b9f87;p=dealii.git Switch to setting the combined orientation. --- diff --git a/include/deal.II/grid/reference_cell.h b/include/deal.II/grid/reference_cell.h index 5ff5140e4d..c6392025a1 100644 --- a/include/deal.II/grid/reference_cell.h +++ b/include/deal.II/grid/reference_cell.h @@ -349,6 +349,13 @@ public: * @{ */ + /** + * Return the default combined face orientation flag (i.e., the default set of + * orientations, defined by orientation, rotate, and flip for a face in 3D). + */ + static constexpr unsigned char + default_combined_face_orientation(); + /** * Return which child cells are adjacent to a certain face of the * mother cell. @@ -1389,6 +1396,14 @@ ReferenceCell::face_reference_cell(const unsigned int face_no) const +inline constexpr unsigned char +ReferenceCell::default_combined_face_orientation() +{ + return 1u; +} + + + inline unsigned int ReferenceCell::child_cell_on_face( const unsigned int face, diff --git a/include/deal.II/grid/tria_accessor.h b/include/deal.II/grid/tria_accessor.h index c3ea1f39f5..e8cf2d7c1d 100644 --- a/include/deal.II/grid/tria_accessor.h +++ b/include/deal.II/grid/tria_accessor.h @@ -1799,6 +1799,17 @@ private: void set_face_rotation(const unsigned int face, const bool rotation) const; + /** + * Set the combined face orientation (i.e., the integer that uniquely encodes + * the orientation, flip, and rotation). + * + * It is only possible to set the face_orientation of cells in 3d (i.e. + * structdim==3 && dim==3). + */ + void + set_combined_face_orientation(const unsigned int face, + const unsigned char combined_orientation) const; + /** * Set the @p used flag. Only for internal use in the library. */ diff --git a/include/deal.II/grid/tria_accessor.templates.h b/include/deal.II/grid/tria_accessor.templates.h index f27a9ef592..faad143516 100644 --- a/include/deal.II/grid/tria_accessor.templates.h +++ b/include/deal.II/grid/tria_accessor.templates.h @@ -926,6 +926,33 @@ namespace internal value); } + /** + * Implementation of the function of some name in the mother class. + */ + template + inline static void + set_combined_face_orientation( + const TriaAccessor &, + const unsigned int, + const unsigned char) + { + Assert(false, ExcInternalError()); + } + + + + inline static void + set_combined_face_orientation(const TriaAccessor<3, 3, 3> &accessor, + const unsigned int face, + const unsigned char combined_orientation) + { + AssertIndexRange(face, accessor.n_faces()); + accessor.tria->levels[accessor.present_level] + ->face_orientations.set_raw_orientation( + accessor.present_index * GeometryInfo<3>::faces_per_cell + face, + combined_orientation); + } + /** * Implementation of the function of some name in the mother class. */ @@ -1543,6 +1570,21 @@ TriaAccessor::set_line_orientation( +template +inline void +TriaAccessor::set_combined_face_orientation( + const unsigned int face, + const unsigned char combined_orientation) const +{ + Assert(used(), TriaAccessorExceptions::ExcCellNotUsed()); + AssertIndexRange(face, this->n_faces()); + + dealii::internal::TriaAccessorImplementation::Implementation:: + set_combined_face_orientation(*this, face, combined_orientation); +} + + + template void TriaAccessor::set_used_flag() const diff --git a/source/grid/tria.cc b/source/grid/tria.cc index 2b5ee8ac43..b3a09641f3 100644 --- a/source/grid/tria.cc +++ b/source/grid/tria.cc @@ -3099,14 +3099,10 @@ namespace internal cell->child(child)->clear_user_flag(); for (auto f : GeometryInfo::face_indices()) - { - // set flags denoting deviations from - // standard orientation of faces back - // to initialization values - cell->child(child)->set_face_orientation(f, true); - cell->child(child)->set_face_flip(f, false); - cell->child(child)->set_face_rotation(f, false); - } + // set flags denoting deviations from standard orientation of + // faces back to initialization values + cell->child(child)->set_combined_face_orientation( + f, ReferenceCell::default_combined_face_orientation()); cell->child(child)->clear_used_flag(); } @@ -5684,23 +5680,13 @@ namespace internal if (i % 2) new_hex->set_parent(hex->index()); - // set the face_orientation flag to true for all - // faces initially, as this is the default value - // which is true for all faces interior to the - // hex. later on go the other way round and - // reset faces that are at the boundary of the - // mother cube - // - // the same is true for the face_flip and - // face_rotation flags. however, the latter two - // are set to false by default as this is the - // standard value + // set the orientation flag to its default state for all + // faces initially. later on go the other way round and + // reset faces that are at the boundary of the mother cube for (const auto f : new_hex->face_indices()) - { - new_hex->set_face_orientation(f, true); - new_hex->set_face_flip(f, false); - new_hex->set_face_rotation(f, false); - } + new_hex->set_combined_face_orientation( + f, + ReferenceCell::default_combined_face_orientation()); } for (unsigned int i = 0; i < n_new_hexes / 2; ++i) hex->set_children(2 * i, new_hexes[2 * i]->index()); @@ -6152,17 +6138,11 @@ namespace internal [2]], }}; - const auto orientation = + new_hex->set_combined_face_orientation( + f, face->reference_cell().get_orientation_index( make_array_view(vertices_1), - make_array_view(vertices_0)); - - new_hex->set_face_orientation( - f, Utilities::get_bit(orientation, 0)); - new_hex->set_face_flip( - f, Utilities::get_bit(orientation, 2)); - new_hex->set_face_rotation( - f, Utilities::get_bit(orientation, 1)); + make_array_view(vertices_0))); } } else if (new_hex->n_faces() == 6) @@ -6191,18 +6171,12 @@ namespace internal if (hex->n_faces() == 6) for (const auto f : hex->face_indices()) { - const unsigned int orientation = - hex->face_orientation(f); - const unsigned int flip = hex->face_flip(f); - const unsigned int rotation = hex->face_rotation(f); + const unsigned char combined_orientation = + hex->combined_face_orientation(f); for (unsigned int c = 0; c < 4; ++c) - { - auto &new_hex = - new_hexes[face_to_child_indices_hex[f][c]]; - new_hex->set_face_orientation(f, orientation); - new_hex->set_face_flip(f, flip); - new_hex->set_face_rotation(f, rotation); - } + new_hexes[face_to_child_indices_hex[f][c]] + ->set_combined_face_orientation( + f, combined_orientation); } } } @@ -7709,11 +7683,9 @@ namespace internal // standard value for (const unsigned int f : GeometryInfo::face_indices()) - { - new_hexes[i]->set_face_orientation(f, true); - new_hexes[i]->set_face_flip(f, false); - new_hexes[i]->set_face_rotation(f, false); - } + new_hexes[i]->set_combined_face_orientation( + f, + ReferenceCell::default_combined_face_orientation()); } // note these hexes as children to the present cell for (unsigned int i = 0; i < n_new_hexes / 2; ++i) @@ -7747,6 +7719,15 @@ namespace internal hex->face_rotation(4), hex->face_rotation(5)}; + // combined orientation + const unsigned char f_co[6] = { + hex->combined_face_orientation(0), + hex->combined_face_orientation(1), + hex->combined_face_orientation(2), + hex->combined_face_orientation(3), + hex->combined_face_orientation(4), + hex->combined_face_orientation(5)}; + // little helper table, indicating, whether the // child with index 0 or with index 1 can be found // at the standard origin of an anisotropically @@ -10535,10 +10516,8 @@ namespace internal f_ro[f], GeometryInfo::face_refinement_case( ref_case, f, f_or[f], f_fl[f], f_ro[f])); - new_hexes[current_child]->set_face_orientation(f, - f_or[f]); - new_hexes[current_child]->set_face_flip(f, f_fl[f]); - new_hexes[current_child]->set_face_rotation(f, f_ro[f]); + new_hexes[current_child]->set_combined_face_orientation( + f, f_co[f]); } // now see if we have created cells that are