From eb1c2116fcf1b97ced8b2128330c7b015523dede Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Tue, 13 Jun 2023 13:22:51 -0600 Subject: [PATCH] Clarify why n_faces() is only possible on cells. --- include/deal.II/grid/tria_accessor.h | 10 +++++++--- include/deal.II/grid/tria_accessor.templates.h | 5 ++++- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/include/deal.II/grid/tria_accessor.h b/include/deal.II/grid/tria_accessor.h index a8d0da59dd..7148294c37 100644 --- a/include/deal.II/grid/tria_accessor.h +++ b/include/deal.II/grid/tria_accessor.h @@ -1740,9 +1740,13 @@ public: n_lines() const; /** - * Number of faces. - * - * @note Only implemented for cells (structdim==dim). + * Return the number of faces for a cell. This function is only + * implemented for cells (i.e., `structdim==dim`) to avoid the question + * of what exactly is meant in a construct such as + * `cell->face(f)->n_faces()`. If you want to ask how many bounding + * lines a face of a 3d cell has, use `cell->face(f)->n_lines()`; if + * you want to ask about the number of vertices of a face of a 2d cell, + * use `cell->face(f)->n_vertices()`. */ unsigned int n_faces() const; diff --git a/include/deal.II/grid/tria_accessor.templates.h b/include/deal.II/grid/tria_accessor.templates.h index e92a899271..f9b70a7d76 100644 --- a/include/deal.II/grid/tria_accessor.templates.h +++ b/include/deal.II/grid/tria_accessor.templates.h @@ -2397,7 +2397,10 @@ template unsigned int TriaAccessor::n_faces() const { - AssertDimension(structdim, dim); + Assert(structdim == dim, + ExcMessage("This function can only be used on objects " + "that are cells, but not on faces or edges " + "that bound cells.")); return this->reference_cell().n_faces(); } -- 2.39.5