]> https://gitweb.dealii.org/ - dealii.git/commitdiff
ReferenceCell: fix some 0d code.
authorDavid Wells <drwells@email.unc.edu>
Fri, 11 Apr 2025 17:41:06 +0000 (13:41 -0400)
committerDavid Wells <drwells@email.unc.edu>
Thu, 17 Apr 2025 17:26:08 +0000 (13:26 -0400)
include/deal.II/grid/reference_cell.h

index 8d3cf0f0f3258b068eba6d9e99f0b0ad43115b18..4ab3293bf39b3ebfe5f3be3257c5ebc30a7998a0 100644 (file)
@@ -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 <int dim>
   double
@@ -2888,10 +2894,13 @@ ReferenceCell::d_linear_shape_function(const Point<dim>  &xi,
   switch (this->kind)
     {
       case ReferenceCells::Vertex:
+        return 1.0;
       case ReferenceCells::Line:
       case ReferenceCells::Quadrilateral:
       case ReferenceCells::Hexahedron:
-        return GeometryInfo<dim>::d_linear_shape_function(xi, i);
+        if constexpr (dim > 0)
+          return GeometryInfo<dim>::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<dim>  &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:

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.