From 2664c815ed55ac2db0b3e491e7dce9a410b70e30 Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Tue, 20 Apr 2021 10:55:52 -0600 Subject: [PATCH] Deprecate TriaAccessor::number_of_children. Use TriaAccessor::n_active_descendants() instead. --- examples/step-30/doc/intro.dox | 4 +-- examples/step-30/step-30.cc | 6 ++-- include/deal.II/grid/grid_tools.h | 2 +- include/deal.II/grid/tria_accessor.h | 25 +++++++++++++++- .../deal.II/grid/tria_accessor.templates.h | 29 ++++++++++++++++++- source/dofs/dof_tools_constraints.cc | 2 +- source/dofs/dof_tools_sparsity.cc | 2 +- source/fe/fe_values.cc | 4 +-- source/grid/tria.cc | 2 +- source/grid/tria_accessor.cc | 2 +- tests/aniso/mesh_3d_21.cc | 2 +- 11 files changed, 65 insertions(+), 15 deletions(-) diff --git a/examples/step-30/doc/intro.dox b/examples/step-30/doc/intro.dox index 20733dbcc0..31a50d6144 100644 --- a/examples/step-30/doc/intro.dox +++ b/examples/step-30/doc/intro.dox @@ -283,11 +283,11 @@ write code that works for both isotropic and anisotropic refinement: @endcode Here the number of subfaces is three. It is important to note the subtle differences between, for a face, TriaAccessor::n_children() and - TriaAccessor::number_of_children(). The first function returns the number of + TriaAccessor::n_active_descendants(). The first function returns the number of immediate children, which would be two for the above example, whereas the second returns the number of active offspring (i.e., including children, grandchildren, and further descendants), which is the correct three in - the example above. Using face->number_of_children() works for + the example above. Using face->n_active_descendants() works for isotropic and anisotropic as well as 2D and 3D cases, so it should always be used. It should be noted that if any of the cells behind the two small subfaces on the left side of the rightmost image is further diff --git a/examples/step-30/step-30.cc b/examples/step-30/step-30.cc index 43043d571b..b9dfadf843 100644 --- a/examples/step-30/step-30.cc +++ b/examples/step-30/step-30.cc @@ -497,7 +497,7 @@ namespace Step30 // Now we loop over all subfaces, i.e. the children and // possibly grandchildren of the current face. for (unsigned int subface_no = 0; - subface_no < face->number_of_children(); + subface_no < face->n_active_descendants(); ++subface_no) { // To get the cell behind the current subface we can @@ -747,7 +747,7 @@ namespace Step30 unsigned int neighbor2 = cell->neighbor_face_no(face_no); // Now we loop over all subfaces, for (unsigned int subface_no = 0; - subface_no < face->number_of_children(); + subface_no < face->n_active_descendants(); ++subface_no) { // get an iterator pointing to the cell behind the @@ -840,7 +840,7 @@ namespace Step30 ExcInternalError()); Assert(neighbor_face_subface.second < neighbor->face(neighbor_face_subface.first) - ->number_of_children(), + ->n_active_descendants(), ExcInternalError()); Assert(neighbor->neighbor_child_on_subface( neighbor_face_subface.first, diff --git a/include/deal.II/grid/grid_tools.h b/include/deal.II/grid/grid_tools.h index d6473fbf3e..a9a1666399 100644 --- a/include/deal.II/grid/grid_tools.h +++ b/include/deal.II/grid/grid_tools.h @@ -3487,7 +3487,7 @@ namespace GridTools // out which border to the present // cell for (unsigned int c = 0; - c < cell->face(n)->number_of_children(); + c < cell->face(n)->n_active_descendants(); ++c) active_neighbors.push_back( cell->neighbor_child_on_subface(n, c)); diff --git a/include/deal.II/grid/tria_accessor.h b/include/deal.II/grid/tria_accessor.h index 5214e06cd8..468efa9423 100644 --- a/include/deal.II/grid/tria_accessor.h +++ b/include/deal.II/grid/tria_accessor.h @@ -953,6 +953,13 @@ public: unsigned int n_children() const; + /** + * @deprecated Use n_active_descendants() instead. + */ + DEAL_II_DEPRECATED_EARLY + unsigned int + number_of_children() const; + /** * Compute and return the number of active descendants of this objects. For * example, if all of the eight children of a hex are further refined @@ -967,7 +974,7 @@ public: * current object is not further refined, the answer is one. */ unsigned int - number_of_children() const; + n_active_descendants() const; /** * Return the number of times that this object is refined. Note that not all @@ -2128,8 +2135,16 @@ public: * Always zero. */ static unsigned int + n_active_descendants(); + + /** + * @deprecated Use n_active_descendants() instead. + */ + DEAL_II_DEPRECATED_EARLY + static unsigned int number_of_children(); + /** * Return the number of times that this object is refined. Always 0. */ @@ -2586,8 +2601,16 @@ public: * Always zero. */ static unsigned int + n_active_descendants(); + + /** + * @deprecated Use n_active_descendants() instead. + */ + DEAL_II_DEPRECATED_EARLY + static unsigned int number_of_children(); + /** * Return the number of times that this object is refined. Always 0. */ diff --git a/include/deal.II/grid/tria_accessor.templates.h b/include/deal.II/grid/tria_accessor.templates.h index ed0e211ca3..1524e05e9f 100644 --- a/include/deal.II/grid/tria_accessor.templates.h +++ b/include/deal.II/grid/tria_accessor.templates.h @@ -1800,6 +1800,15 @@ TriaAccessor::max_refinement_depth() const template unsigned int TriaAccessor::number_of_children() const +{ + return n_active_descendants(); +} + + + +template +unsigned int +TriaAccessor::n_active_descendants() const { if (!this->has_children()) return 1; @@ -1807,7 +1816,7 @@ TriaAccessor::number_of_children() const { unsigned int sum = 0; for (unsigned int c = 0; c < n_children(); ++c) - sum += this->child(c)->number_of_children(); + sum += this->child(c)->n_active_descendants(); return sum; } } @@ -2566,6 +2575,15 @@ TriaAccessor<0, dim, spacedim>::number_of_children() +template +inline unsigned int +TriaAccessor<0, dim, spacedim>::n_active_descendants() +{ + return 0; +} + + + template inline unsigned int TriaAccessor<0, dim, spacedim>::max_refinement_depth() @@ -2989,6 +3007,15 @@ TriaAccessor<0, 1, spacedim>::number_of_children() +template +inline unsigned int +TriaAccessor<0, 1, spacedim>::n_active_descendants() +{ + return 0; +} + + + template inline unsigned int TriaAccessor<0, 1, spacedim>::max_refinement_depth() diff --git a/source/dofs/dof_tools_constraints.cc b/source/dofs/dof_tools_constraints.cc index 7809d2d525..96aa50209a 100644 --- a/source/dofs/dof_tools_constraints.cc +++ b/source/dofs/dof_tools_constraints.cc @@ -1139,7 +1139,7 @@ namespace DoFTools if (dof_handler.has_hp_capabilities()) for (unsigned int c = 0; - c < cell->face(face)->number_of_children(); + c < cell->face(face)->n_active_descendants(); ++c) { const auto subcell = diff --git a/source/dofs/dof_tools_sparsity.cc b/source/dofs/dof_tools_sparsity.cc index 241e1e6746..b295c1deac 100644 --- a/source/dofs/dof_tools_sparsity.cc +++ b/source/dofs/dof_tools_sparsity.cc @@ -608,7 +608,7 @@ namespace DoFTools if (neighbor->has_children()) { for (unsigned int sub_nr = 0; - sub_nr != cell_face->number_of_children(); + sub_nr != cell_face->n_active_descendants(); ++sub_nr) { const typename DoFHandler:: diff --git a/source/fe/fe_values.cc b/source/fe/fe_values.cc index 6284724fe2..fb39b05f08 100644 --- a/source/fe/fe_values.cc +++ b/source/fe/fe_values.cc @@ -5052,10 +5052,10 @@ FESubfaceValues::reinit( 0, GeometryInfo::max_children_per_face)); Assert(!cell->face(face_no)->has_children() || - subface_no < cell->face(face_no)->number_of_children(), + subface_no < cell->face(face_no)->n_active_descendants(), ExcIndexRange(subface_no, 0, - cell->face(face_no)->number_of_children())); + cell->face(face_no)->n_active_descendants())); Assert(cell->has_children() == false, ExcMessage("You can't use subface data for cells that are " "already refined. Iterate over their children " diff --git a/source/grid/tria.cc b/source/grid/tria.cc index 33cfcd5252..2995dc9025 100644 --- a/source/grid/tria.cc +++ b/source/grid/tria.cc @@ -5326,7 +5326,7 @@ namespace internal if (face_ref_case == RefinementCase::isotropic_refinement) { - if (aface->number_of_children() < 4) + if (aface->n_active_descendants() < 4) // we use user_flags to denote needed // isotropic refinement aface->set_user_flag(); diff --git a/source/grid/tria_accessor.cc b/source/grid/tria_accessor.cc index 6f4e270ac5..44def28d05 100644 --- a/source/grid/tria_accessor.cc +++ b/source/grid/tria_accessor.cc @@ -2981,7 +2981,7 @@ CellAccessor::neighbor_child_on_subface( const typename Triangulation::face_iterator mother_face = this->face(face); const unsigned int total_children = - mother_face->number_of_children(); + mother_face->n_active_descendants(); AssertIndexRange(subface, total_children); Assert(total_children <= GeometryInfo<3>::max_children_per_face, ExcInternalError()); diff --git a/tests/aniso/mesh_3d_21.cc b/tests/aniso/mesh_3d_21.cc index c39b5d5480..10bd2bb714 100644 --- a/tests/aniso/mesh_3d_21.cc +++ b/tests/aniso/mesh_3d_21.cc @@ -66,7 +66,7 @@ void check_this(Triangulation<3> &tria) for (const unsigned int face_no : GeometryInfo<3>::face_indices()) if (!cell->at_boundary(face_no) && cell->face(face_no)->has_children()) for (unsigned int subface_no = 0; - subface_no < cell->face(face_no)->number_of_children(); + subface_no < cell->face(face_no)->n_active_descendants(); ++subface_no) { unsigned int neighbor_neighbor = cell->neighbor_face_no(face_no); -- 2.39.5