]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Centralize the places where we call P4EST_QUADRANT_INIT/P8EST_QUADRANT_INIT. 18512/head
authorWolfgang Bangerth <bangerth@colostate.edu>
Thu, 29 May 2025 13:16:33 +0000 (07:16 -0600)
committerWolfgang Bangerth <bangerth@colostate.edu>
Thu, 29 May 2025 13:17:25 +0000 (07:17 -0600)
include/deal.II/distributed/p4est_wrappers.h
source/distributed/p4est_wrappers.cc
source/distributed/tria.cc

index bdf69e80890b7c8f9bbc5dc62d75ee2802801cdc..c7aba1df5f9819012e8dc51057e00281dce90ee0 100644 (file)
@@ -120,11 +120,17 @@ namespace internal
 
 
     /**
-     * A structure whose explicit specializations contain pointers to the
+     * A structure whose explicit specializations represent the
      * relevant p4est_* and p8est_* functions. Using this structure, for
-     * example by saying functions<dim>::quadrant_compare, we can write code
-     * in a dimension independent way, either calling p4est_quadrant_compare
-     * or p8est_quadrant_compare, depending on template argument.
+     * example by saying functions<dim>::quadrant_compare(...), we can write
+     * code in a dimension independent way, either calling
+     * p4est_quadrant_compare or p8est_quadrant_compare, depending on template
+     * argument.
+     *
+     * In most cases, the members of this class are simply pointers to
+     * p4est_* or p8est_* functions. In one case, it's simply a static
+     * member function that dispatches to things p4est chooses to
+     * implement via a macro.
      */
     template <int dim>
     struct functions;
@@ -144,6 +150,9 @@ namespace internal
                                          int                 level,
                                          std::uint64_t       id);
 
+      static void
+      quadrant_init(types<2>::quadrant &q);
+
       static int (&quadrant_is_equal)(const types<2>::quadrant *q1,
                                       const types<2>::quadrant *q2);
 
@@ -345,6 +354,9 @@ namespace internal
                                          int                 level,
                                          std::uint64_t       id);
 
+      static void
+      quadrant_init(types<3>::quadrant &q);
+
       static int (&quadrant_is_equal)(const types<3>::quadrant *q1,
                                       const types<3>::quadrant *q2);
 
index 773f3ec0952d13f5062884951341b572c313f05f..4c62e0857c2e764e7c58183cddc1517872740f6e 100644 (file)
@@ -354,6 +354,12 @@ namespace internal
                                               std::uint64_t       id) =
       p4est_quadrant_set_morton;
 
+    void
+    functions<2>::quadrant_init(types<2>::quadrant &q)
+    {
+      P4EST_QUADRANT_INIT(&q);
+    }
+
     int (&functions<2>::quadrant_is_equal)(const types<2>::quadrant *q1,
                                            const types<2>::quadrant *q2) =
       p4est_quadrant_is_equal;
@@ -567,6 +573,12 @@ namespace internal
                                               std::uint64_t       id) =
       p8est_quadrant_set_morton;
 
+    void
+    functions<3>::quadrant_init(types<3>::quadrant &q)
+    {
+      P8EST_QUADRANT_INIT(&q);
+    }
+
     int (&functions<3>::quadrant_is_equal)(const types<3>::quadrant *q1,
                                            const types<3>::quadrant *q2) =
       p8est_quadrant_is_equal;
@@ -782,18 +794,7 @@ namespace internal
       for (unsigned int c = 0;
            c < dealii::GeometryInfo<dim>::max_children_per_cell;
            ++c)
-        switch (dim)
-          {
-            case 2:
-              P4EST_QUADRANT_INIT(&p4est_children[c]);
-              break;
-            case 3:
-              P8EST_QUADRANT_INIT(&p4est_children[c]);
-              break;
-            default:
-              DEAL_II_NOT_IMPLEMENTED();
-          }
-
+        functions<dim>::quadrant_init(p4est_children[c]);
 
       functions<dim>::quadrant_childrenv(&p4est_cell, p4est_children);
     }
@@ -802,17 +803,7 @@ namespace internal
     void
     init_coarse_quadrant(typename types<dim>::quadrant &quad)
     {
-      switch (dim)
-        {
-          case 2:
-            P4EST_QUADRANT_INIT(&quad);
-            break;
-          case 3:
-            P8EST_QUADRANT_INIT(&quad);
-            break;
-          default:
-            DEAL_II_NOT_IMPLEMENTED();
-        }
+      functions<dim>::quadrant_init(quad);
       functions<dim>::quadrant_set_morton(&quad,
                                           /*level=*/0,
                                           /*index=*/0);
index 3712897afdf524715136c822cc7353d6ad554965..187846291da860301ff0b728bda2ad84f42a9af1 100644 (file)
@@ -463,17 +463,7 @@ namespace
           p4est_child[GeometryInfo<dim>::max_children_per_cell];
         for (unsigned int c = 0; c < GeometryInfo<dim>::max_children_per_cell;
              ++c)
-          switch (dim)
-            {
-              case 2:
-                P4EST_QUADRANT_INIT(&p4est_child[c]);
-                break;
-              case 3:
-                P8EST_QUADRANT_INIT(&p4est_child[c]);
-                break;
-              default:
-                DEAL_II_NOT_IMPLEMENTED();
-            }
+          internal::p4est::functions<dim>::quadrant_init(p4est_child[c]);
 
 
         internal::p4est::functions<dim>::quadrant_childrenv(&p4est_cell,
@@ -531,18 +521,7 @@ namespace
             for (unsigned int c = 0;
                  c < GeometryInfo<dim>::max_children_per_cell;
                  ++c)
-              switch (dim)
-                {
-                  case 2:
-                    P4EST_QUADRANT_INIT(&p4est_child[c]);
-                    break;
-                  case 3:
-                    P8EST_QUADRANT_INIT(&p4est_child[c]);
-                    break;
-                  default:
-                    DEAL_II_NOT_IMPLEMENTED();
-                }
-
+              internal::p4est::functions<dim>::quadrant_init(p4est_child[c]);
 
             internal::p4est::functions<dim>::quadrant_childrenv(&p4est_cell,
                                                                 p4est_child);
@@ -1353,17 +1332,7 @@ namespace
           p4est_child[GeometryInfo<dim>::max_children_per_cell];
         for (unsigned int c = 0; c < GeometryInfo<dim>::max_children_per_cell;
              ++c)
-          switch (dim)
-            {
-              case 2:
-                P4EST_QUADRANT_INIT(&p4est_child[c]);
-                break;
-              case 3:
-                P8EST_QUADRANT_INIT(&p4est_child[c]);
-                break;
-              default:
-                DEAL_II_NOT_IMPLEMENTED();
-            }
+          internal::p4est::functions<dim>::quadrant_init(p4est_child[c]);
         internal::p4est::functions<dim>::quadrant_childrenv(&p4est_cell,
                                                             p4est_child);
         for (unsigned int c = 0; c < GeometryInfo<dim>::max_children_per_cell;
@@ -1643,17 +1612,7 @@ namespace
 
         for (unsigned int c = 0; c < GeometryInfo<dim>::max_children_per_cell;
              ++c)
-          switch (dim)
-            {
-              case 2:
-                P4EST_QUADRANT_INIT(&p4est_child[c]);
-                break;
-              case 3:
-                P8EST_QUADRANT_INIT(&p4est_child[c]);
-                break;
-              default:
-                DEAL_II_NOT_IMPLEMENTED();
-            }
+          internal::p4est::functions<dim>::quadrant_init(p4est_child[c]);
 
         dealii::internal::p4est::functions<dim>::quadrant_childrenv(
           &p4est_cell, p4est_child);
@@ -1684,17 +1643,7 @@ namespace
           p4est_child[GeometryInfo<dim>::max_children_per_cell];
         for (unsigned int c = 0; c < GeometryInfo<dim>::max_children_per_cell;
              ++c)
-          switch (dim)
-            {
-              case 2:
-                P4EST_QUADRANT_INIT(&p4est_child[c]);
-                break;
-              case 3:
-                P8EST_QUADRANT_INIT(&p4est_child[c]);
-                break;
-              default:
-                DEAL_II_NOT_IMPLEMENTED();
-            }
+          internal::p4est::functions<dim>::quadrant_init(p4est_child[c]);
 
         dealii::internal::p4est::functions<dim>::quadrant_childrenv(
           &p4est_cell, p4est_child);

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.