From: Wolfgang Bangerth Date: Tue, 9 Feb 2021 01:31:49 +0000 (-0700) Subject: Also move internal::ReferenceCell::Base::vertex/line/face_indices() to ReferenceCell. X-Git-Tag: v9.3.0-rc1~464^2~1 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fbc1c3d1181bfdbdb3f94599ea34df7acc6da93a;p=dealii.git Also move internal::ReferenceCell::Base::vertex/line/face_indices() to ReferenceCell. --- diff --git a/include/deal.II/fe/fe_tools.templates.h b/include/deal.II/fe/fe_tools.templates.h index 7952648c1b..f96914254c 100644 --- a/include/deal.II/fe/fe_tools.templates.h +++ b/include/deal.II/fe/fe_tools.templates.h @@ -235,9 +235,7 @@ namespace FETools // one, taking into account multiplicities, and other complications unsigned int total_index = 0; for (const unsigned int vertex_number : - dealii::internal::ReferenceCell::get_cell( - fes.front()->reference_cell()) - .vertex_indices()) + fes.front()->reference_cell().vertex_indices()) { for (unsigned int base = 0; base < fes.size(); ++base) for (unsigned int m = 0; m < multiplicities[base]; ++m) @@ -258,9 +256,7 @@ namespace FETools // 2. Lines for (const unsigned int line_number : - dealii::internal::ReferenceCell::get_cell( - fes.front()->reference_cell()) - .line_indices()) + fes.front()->reference_cell().line_indices()) { for (unsigned int base = 0; base < fes.size(); ++base) for (unsigned int m = 0; m < multiplicities[base]; ++m) @@ -426,9 +422,7 @@ namespace FETools // base elements, and other complications unsigned int total_index = 0; for (const unsigned int vertex_number : - dealii::internal::ReferenceCell::get_cell( - fes.front()->reference_cell()) - .vertex_indices()) + fes.front()->reference_cell().vertex_indices()) { unsigned int comp_start = 0; for (unsigned int base = 0; base < fes.size(); ++base) @@ -461,9 +455,7 @@ namespace FETools // 2. Lines for (const unsigned int line_number : - dealii::internal::ReferenceCell::get_cell( - fes.front()->reference_cell()) - .line_indices()) + fes.front()->reference_cell().line_indices()) { unsigned int comp_start = 0; for (unsigned int base = 0; base < fes.size(); ++base) @@ -669,8 +661,7 @@ namespace FETools // vertex, etc total_index = 0; for (const unsigned int vertex_number : - dealii::internal::ReferenceCell::get_cell(fe.reference_cell()) - .vertex_indices()) + fe.reference_cell().vertex_indices()) { unsigned int comp_start = 0; for (unsigned int base = 0; base < fe.n_base_elements(); ++base) @@ -711,9 +702,7 @@ namespace FETools } // 2. Lines - for (const unsigned int line_number : - dealii::internal::ReferenceCell::get_cell(fe.reference_cell()) - .line_indices()) + for (const unsigned int line_number : fe.reference_cell().line_indices()) { unsigned int comp_start = 0; for (unsigned int base = 0; base < fe.n_base_elements(); ++base) diff --git a/include/deal.II/grid/reference_cell.h b/include/deal.II/grid/reference_cell.h index 83718e97bc..7af95cb45e 100644 --- a/include/deal.II/grid/reference_cell.h +++ b/include/deal.II/grid/reference_cell.h @@ -220,6 +220,13 @@ public: unsigned int n_vertices() const; + /** + * Return an object that can be thought of as an array containing all + * indices from zero to n_vertices(). + */ + std_cxx20::ranges::iota_view + vertex_indices() const; + /** * Return the number of lines that make up the reference * cell in question. A line is an "edge" (a one-dimensional @@ -228,6 +235,13 @@ public: unsigned int n_lines() const; + /** + * Return an object that can be thought of as an array containing all + * indices from zero to n_lines(). + */ + std_cxx20::ranges::iota_view + line_indices() const; + /** * Return the number of faces that make up the reference * cell in question. A face is a `(dim-1)`-dimensional @@ -236,6 +250,13 @@ public: unsigned int n_faces() const; + /** + * Return an object that can be thought of as an array containing all + * indices from zero to n_faces(). + */ + std_cxx20::ranges::iota_view + face_indices() const; + /** * Return the reference-cell type of face @p face_no of the current * object. For example, if the current object is @@ -676,6 +697,30 @@ ReferenceCell::n_faces() const +inline std_cxx20::ranges::iota_view +ReferenceCell::vertex_indices() const +{ + return {0U, n_vertices()}; +} + + + +inline std_cxx20::ranges::iota_view +ReferenceCell::line_indices() const +{ + return {0U, n_lines()}; +} + + + +inline std_cxx20::ranges::iota_view +ReferenceCell::face_indices() const +{ + return {0U, n_faces()}; +} + + + inline ReferenceCell ReferenceCell::face_reference_cell(const unsigned int face_no) const { @@ -1083,7 +1128,6 @@ namespace internal return 0; } - public: /** * Return an object that can be thought of as an array containing all * indices from zero to n_vertices(). @@ -1114,6 +1158,7 @@ namespace internal return {0U, n_faces()}; } + public: /** * Standard decomposition of vertex index into face and face-vertex * index. diff --git a/source/grid/grid_in.cc b/source/grid/grid_in.cc index efb9518538..b43bd544c6 100644 --- a/source/grid/grid_in.cc +++ b/source/grid/grid_in.cc @@ -3346,13 +3346,11 @@ GridIn::read_exodusii( AssertThrowExodusII(ierr); const ReferenceCell type = exodusii_name_to_type(string_temp.data(), n_nodes_per_element); - const internal::ReferenceCell::Base &info = - internal::ReferenceCell::get_cell(type); // The number of nodes per element may be larger than what we want to // read - for example, if the Exodus file contains a QUAD9 element, we // only want to read the first four values and ignore the rest. - Assert(int(info.n_vertices()) <= n_nodes_per_element, ExcInternalError()); + Assert(int(type.n_vertices()) <= n_nodes_per_element, ExcInternalError()); std::vector connection(n_nodes_per_element * n_block_elements); ierr = ex_get_conn(ex_id, @@ -3366,10 +3364,11 @@ GridIn::read_exodusii( for (unsigned int elem_n = 0; elem_n < connection.size(); elem_n += n_nodes_per_element) { - CellData cell(info.n_vertices()); - for (unsigned int i : info.vertex_indices()) + CellData cell(type.n_vertices()); + for (unsigned int i : type.vertex_indices()) { - cell.vertices[info.exodusii_vertex_to_deal_vertex(i)] = + cell.vertices[internal::ReferenceCell::get_cell(info) + .exodusii_vertex_to_deal_vertex(i)] = connection[elem_n + i] - 1; } cell.material_id = element_block_id; diff --git a/source/simplex/fe_lib.cc b/source/simplex/fe_lib.cc index df068f13ff..fd51f04024 100644 --- a/source/simplex/fe_lib.cc +++ b/source/simplex/fe_lib.cc @@ -154,12 +154,12 @@ namespace Simplex if (dim == 1) return {}; - const auto &info = internal::ReferenceCell::get_cell( - dim == 2 ? ReferenceCells::Triangle : ReferenceCells::Tetrahedron); std::vector>> unit_face_points; // all faces have the same support points - for (auto face_n : info.face_indices()) + for (auto face_n : + (dim == 2 ? ReferenceCells::Triangle : ReferenceCells::Tetrahedron) + .face_indices()) { (void)face_n; unit_face_points.emplace_back( diff --git a/tests/simplex/fe_lib_01.cc b/tests/simplex/fe_lib_01.cc index cc0f154e78..9c46e8cbac 100644 --- a/tests/simplex/fe_lib_01.cc +++ b/tests/simplex/fe_lib_01.cc @@ -29,21 +29,19 @@ test(const FiniteElement &fe) { deallog << fe.get_name() << ": " << std::endl; - const auto &reference_cell = - internal::ReferenceCell::get_cell(fe.reference_cell()); - deallog << " n_dofs_per_vertex(): " << fe.n_dofs_per_vertex() << std::endl; deallog << " n_dofs_per_line(): " << fe.n_dofs_per_line() << std::endl; deallog << " n_dofs_per_quad(): "; - for (unsigned int i = 0; i < (dim == 2 ? 1 : reference_cell.n_faces()); ++i) + for (unsigned int i = 0; i < (dim == 2 ? 1 : fe.reference_cell().n_faces()); + ++i) deallog << fe.n_dofs_per_quad(i) << " "; deallog << std::endl; deallog << " n_dofs_per_hex(): " << fe.n_dofs_per_hex() << std::endl; deallog << " n_dofs_per_face(): "; - for (unsigned int i = 0; i < reference_cell.n_faces(); ++i) + for (unsigned int i = 0; i < fe.reference_cell().n_faces(); ++i) deallog << fe.n_dofs_per_face(i) << " "; deallog << std::endl; diff --git a/tests/simplex/reference_cell_kind_01.cc b/tests/simplex/reference_cell_kind_01.cc index 2cf95ff474..0d3e7fe611 100644 --- a/tests/simplex/reference_cell_kind_01.cc +++ b/tests/simplex/reference_cell_kind_01.cc @@ -29,10 +29,9 @@ template void test(const ReferenceCell &reference_cell) { - const auto kind = ReferenceCell(reference_cell); - const auto &info = internal::ReferenceCell::get_cell(reference_cell); + const auto kind = ReferenceCell(reference_cell); - for (const auto v : info.vertex_indices()) + for (const auto v : reference_cell.vertex_indices()) { deallog << v << ": "; for (const auto i : kind.faces_for_given_vertex(v)) diff --git a/tests/simplex/unit_tangential_vectors_01.cc b/tests/simplex/unit_tangential_vectors_01.cc index b3481a822f..61fec47d1d 100644 --- a/tests/simplex/unit_tangential_vectors_01.cc +++ b/tests/simplex/unit_tangential_vectors_01.cc @@ -30,8 +30,7 @@ template void test(const ReferenceCell &reference_cell) { - for (const auto face_no : - internal::ReferenceCell::get_cell(reference_cell).face_indices()) + for (const auto face_no : reference_cell.face_indices()) { deallog << reference_cell.template unit_normal_vectors(face_no) << std::endl;