From 570da28bcb94a1ab322627222cc39199f292ac1b Mon Sep 17 00:00:00 2001 From: David Wells Date: Fri, 11 Apr 2025 13:41:06 -0400 Subject: [PATCH] ReferenceCell: fix some 0d code. --- include/deal.II/grid/reference_cell.h | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/include/deal.II/grid/reference_cell.h b/include/deal.II/grid/reference_cell.h index 8d3cf0f0f3..4ab3293bf3 100644 --- a/include/deal.II/grid/reference_cell.h +++ b/include/deal.II/grid/reference_cell.h @@ -189,6 +189,12 @@ public: * @pre The template argument `dim` must equal the dimension * of the space in which the reference cell you are querying * lives (i.e., it must equal the result of get_dimension()). + * + * For ReferenceCells::Vertex, the reference cell is a zero-dimensional point + * in a zero-dimensional space: i.e., asking about the value of a polynomial + * doesn't make sense since there cannot be any independent variables. To + * enable dimension-independent programming we define the zero-dimensional + * value to be 1. */ template double @@ -2888,10 +2894,13 @@ ReferenceCell::d_linear_shape_function(const Point &xi, switch (this->kind) { case ReferenceCells::Vertex: + return 1.0; case ReferenceCells::Line: case ReferenceCells::Quadrilateral: case ReferenceCells::Hexahedron: - return GeometryInfo::d_linear_shape_function(xi, i); + if constexpr (dim > 0) + return GeometryInfo::d_linear_shape_function(xi, i); + DEAL_II_ASSERT_UNREACHABLE(); // see also BarycentricPolynomials<2>::compute_value case ReferenceCells::Triangle: { @@ -2962,6 +2971,7 @@ ReferenceCell::d_linear_shape_function(const Point &xi, DEAL_II_NOT_IMPLEMENTED(); } + DEAL_II_ASSERT_UNREACHABLE(); return 0.0; } @@ -3013,7 +3023,7 @@ ReferenceCell::volume() const switch (this->kind) { case ReferenceCells::Vertex: - return 0; + return 1; case ReferenceCells::Line: return 1; case ReferenceCells::Triangle: -- 2.39.5