From: David Wells Date: Sat, 4 Jan 2025 22:27:31 +0000 (-0500) Subject: Use types::geometric_orientation for lines. X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f24bcadf95b1efdeb2de6f8512ccd67c9a15e76c;p=dealii.git Use types::geometric_orientation for lines. --- diff --git a/include/deal.II/dofs/dof_accessor.h b/include/deal.II/dofs/dof_accessor.h index 1584668420..decc696067 100644 --- a/include/deal.II/dofs/dof_accessor.h +++ b/include/deal.II/dofs/dof_accessor.h @@ -3168,8 +3168,9 @@ namespace internal for (const auto line : accessor.line_indices()) { - const bool line_orientation = line_orientations[line]; - if (line_orientation) + const auto line_orientation = line_orientations[line]; + if (line_orientation == + ReferenceCell::default_combined_face_orientation()) dof_operation.process_dofs( accessor.get_dof_handler(), 0, diff --git a/include/deal.II/grid/reference_cell.h b/include/deal.II/grid/reference_cell.h index f4220363f1..b080d14446 100644 --- a/include/deal.II/grid/reference_cell.h +++ b/include/deal.II/grid/reference_cell.h @@ -439,10 +439,6 @@ public: * 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 the standard orientation type. */ static constexpr types::geometric_orientation reversed_combined_line_orientation(); @@ -594,21 +590,16 @@ public: const types::geometric_orientation face_orientation) const; /** - * Return whether the line with index @p line is oriented in - * standard direction within a cell, given the @p face_orientation of - * the face within the current cell, and @p line_orientation flag - * for the line within that face. @p true indicates that the line is - * oriented from vertex 0 to vertex 1, whereas it is the other way - * around otherwise. In 1d and 2d, this is always @p true, but in 3d - * it may be different, see the respective discussion in the - * documentation of the GeometryInfo class. + * Return whether the line with index @p line is oriented in standard + * direction within a cell, given the @p face_orientation of the face within + * the current cell, and @p line_orientation for the line within that face. */ - bool + types::geometric_orientation standard_vs_true_line_orientation( const unsigned int line, const unsigned int face, const types::geometric_orientation face_orientation, - const bool line_orientation) const; + const types::geometric_orientation line_orientation) const; /** * @} @@ -3227,21 +3218,26 @@ ReferenceCell::n_face_orientations(const unsigned int face_no) const -inline bool +inline types::geometric_orientation ReferenceCell::standard_vs_true_line_orientation( const unsigned int line, const unsigned int face, const types::geometric_orientation combined_face_orientation, - const bool line_orientation) const + const types::geometric_orientation line_orientation) const { + constexpr auto D = ReferenceCell::default_combined_face_orientation(); + constexpr auto R = ReferenceCell::reversed_combined_line_orientation(); if (*this == ReferenceCells::Hexahedron) { - static constexpr dealii::ndarray bool_table{ - {{{true, true, false, true, false, false, true, false}}, - {{true, true, true, false, false, false, false, true}}}}; - - return (line_orientation == - bool_table[line / 2][combined_face_orientation]); + static constexpr dealii::ndarray + table{{{{D, D, R, D, R, R, D, R}}, {{D, D, D, R, R, R, R, D}}}}; + // We use line / 2 here since lines i and i + 1 are parallel and, on a + // given face, have the same relative orientations. + const bool match = + line_orientation == table[line / 2][combined_face_orientation]; + + return match ? ReferenceCell::default_combined_face_orientation() : + ReferenceCell::reversed_combined_line_orientation(); } else if (*this == ReferenceCells::Tetrahedron) { @@ -3256,17 +3252,19 @@ ReferenceCell::standard_vs_true_line_orientation( "This function can only be called for following face-line " "combinations: (0,0), (0,1), (0,2), (1,1), (1,2), (2,1),")); - static constexpr dealii::ndarray bool_table{ - {{{false, true, false, true, false, true}}, - {{true, false, true, false, true, false}}}}; + static constexpr dealii::ndarray + table{{{{R, D, R, D, R, D}}, {{D, R, D, R, D, R}}}}; + + const bool match = + line_orientation == table[combined_line][combined_face_orientation]; - return (line_orientation == - bool_table[combined_line][combined_face_orientation]); + return match ? ReferenceCell::default_combined_face_orientation() : + ReferenceCell::reversed_combined_line_orientation(); } else // TODO: This might actually be wrong for some of the other // kinds of objects. We should check this - return true; + return ReferenceCell::default_combined_face_orientation(); } diff --git a/include/deal.II/grid/tria_accessor.h b/include/deal.II/grid/tria_accessor.h index ce1fa600df..c08276b717 100644 --- a/include/deal.II/grid/tria_accessor.h +++ b/include/deal.II/grid/tria_accessor.h @@ -999,17 +999,14 @@ public: /** * Return whether the line with index @p line is oriented in standard - * direction. @p true indicates, that the line is oriented from vertex 0 to - * vertex 1, whereas it is the other way around otherwise. In 1d and 2d, - * this is always @p true, but in 3d it may be different, see the respective - * discussion in the documentation of the GeometryInfo class. + * direction. * - * This function is really only for internal use in the library unless you - * absolutely know what this is all about. + * @warning This function is really only for internal use in the library + * unless you absolutely know what this is all about. * - * This function queries ReferenceCell::standard_vs_true_line_orientation(). + * @note This function queries ReferenceCell::standard_vs_true_line_orientation(). */ - bool + types::geometric_orientation line_orientation(const unsigned int line) const; /** * @} @@ -1813,7 +1810,8 @@ private: * structdim==2 && dim==3). */ void - set_line_orientation(const unsigned int line, const bool orientation) const; + set_line_orientation(const unsigned int line, + const types::geometric_orientation orientation) const; /** * Set the combined face orientation (i.e., the integer that uniquely encodes @@ -2171,9 +2169,9 @@ public: face_rotation(const unsigned int face); /** - * @brief Always return false + * @brief Always return ReferenceCell::reversed_combined_line_orientation() */ - static bool + static types::geometric_orientation line_orientation(const unsigned int line); /** @@ -2840,9 +2838,9 @@ public: face_rotation(const unsigned int face); /** - * @brief Always return false + * @brief Always return ReferenceCell::reversed_combined_line_orientation() */ - static bool + static types::geometric_orientation line_orientation(const unsigned int line); /** @@ -5068,10 +5066,7 @@ namespace internal // efficient std::array line_orientations = {}; for (const unsigned int line : cell.line_indices()) - line_orientations[line] = - cell.line_orientation(line) == true ? - ReferenceCell::default_combined_face_orientation() : - ReferenceCell::reversed_combined_line_orientation(); + line_orientations[line] = cell.line_orientation(line); return line_orientations; } @@ -5112,19 +5107,28 @@ namespace internal ref_cell.standard_to_real_face_line(1, f, orientation), ref_cell.standard_to_real_face_line(2, f, orientation), ref_cell.standard_to_real_face_line(3, f, orientation)}}; - const auto quad = cell.quad(f); - const std::array my_orientations{ - {ref_cell.standard_vs_true_line_orientation( - 0, f, orientation, quad->line_orientation(my_indices[0])), - ref_cell.standard_vs_true_line_orientation( - 1, f, orientation, quad->line_orientation(my_indices[1])), - ref_cell.standard_vs_true_line_orientation( - 2, f, orientation, quad->line_orientation(my_indices[2])), - ref_cell.standard_vs_true_line_orientation( - 3, - f, - orientation, - quad->line_orientation(my_indices[3]))}}; + const auto quad = cell.quad(f); + const std::array + my_orientations{{ref_cell.standard_vs_true_line_orientation( + 0, + f, + orientation, + quad->line_orientation(my_indices[0])), + ref_cell.standard_vs_true_line_orientation( + 1, + f, + orientation, + quad->line_orientation(my_indices[1])), + ref_cell.standard_vs_true_line_orientation( + 2, + f, + orientation, + quad->line_orientation(my_indices[2])), + ref_cell.standard_vs_true_line_orientation( + 3, + f, + orientation, + quad->line_orientation(my_indices[3]))}}; for (unsigned int l = 0; l < 4; ++l) line_orientations[4 * (f - 4) + l] = my_orientations[l]; } @@ -5138,15 +5142,18 @@ namespace internal const std::array my_indices{ {ref_cell.standard_to_real_face_line(0, f, orientation), ref_cell.standard_to_real_face_line(1, f, orientation)}}; - const auto quad = cell.quad(f); - const std::array my_orientations{ - {ref_cell.standard_vs_true_line_orientation( - 0, f, orientation, quad->line_orientation(my_indices[0])), - ref_cell.standard_vs_true_line_orientation( - 1, - f, - orientation, - quad->line_orientation(my_indices[1]))}}; + const auto quad = cell.quad(f); + const std::array + my_orientations{{ref_cell.standard_vs_true_line_orientation( + 0, + f, + orientation, + quad->line_orientation(my_indices[0])), + ref_cell.standard_vs_true_line_orientation( + 1, + f, + orientation, + quad->line_orientation(my_indices[1]))}}; line_orientations[8 + f] = my_orientations[0]; line_orientations[10 + f] = my_orientations[1]; } @@ -5297,11 +5304,7 @@ TriaAccessor::vertex_index( this->reference_cell().standard_vertex_to_face_and_vertex_index(corner); const auto vertex_within_line_index = this->reference_cell().standard_to_real_face_vertex( - vertex_index, - line_index, - this->line_orientation(line_index) == true ? - ReferenceCell::default_combined_face_orientation() : - ReferenceCell::reversed_combined_line_orientation()); + vertex_index, line_index, this->line_orientation(line_index)); return this->line(line_index)->vertex_index(vertex_within_line_index); } @@ -5457,7 +5460,8 @@ TriaAccessor::face_orientation( // in 1d 'faces' are vertices and those are always consistently oriented return true; else if constexpr (structdim == 2) - return this->line_orientation(face); + return this->line_orientation(face) == + ReferenceCell::default_combined_face_orientation(); else return this->tria->levels[this->present_level] ->face_orientations.get_orientation( @@ -5516,7 +5520,7 @@ TriaAccessor::face_rotation( template -inline bool +inline types::geometric_orientation TriaAccessor::line_orientation( const unsigned int line) const { @@ -5526,7 +5530,7 @@ TriaAccessor::line_orientation( (void)line; if constexpr (structdim == 1) - return true; + return ReferenceCell::default_combined_face_orientation(); else if constexpr (structdim == 2 && dim == 2) // lines in 2d are faces { @@ -5536,19 +5540,20 @@ TriaAccessor::line_orientation( combined_orientation == ReferenceCell::reversed_combined_line_orientation(), ExcInternalError()); - return combined_orientation == - ReferenceCell::default_combined_face_orientation() ? - true : - false; + return combined_orientation; } else if constexpr (structdim == 2 && dim == 3) { - // line orientations in 3d are stored in their own array - Assert(this->present_index * ReferenceCells::max_n_lines<2>() + line < - this->tria->faces->quads_line_orientations.size(), + // line orientations in 3d are stored in their own array as bools: here + // 'true' is the default orientation and 'false' is the reversed one + // (which matches set_line_orientation()) + const auto index = + this->present_index * ReferenceCells::max_n_lines<2>() + line; + Assert(index < this->tria->faces->quads_line_orientations.size(), ExcInternalError()); - return this->tria->faces->quads_line_orientations - [this->present_index * ReferenceCells::max_n_lines<2>() + line]; + return this->tria->faces->quads_line_orientations[index] ? + ReferenceCell::default_combined_face_orientation() : + ReferenceCell::reversed_combined_line_orientation(); } else if constexpr (structdim == 3 && dim == 3) { @@ -5580,8 +5585,8 @@ TriaAccessor::line_orientation( template inline void TriaAccessor::set_line_orientation( - const unsigned int line, - const bool value) const + const unsigned int line, + const types::geometric_orientation value) const { Assert(used(), TriaAccessorExceptions::ExcCellNotUsed()); AssertIndexRange(line, this->n_lines()); @@ -5600,13 +5605,14 @@ TriaAccessor::set_line_orientation( if constexpr (dim == 3) { // We set line orientations per face, not per cell, so this only works for - // faces in 3d + // faces in 3d. Assert(structdim == 2, ExcNotImplemented()); - Assert(this->present_index * ReferenceCells::max_n_lines<2>() + line < - this->tria->faces->quads_line_orientations.size(), + const auto index = + this->present_index * ReferenceCells::max_n_lines<2>() + line; + Assert(index < this->tria->faces->quads_line_orientations.size(), ExcInternalError()); - this->tria->faces->quads_line_orientations - [this->present_index * ReferenceCells::max_n_lines<2>() + line] = value; + this->tria->faces->quads_line_orientations[index] = + value == ReferenceCell::default_combined_face_orientation(); } } @@ -6905,10 +6911,10 @@ TriaAccessor<0, dim, spacedim>::face_rotation(const unsigned int /*face*/) template -inline bool +inline types::geometric_orientation TriaAccessor<0, dim, spacedim>::line_orientation(const unsigned int /*line*/) { - return false; + return ReferenceCell::reversed_combined_line_orientation(); } @@ -7353,10 +7359,10 @@ TriaAccessor<0, 1, spacedim>::face_rotation(const unsigned int /*face*/) template -inline bool +inline types::geometric_orientation TriaAccessor<0, 1, spacedim>::line_orientation(const unsigned int /*line*/) { - return false; + return ReferenceCell::reversed_combined_line_orientation(); } diff --git a/include/deal.II/numerics/vector_tools_boundary.templates.h b/include/deal.II/numerics/vector_tools_boundary.templates.h index d1b5dd86ed..26f248aada 100644 --- a/include/deal.II/numerics/vector_tools_boundary.templates.h +++ b/include/deal.II/numerics/vector_tools_boundary.templates.h @@ -1122,14 +1122,14 @@ namespace VectorTools GeometryInfo::vertices_per_face * fe.n_dofs_per_vertex() + line * fe.n_dofs_per_line() + line_dof_idx; - // Note, assuming that the edge orientations are "standard" - // i.e. cell->line_orientation(line) = true. - Assert(cell->line_orientation(line), + // Note, assuming that the edge orientations are "standard", i.e., + // cell->line_orientation(line) = + // ReferenceCell::default_combined_face_orientation() + Assert(cell->line_orientation(line) == + ReferenceCell::default_combined_face_orientation(), ExcMessage("Edge orientation does not meet expectation.")); // Next, translate from face to cell. Note, this might be assuming - // that the edge orientations are "standard" (not sure any more at - // this time), i.e. - // cell->line_orientation(line) = true. + // that the edge orientations are "standard" const unsigned int cell_dof_idx = fe.face_to_cell_index(face_dof_idx, face); @@ -1558,9 +1558,7 @@ namespace VectorTools line * fe.n_dofs_per_line() + line_dof_idx; // Next, translate from face to cell. Note, this might be - // assuming that the edge orientations are "standard" (not - // sure any more at this time), i.e. - // cell->line_orientation(line) = true. + // assuming that the edge orientations are "standard" const unsigned int cell_dof_idx = fe.face_to_cell_index(face_dof_idx, face); diff --git a/source/fe/fe_poly_tensor.cc b/source/fe/fe_poly_tensor.cc index 476517aa62..846e87be37 100644 --- a/source/fe/fe_poly_tensor.cc +++ b/source/fe/fe_poly_tensor.cc @@ -147,7 +147,8 @@ namespace internal const unsigned int dim = 2; // TODO: This fixes only lowest order for (unsigned int l = 0; l < GeometryInfo::lines_per_cell; ++l) - if (!(cell->line_orientation(l)) && + if ((cell->line_orientation(l) == + ReferenceCell::reversed_combined_line_orientation()) && mapping_kind[0] == mapping_nedelec) line_dof_sign[l] = -1.0; } @@ -165,7 +166,8 @@ namespace internal // TODO: This is probably only going to work for those elements for // which all dofs are face dofs for (unsigned int l = 0; l < GeometryInfo::lines_per_cell; ++l) - if (!(cell->line_orientation(l)) && + if ((cell->line_orientation(l) == + ReferenceCell::reversed_combined_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 9b930baed3..64e5390fc8 100644 --- a/source/grid/tria.cc +++ b/source/grid/tria.cc @@ -3314,6 +3314,9 @@ namespace internal combined_orientation == ReferenceCell::reversed_combined_line_orientation(), ExcInternalError()); + // Same convention as TriaAccessor::set_line_orientation(): + // store true for the default orientation and false for + // reversed. faces.quads_line_orientations [q * ReferenceCells::max_n_lines<2>() + j] = combined_orientation == @@ -4304,11 +4307,12 @@ namespace internal switch_1->line_index(2)), static_cast( switch_1->line_index(3))}; - const bool switch_1_line_orientations[4] = { - switch_1->line_orientation(0), - switch_1->line_orientation(1), - switch_1->line_orientation(2), - switch_1->line_orientation(3)}; + const types::geometric_orientation + switch_1_line_orientations[4] = { + switch_1->line_orientation(0), + switch_1->line_orientation(1), + switch_1->line_orientation(2), + switch_1->line_orientation(3)}; const types::boundary_id switch_1_boundary_id = switch_1->boundary_id(); const unsigned int switch_1_user_index = @@ -6449,11 +6453,7 @@ namespace internal s.insert(i); #endif - new_quad->set_line_orientation( - f, - orientation == - ReferenceCell:: - default_combined_face_orientation()); + new_quad->set_line_orientation(f, orientation); } #ifdef DEBUG AssertDimension(s.size(), 3); @@ -6567,7 +6567,8 @@ namespace internal numbers::internal_face_boundary_id); new_quad->set_manifold_id(hex->manifold_id()); for (const auto j : new_quads[i]->line_indices()) - new_quad->set_line_orientation(j, true); + new_quad->set_line_orientation( + j, ReferenceCell::default_combined_face_orientation()); } // we always get 8 children per refined cell @@ -6912,11 +6913,7 @@ namespace internal make_array_view(vertices_0), make_array_view(vertices_1)); - new_quad->set_line_orientation( - l, - orientation == - ReferenceCell:: - default_combined_face_orientation()); + new_quad->set_line_orientation(l, orientation); // on a hex, inject the status of the current line // also to the line on the other quad along the @@ -6925,11 +6922,7 @@ namespace internal ReferenceCells::Hexahedron) new_quads[representative_lines[q % 4][1] + q - (q % 4)] - ->set_line_orientation( - l, - orientation == - ReferenceCell:: - default_combined_face_orientation()); + ->set_line_orientation(l, orientation); } } } @@ -7726,7 +7719,9 @@ namespace internal for (unsigned int j = 0; j < GeometryInfo::lines_per_face; ++j) - new_quad->set_line_orientation(j, true); + new_quad->set_line_orientation( + j, + ReferenceCell::default_combined_face_orientation()); } // now set the line orientation of children of // outer lines correctly, the lines in the @@ -7949,11 +7944,12 @@ namespace internal switch_1->line_index(1), switch_1->line_index(2), switch_1->line_index(3)}; - const bool switch_1_line_orientations[4] = { - switch_1->line_orientation(0), - switch_1->line_orientation(1), - switch_1->line_orientation(2), - switch_1->line_orientation(3)}; + const types::geometric_orientation + switch_1_line_orientations[4] = { + switch_1->line_orientation(0), + switch_1->line_orientation(1), + switch_1->line_orientation(2), + switch_1->line_orientation(3)}; const types::boundary_id switch_1_boundary_id = switch_1->boundary_id(); const unsigned int switch_1_user_index = @@ -8399,7 +8395,9 @@ namespace internal for (unsigned int j = 0; j < GeometryInfo::lines_per_face; ++j) - new_quad->set_line_orientation(j, true); + new_quad->set_line_orientation( + j, + ReferenceCell::default_combined_face_orientation()); } // now set the line orientation of children of // outer lines correctly, the lines in the @@ -8550,7 +8548,9 @@ namespace internal for (unsigned int j = 0; j < GeometryInfo::lines_per_face; ++j) - new_quads[i]->set_line_orientation(j, true); + new_quads[i]->set_line_orientation( + j, + ReferenceCell::default_combined_face_orientation()); } types::subdomain_id subdomainid = hex->subdomain_id(); @@ -8769,7 +8769,7 @@ namespace internal // created ones and thus have no parents, they // cannot inherit this property. set up an array // and fill it with the respective values - bool line_orientation[4]; + types::geometric_orientation line_orientation[4]{}; // the middle vertex marked as m0 above is the // start vertex for lines 0 and 2 in standard @@ -8782,15 +8782,16 @@ namespace internal for (unsigned int i = 0; i < 4; ++i) if (lines[i]->vertex_index(i % 2) == middle_vertices[i % 2]) - line_orientation[i] = true; + line_orientation[i] = ReferenceCell:: + default_combined_face_orientation(); else { - // it must be the other - // way round then + // it must be the other way round then Assert(lines[i]->vertex_index((i + 1) % 2) == middle_vertices[i % 2], ExcInternalError()); - line_orientation[i] = false; + line_orientation[i] = ReferenceCell:: + reversed_combined_line_orientation(); } // set up the new quad, line numbering is as @@ -8996,7 +8997,7 @@ namespace internal // created ones and thus have no parents, they // cannot inherit this property. set up an array // and fill it with the respective values - bool line_orientation[4]; + types::geometric_orientation line_orientation[4]{}; // the middle vertex marked as m0 above is the // start vertex for lines 0 and 2 in standard @@ -9009,14 +9010,16 @@ namespace internal for (unsigned int i = 0; i < 4; ++i) if (lines[i]->vertex_index(i % 2) == middle_vertices[i % 2]) - line_orientation[i] = true; + line_orientation[i] = ReferenceCell:: + default_combined_face_orientation(); else { // it must be the other way round then Assert(lines[i]->vertex_index((i + 1) % 2) == middle_vertices[i % 2], ExcInternalError()); - line_orientation[i] = false; + line_orientation[i] = ReferenceCell:: + reversed_combined_line_orientation(); } // set up the new quad, line numbering is as @@ -9224,7 +9227,7 @@ namespace internal // created ones and thus have no parents, they // cannot inherit this property. set up an array // and fill it with the respective values - bool line_orientation[4]; + types::geometric_orientation line_orientation[4]{}; // the middle vertex marked as m0 above is the // start vertex for lines 0 and 2 in standard @@ -9237,14 +9240,16 @@ namespace internal for (unsigned int i = 0; i < 4; ++i) if (lines[i]->vertex_index(i % 2) == middle_vertices[i % 2]) - line_orientation[i] = true; + line_orientation[i] = ReferenceCell:: + default_combined_face_orientation(); else { // it must be the other way round then Assert(lines[i]->vertex_index((i + 1) % 2) == middle_vertices[i % 2], ExcInternalError()); - line_orientation[i] = false; + line_orientation[i] = ReferenceCell:: + reversed_combined_line_orientation(); } // set up the new quad, line numbering is as @@ -9537,7 +9542,7 @@ namespace internal // created ones and thus have no parents, they // cannot inherit this property. set up an array // and fill it with the respective values - bool line_orientation[13]; + types::geometric_orientation line_orientation[13]{}; // the middle vertices of the lines of our // bottom face @@ -9553,14 +9558,16 @@ namespace internal // face for (unsigned int i = 0; i < 4; ++i) if (lines[i]->vertex_index(0) == middle_vertices[i]) - line_orientation[i] = true; + line_orientation[i] = ReferenceCell:: + default_combined_face_orientation(); else { // it must be the other way round then Assert(lines[i]->vertex_index(1) == middle_vertices[i], ExcInternalError()); - line_orientation[i] = false; + line_orientation[i] = ReferenceCell:: + reversed_combined_line_orientation(); } // note: for lines 4 to 11 (inner lines of the @@ -9573,21 +9580,23 @@ namespace internal if (lines[i]->vertex_index((i + 1) % 2) == middle_vertex_index( hex->face(3 + i / 4))) - line_orientation[i] = true; + line_orientation[i] = ReferenceCell:: + default_combined_face_orientation(); else { - // it must be the other way - // round then + // it must be the other way round then Assert(lines[i]->vertex_index(i % 2) == (middle_vertex_index( hex->face(3 + i / 4))), ExcInternalError()); - line_orientation[i] = false; + line_orientation[i] = ReferenceCell:: + reversed_combined_line_orientation(); } // for the last line the line orientation is // always true, since it was just constructed // that way - line_orientation[12] = true; + line_orientation[12] = + ReferenceCell::default_combined_face_orientation(); // set up the 4 quads, numbered as follows (left // quad numbering, right line numbering @@ -9971,7 +9980,7 @@ namespace internal // created ones and thus have no parents, they // cannot inherit this property. set up an array // and fill it with the respective values - bool line_orientation[13]; + types::geometric_orientation line_orientation[13]{}; // the middle vertices of the // lines of our front face @@ -9986,14 +9995,16 @@ namespace internal // line is 'true', if vertex 0 is on the front for (unsigned int i = 0; i < 4; ++i) if (lines[i]->vertex_index(0) == middle_vertices[i]) - line_orientation[i] = true; + line_orientation[i] = ReferenceCell:: + default_combined_face_orientation(); else { // it must be the other way round then Assert(lines[i]->vertex_index(1) == middle_vertices[i], ExcInternalError()); - line_orientation[i] = false; + line_orientation[i] = ReferenceCell:: + reversed_combined_line_orientation(); } // note: for lines 4 to 11 (inner lines of the @@ -10006,7 +10017,8 @@ namespace internal if (lines[i]->vertex_index((i + 1) % 2) == middle_vertex_index( hex->face(1 + i / 4))) - line_orientation[i] = true; + line_orientation[i] = ReferenceCell:: + default_combined_face_orientation(); else { // it must be the other way @@ -10015,12 +10027,14 @@ namespace internal (middle_vertex_index( hex->face(1 + i / 4))), ExcInternalError()); - line_orientation[i] = false; + line_orientation[i] = ReferenceCell:: + reversed_combined_line_orientation(); } // for the last line the line orientation is // always true, since it was just constructed // that way - line_orientation[12] = true; + line_orientation[12] = + ReferenceCell::default_combined_face_orientation(); // set up the 4 quads, numbered as follows (left // quad numbering, right line numbering @@ -10419,7 +10433,7 @@ namespace internal // created ones and thus have no parents, they // cannot inherit this property. set up an array // and fill it with the respective values - bool line_orientation[13]; + types::geometric_orientation line_orientation[13]{}; // the middle vertices of the lines of our front // face @@ -10434,14 +10448,16 @@ namespace internal // line is 'true', if vertex 0 is on the front for (unsigned int i = 0; i < 4; ++i) if (lines[i]->vertex_index(0) == middle_vertices[i]) - line_orientation[i] = true; + line_orientation[i] = ReferenceCell:: + default_combined_face_orientation(); else { // it must be the other way round then Assert(lines[i]->vertex_index(1) == middle_vertices[i], ExcInternalError()); - line_orientation[i] = false; + line_orientation[i] = ReferenceCell:: + reversed_combined_line_orientation(); } // note: for lines 4 to 11 (inner lines of the @@ -10454,21 +10470,22 @@ namespace internal if (lines[i]->vertex_index((i + 1) % 2) == middle_vertex_index( hex->face(i / 4 - 1))) - line_orientation[i] = true; + line_orientation[i] = ReferenceCell:: + default_combined_face_orientation(); else { - // it must be the other way - // round then + // it must be the other way round then Assert(lines[i]->vertex_index(i % 2) == (middle_vertex_index( hex->face(i / 4 - 1))), ExcInternalError()); - line_orientation[i] = false; + line_orientation[i] = ReferenceCell:: + reversed_combined_line_orientation(); } - // for the last line the line orientation is - // always true, since it was just constructed - // that way - line_orientation[12] = true; + // for the last line the line orientation is always + // the default, since it was just constructed that way + line_orientation[12] = + ReferenceCell::default_combined_face_orientation(); // set up the 4 quads, numbered as follows (left // quad numbering, right line numbering @@ -11009,7 +11026,7 @@ namespace internal // created ones and thus have no parents, they // cannot inherit this property. set up an array // and fill it with the respective values - bool line_orientation[30]; + types::geometric_orientation line_orientation[30]{}; // note: for the first 24 lines (inner lines of // the outer quads) the following holds: the @@ -11020,7 +11037,8 @@ namespace internal for (unsigned int i = 0; i < 24; ++i) if (lines[i]->vertex_index((i + 1) % 2) == vertex_indices[i / 4]) - line_orientation[i] = true; + line_orientation[i] = ReferenceCell:: + default_combined_face_orientation(); else { // it must be the other way @@ -11028,13 +11046,15 @@ namespace internal Assert(lines[i]->vertex_index(i % 2) == vertex_indices[i / 4], ExcInternalError()); - line_orientation[i] = false; + line_orientation[i] = ReferenceCell:: + reversed_combined_line_orientation(); } // for the last 6 lines the line orientation is // always true, since they were just constructed // that way for (unsigned int i = 24; i < 30; ++i) - line_orientation[i] = true; + line_orientation[i] = ReferenceCell:: + default_combined_face_orientation(); // set up the 12 quads, numbered as follows // (left quad numbering, right line numbering @@ -15971,10 +15991,10 @@ void Triangulation::reset_cell_vertex_indices_cache() if (ref_cell == ReferenceCells::Hexahedron) for (unsigned int face = 4; face < 6; ++face) { - const auto face_iter = cell->face(face); - const std::array line_orientations{ - {face_iter->line_orientation(0), - face_iter->line_orientation(1)}}; + const auto face_iter = cell->face(face); + const std::array + line_orientations{{face_iter->line_orientation(0), + face_iter->line_orientation(1)}}; std::array raw_vertex_indices{ {face_iter->line(0)->vertex_index(1 - line_orientations[0]), face_iter->line(1)->vertex_index(1 - line_orientations[1]), @@ -16003,8 +16023,9 @@ void Triangulation::reset_cell_vertex_indices_cache() } else if (ref_cell == ReferenceCells::Quadrilateral) { - const std::array line_orientations{ - {cell->line_orientation(0), cell->line_orientation(1)}}; + const std::array + line_orientations{ + {cell->line_orientation(0), cell->line_orientation(1)}}; std::array raw_vertex_indices{ {cell->line(0)->vertex_index(1 - line_orientations[0]), cell->line(1)->vertex_index(1 - line_orientations[1]), diff --git a/tests/fe/fe_conformity_test.h b/tests/fe/fe_conformity_test.h index 9859c9027b..df239860cd 100644 --- a/tests/fe/fe_conformity_test.h +++ b/tests/fe/fe_conformity_test.h @@ -191,8 +191,9 @@ namespace FEConforimityTest ++line_index) { deallog << " {" << line_index << " -> " - << cell->line_orientation(line_index) << "}" - << std::endl; + << (cell->line_orientation(line_index) == + ReferenceCell::default_combined_face_orientation()) + << "}" << std::endl; } // line_index } // cell } // plot_mesh_properties @@ -243,8 +244,9 @@ namespace FEConforimityTest ++line_index) { deallog << " {" << line_index << " -> " - << cell->line_orientation(line_index) << "}" - << std::endl; + << (cell->line_orientation(line_index) == + ReferenceCell::default_combined_face_orientation()) + << "}" << std::endl; } // line_index } // cell } // plot_mesh_properties diff --git a/tests/grid/extrude_orientation_01.cc b/tests/grid/extrude_orientation_01.cc index 903a6e3159..45f6748fe9 100644 --- a/tests/grid/extrude_orientation_01.cc +++ b/tests/grid/extrude_orientation_01.cc @@ -68,7 +68,10 @@ test(std::ostream &out) << (c->face_flip(f) ? "/true" : "/false") << std::endl; for (unsigned int e = 0; e < GeometryInfo<3>::lines_per_cell; ++e) deallog << " edge=" << e - << (c->line_orientation(e) ? " -> true" : " -> false") + << (c->line_orientation(e) == + ReferenceCell::default_combined_face_orientation() ? + " -> true" : + " -> false") << std::endl; } } diff --git a/tests/grid/extrude_orientation_02.cc b/tests/grid/extrude_orientation_02.cc index c02814650b..571f5cc878 100644 --- a/tests/grid/extrude_orientation_02.cc +++ b/tests/grid/extrude_orientation_02.cc @@ -61,7 +61,10 @@ test() << (c->face_flip(f) ? "/true" : "/false") << std::endl; for (unsigned int e = 0; e < GeometryInfo<3>::lines_per_cell; ++e) deallog << " edge=" << e - << (c->line_orientation(e) ? " -> true" : " -> false") + << (c->line_orientation(e) == + ReferenceCell::default_combined_face_orientation() ? + " -> true" : + " -> false") << std::endl; } } diff --git a/tests/grid/extrude_orientation_03.cc b/tests/grid/extrude_orientation_03.cc index 6cff333298..48b2dd8ed2 100644 --- a/tests/grid/extrude_orientation_03.cc +++ b/tests/grid/extrude_orientation_03.cc @@ -60,7 +60,10 @@ test() << (c->face_flip(f) ? "/true" : "/false") << std::endl; for (unsigned int e = 0; e < GeometryInfo<3>::lines_per_cell; ++e) deallog << " edge=" << e - << (c->line_orientation(e) ? " -> true" : " -> false") + << (c->line_orientation(e) == + ReferenceCell::default_combined_face_orientation() ? + " -> true" : + " -> false") << std::endl; } } diff --git a/tests/grid/grid_generator_10.cc b/tests/grid/grid_generator_10.cc index 70d1072abb..16f776486f 100644 --- a/tests/grid/grid_generator_10.cc +++ b/tests/grid/grid_generator_10.cc @@ -107,9 +107,14 @@ check_grid() ++line) { deallog << line << ": " - << (cell->line_orientation(line) ? "true" : "false") + << (cell->line_orientation(line) == + ReferenceCell::default_combined_face_orientation() ? + "true" : + "false") << std::endl; - Assert(cell->line_orientation(line) == true, ExcInternalError()); + Assert(cell->line_orientation(line) == + ReferenceCell::default_combined_face_orientation(), + ExcInternalError()); } } } diff --git a/tests/grid/grid_generator_non_standard_orientation_mesh_2d.cc b/tests/grid/grid_generator_non_standard_orientation_mesh_2d.cc index 2d64faed2c..07b0c71f8f 100644 --- a/tests/grid/grid_generator_non_standard_orientation_mesh_2d.cc +++ b/tests/grid/grid_generator_non_standard_orientation_mesh_2d.cc @@ -55,7 +55,9 @@ plot_all_info(const Triangulation &tria) line_index < GeometryInfo::lines_per_cell; ++line_index) { - deallog << cell->line_orientation(line_index) << " "; + deallog << (cell->line_orientation(line_index) == + ReferenceCell::default_combined_face_orientation()) + << " "; } // line_index deallog << '}' << std::endl << std::endl; } // cell diff --git a/tests/grid/grid_generator_non_standard_orientation_mesh_3d.cc b/tests/grid/grid_generator_non_standard_orientation_mesh_3d.cc index 87b2ef5e31..d8d87fb994 100644 --- a/tests/grid/grid_generator_non_standard_orientation_mesh_3d.cc +++ b/tests/grid/grid_generator_non_standard_orientation_mesh_3d.cc @@ -56,7 +56,9 @@ plot_all_info(const Triangulation &tria) line_index < GeometryInfo::lines_per_cell; ++line_index) { - deallog << cell->line_orientation(line_index) << " "; + deallog << (cell->line_orientation(line_index) == + ReferenceCell::default_combined_face_orientation()) + << " "; } // line_index deallog << '}' << std::endl << std::endl; } // cell diff --git a/tests/simplex/orientation_04.cc b/tests/simplex/orientation_04.cc index c348ea19b6..7f3025ada9 100644 --- a/tests/simplex/orientation_04.cc +++ b/tests/simplex/orientation_04.cc @@ -161,7 +161,8 @@ test() p1.first = cell->line(l)->vertex_index(0); p1.second = cell->line(l)->vertex_index(1); - if (orientation_exp == false) + if (orientation_exp == + ReferenceCell::reversed_combined_line_orientation()) std::swap(p1.first, p1.second); success &= (p0 == p1);