]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Add ReferenceCell::max_n_lines<dim>().
authorDavid Wells <drwells@email.unc.edu>
Tue, 31 Dec 2024 05:49:49 +0000 (00:49 -0500)
committerDavid Wells <drwells@email.unc.edu>
Wed, 1 Jan 2025 15:54:48 +0000 (10:54 -0500)
include/deal.II/grid/reference_cell.h
include/deal.II/grid/tria_accessor.h
source/grid/tria.cc

index dca975c3adfb7204b301aadc16c572033d0d3dca..64268f40a6572880caa83d92f51e1af048006044 100644 (file)
@@ -311,6 +311,17 @@ public:
   unsigned int
   n_lines() const;
 
+  /**
+   * Return the maximum number of lines an object of dimension `structdim` can
+   * have. This is always the number of lines of a `structdim`-dimensional
+   * hypercube.
+   *
+   * @see ReferenceCell::max_n_faces()
+   */
+  template <int structdim>
+  static constexpr unsigned int
+  max_n_lines();
+
   /**
    * Return an object that can be thought of as an array containing all
    * indices from zero to n_lines().
@@ -1610,6 +1621,15 @@ ReferenceCell::n_lines() const
 
 
 
+template <int structdim>
+inline constexpr unsigned int
+ReferenceCell::max_n_lines()
+{
+  return GeometryInfo<structdim>::lines_per_cell;
+}
+
+
+
 template <int dim>
 Point<dim>
 ReferenceCell::vertex(const unsigned int v) const
index 4808a109c7f213d48e88954a9014e300b916b07a..509995fea5ee8bda2327c82dd479b12e7399a3b7 100644 (file)
@@ -5586,11 +5586,11 @@ TriaAccessor<structdim, dim, spacedim>::line_orientation(
   else if constexpr (structdim == 2 && dim == 3)
     {
       // line orientations in 3d are stored in their own array
-      Assert(this->present_index * GeometryInfo<3>::lines_per_face + line <
+      Assert(this->present_index * ReferenceCell::max_n_lines<2>() + line <
                this->tria->faces->quads_line_orientations.size(),
              ExcInternalError());
       return this->tria->faces->quads_line_orientations
-        [this->present_index * GeometryInfo<3>::lines_per_face + line];
+        [this->present_index * ReferenceCell::max_n_lines<2>() + line];
     }
   else if constexpr (structdim == 3 && dim == 3)
     {
@@ -5644,11 +5644,11 @@ TriaAccessor<structdim, dim, spacedim>::set_line_orientation(
       // We set line orientations per face, not per cell, so this only works for
       // faces in 3d
       Assert(structdim == 2, ExcNotImplemented());
-      Assert(this->present_index * GeometryInfo<3>::lines_per_face + line <
+      Assert(this->present_index * ReferenceCell::max_n_lines<2>() + line <
                this->tria->faces->quads_line_orientations.size(),
              ExcInternalError());
       this->tria->faces->quads_line_orientations
-        [this->present_index * GeometryInfo<3>::lines_per_face + line] = value;
+        [this->present_index * ReferenceCell::max_n_lines<2>() + line] = value;
     }
 }
 
index 4aa54eb69a26b3e892ab7a10326ddc9c169bab53..2427d4017c2bb266b597eba56575e420c3a4c6f3 100644 (file)
@@ -2070,7 +2070,7 @@ namespace internal
         {
           // reserve the field of the derived class
           tria_faces.quads_line_orientations.resize(
-            new_size * GeometryInfo<3>::lines_per_face, true);
+            new_size * ReferenceCell::max_n_lines<2>(), true);
 
           auto &q_is_q = tria_faces.quad_is_quadrilateral;
           q_is_q.reserve(new_size);
@@ -3289,14 +3289,16 @@ namespace internal
             for (unsigned int q = 0, k = 0; q < n_quads; ++q)
               {
                 // set entity type of quads
-                faces.set_quad_type(q, connectivity.entity_types(2)[q]);
+                const auto reference_cell = connectivity.entity_types(2)[q];
+                faces.set_quad_type(q, reference_cell);
 
                 // loop over all its lines
                 for (unsigned int i = crs.ptr[q], j = 0; i < crs.ptr[q + 1];
                      ++i, ++j, ++k)
                   {
+                    AssertIndexRange(j, reference_cell.n_lines());
                     // set line index
-                    quads_0.cells[q * GeometryInfo<3>::lines_per_face + j] =
+                    quads_0.cells[q * ReferenceCell::max_n_lines<2>() + j] =
                       crs.col[i];
 
                     // set line orientations
@@ -3312,7 +3314,7 @@ namespace internal
                           ReferenceCell::reversed_combined_line_orientation(),
                       ExcInternalError());
                     faces.quads_line_orientations
-                      [q * GeometryInfo<3>::lines_per_face + j] =
+                      [q * ReferenceCell::max_n_lines<2>() + j] =
                       combined_orientation ==
                       ReferenceCell::default_combined_face_orientation();
                   }

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.