]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Check which kinds of cells we can handle in TriaAccessor::extent_in_direction(). 18609/head
authorWolfgang Bangerth <bangerth@colostate.edu>
Tue, 1 Jul 2025 14:25:03 +0000 (08:25 -0600)
committerWolfgang Bangerth <bangerth@colostate.edu>
Tue, 1 Jul 2025 14:25:03 +0000 (08:25 -0600)
source/grid/tria_accessor.cc

index 24c0027c05fed99086536eaad156a0e1f2c2e496..7d22453879464016ffa0039d27b0be3855858dd4 100644 (file)
@@ -1584,7 +1584,10 @@ template <>
 double
 TriaAccessor<2, 2, 2>::extent_in_direction(const unsigned int axis) const
 {
-  const unsigned int lines[2][2] = {
+  Assert(this->reference_cell() == ReferenceCells::Quadrilateral,
+         ExcNotImplemented());
+
+  constexpr unsigned int lines[2][2] = {
     {2, 3},  //  Lines along x-axis, see GeometryInfo
     {0, 1}}; //  Lines along y-axis
 
@@ -1598,7 +1601,10 @@ template <>
 double
 TriaAccessor<2, 2, 3>::extent_in_direction(const unsigned int axis) const
 {
-  const unsigned int lines[2][2] = {
+  Assert(this->reference_cell() == ReferenceCells::Quadrilateral,
+         ExcNotImplemented());
+
+  constexpr unsigned int lines[2][2] = {
     {2, 3},  //  Lines along x-axis, see GeometryInfo
     {0, 1}}; //  Lines along y-axis
 
@@ -1613,17 +1619,20 @@ template <>
 double
 TriaAccessor<3, 3, 3>::extent_in_direction(const unsigned int axis) const
 {
-  const unsigned int lines[3][4] = {
+  Assert(this->reference_cell() == ReferenceCells::Hexahedron,
+         ExcNotImplemented());
+
+  constexpr unsigned int lines[3][4] = {
     {2, 3, 6, 7},    // Lines along x-axis, see GeometryInfo
     {0, 1, 4, 5},    // Lines along y-axis
     {8, 9, 10, 11}}; // Lines along z-axis
 
   AssertIndexRange(axis, 3);
 
-  double lengths[4] = {this->line(lines[axis][0])->diameter(),
-                       this->line(lines[axis][1])->diameter(),
-                       this->line(lines[axis][2])->diameter(),
-                       this->line(lines[axis][3])->diameter()};
+  const double lengths[4] = {this->line(lines[axis][0])->diameter(),
+                             this->line(lines[axis][1])->diameter(),
+                             this->line(lines[axis][2])->diameter(),
+                             this->line(lines[axis][3])->diameter()};
 
   return std::max({lengths[0], lengths[1], lengths[2], lengths[3]});
 }

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.