]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Use RefinementCase::all_refinement_cases() and assorted cleanups.
authorWolfgang Bangerth <bangerth@colostate.edu>
Thu, 26 Oct 2023 19:58:31 +0000 (13:58 -0600)
committerWolfgang Bangerth <bangerth@colostate.edu>
Thu, 26 Oct 2023 19:58:31 +0000 (13:58 -0600)
include/deal.II/fe/fe_tools.templates.h
source/fe/fe.cc
source/fe/fe_dgp_nonparametric.cc
source/fe/fe_q_bubbles.cc
source/fe/fe_rt_bubbles.cc

index f093b1bb6d0a35f29bd31ce84dda85e91a2a986e..dc6b6570ec6527f6d9af51e27e994c0f2edf3eb4 100644 (file)
@@ -1865,11 +1865,11 @@ namespace FETools
     Threads::TaskGroup<void> task_group;
 
     // loop over all possible refinement cases
-    unsigned int ref_case = (isotropic_only) ?
-                              RefinementCase<dim>::isotropic_refinement :
-                              RefinementCase<dim>::cut_x;
-
-    for (; ref_case <= RefinementCase<dim>::isotropic_refinement; ++ref_case)
+    for (unsigned int ref_case =
+           (isotropic_only ? RefinementCase<dim>::isotropic_refinement :
+                             RefinementCase<dim>::cut_x);
+         ref_case <= RefinementCase<dim>::isotropic_refinement;
+         ++ref_case)
       task_group += Threads::new_task(
         &internal::FEToolsComputeEmbeddingMatricesHelper::
           compute_embedding_matrices_for_refinement_case<dim, number, spacedim>,
@@ -2270,10 +2270,11 @@ namespace FETools
 
     // finally loop over all possible refinement cases
     Threads::TaskGroup<> tasks;
-    unsigned int         ref_case = (isotropic_only) ?
-                                      RefinementCase<dim>::isotropic_refinement :
-                                      RefinementCase<dim>::cut_x;
-    for (; ref_case <= RefinementCase<dim>::isotropic_refinement; ++ref_case)
+    for (unsigned int ref_case =
+           (isotropic_only ? RefinementCase<dim>::isotropic_refinement :
+                             RefinementCase<dim>::cut_x);
+         ref_case <= RefinementCase<dim>::isotropic_refinement;
+         ++ref_case)
       tasks += Threads::new_task([&, ref_case]() {
         compute_one_case(ref_case, mass, matrices[ref_case - 1]);
       });
index 9dd634495c1c295b7e303d50ebbc7f88040c72d0..a1ca2bac05be45c312e40c55b2fd51197a889a33 100644 (file)
@@ -135,17 +135,17 @@ FiniteElement<dim, spacedim>::FiniteElement(
   // constructor of FullMatrix<dim> initializes them with size zero
   prolongation.resize(RefinementCase<dim>::isotropic_refinement);
   restriction.resize(RefinementCase<dim>::isotropic_refinement);
-  for (unsigned int ref = RefinementCase<dim>::cut_x;
-       ref < RefinementCase<dim>::isotropic_refinement + 1;
-       ++ref)
-    {
-      prolongation[ref - 1].resize(GeometryInfo<dim>::n_children(
-                                     RefinementCase<dim>(ref)),
-                                   FullMatrix<double>());
-      restriction[ref - 1].resize(GeometryInfo<dim>::n_children(
-                                    RefinementCase<dim>(ref)),
-                                  FullMatrix<double>());
-    }
+  for (const unsigned int ref_case :
+       RefinementCase<dim>::all_refinement_cases())
+    if (ref_case != RefinementCase<dim>::no_refinement)
+      {
+        prolongation[ref - 1].resize(GeometryInfo<dim>::n_children(
+                                       RefinementCase<dim>(ref)),
+                                     FullMatrix<double>());
+        restriction[ref - 1].resize(GeometryInfo<dim>::n_children(
+                                      RefinementCase<dim>(ref)),
+                                    FullMatrix<double>());
+      }
 
 
   if (dim == 3)
@@ -300,29 +300,29 @@ FiniteElement<dim, spacedim>::reinit_restriction_and_prolongation_matrices(
   const bool isotropic_restriction_only,
   const bool isotropic_prolongation_only)
 {
-  for (unsigned int ref_case = RefinementCase<dim>::cut_x;
-       ref_case <= RefinementCase<dim>::isotropic_refinement;
-       ++ref_case)
-    {
-      const unsigned int nc =
-        GeometryInfo<dim>::n_children(RefinementCase<dim>(ref_case));
-
-      for (unsigned int i = 0; i < nc; ++i)
-        {
-          if (this->restriction[ref_case - 1][i].m() !=
-                this->n_dofs_per_cell() &&
-              (!isotropic_restriction_only ||
-               ref_case == RefinementCase<dim>::isotropic_refinement))
-            this->restriction[ref_case - 1][i].reinit(this->n_dofs_per_cell(),
-                                                      this->n_dofs_per_cell());
-          if (this->prolongation[ref_case - 1][i].m() !=
-                this->n_dofs_per_cell() &&
-              (!isotropic_prolongation_only ||
-               ref_case == RefinementCase<dim>::isotropic_refinement))
-            this->prolongation[ref_case - 1][i].reinit(this->n_dofs_per_cell(),
-                                                       this->n_dofs_per_cell());
-        }
-    }
+  for (const unsigned int ref_case :
+       RefinementCase<dim>::all_refinement_cases())
+    if (ref_case != RefinementCase<dim>::no_refinement)
+      {
+        const unsigned int nc =
+          GeometryInfo<dim>::n_children(RefinementCase<dim>(ref_case));
+
+        for (unsigned int i = 0; i < nc; ++i)
+          {
+            if (this->restriction[ref_case - 1][i].m() !=
+                  this->n_dofs_per_cell() &&
+                (!isotropic_restriction_only ||
+                 ref_case == RefinementCase<dim>::isotropic_refinement))
+              this->restriction[ref_case - 1][i].reinit(
+                this->n_dofs_per_cell(), this->n_dofs_per_cell());
+            if (this->prolongation[ref_case - 1][i].m() !=
+                  this->n_dofs_per_cell() &&
+                (!isotropic_prolongation_only ||
+                 ref_case == RefinementCase<dim>::isotropic_refinement))
+              this->prolongation[ref_case - 1][i].reinit(
+                this->n_dofs_per_cell(), this->n_dofs_per_cell());
+          }
+      }
 }
 
 
@@ -722,25 +722,27 @@ template <int dim, int spacedim>
 bool
 FiniteElement<dim, spacedim>::prolongation_is_implemented() const
 {
-  for (unsigned int ref_case = RefinementCase<dim>::cut_x;
-       ref_case < RefinementCase<dim>::isotropic_refinement + 1;
-       ++ref_case)
-    for (unsigned int c = 0;
-         c < GeometryInfo<dim>::n_children(RefinementCase<dim>(ref_case));
-         ++c)
-      {
-        // make sure also the lazily initialized matrices are created
-        get_prolongation_matrix(c, RefinementCase<dim>(ref_case));
-        Assert((prolongation[ref_case - 1][c].m() == this->n_dofs_per_cell()) ||
-                 (prolongation[ref_case - 1][c].m() == 0),
-               ExcInternalError());
-        Assert((prolongation[ref_case - 1][c].n() == this->n_dofs_per_cell()) ||
-                 (prolongation[ref_case - 1][c].n() == 0),
-               ExcInternalError());
-        if ((prolongation[ref_case - 1][c].m() == 0) ||
-            (prolongation[ref_case - 1][c].n() == 0))
-          return false;
-      }
+  for (const unsigned int ref_case :
+       RefinementCase<dim>::all_refinement_cases())
+    if (ref_case != RefinementCase<dim>::no_refinement)
+      for (unsigned int c = 0;
+           c < GeometryInfo<dim>::n_children(RefinementCase<dim>(ref_case));
+           ++c)
+        {
+          // make sure also the lazily initialized matrices are created
+          get_prolongation_matrix(c, RefinementCase<dim>(ref_case));
+          Assert((prolongation[ref_case - 1][c].m() ==
+                  this->n_dofs_per_cell()) ||
+                   (prolongation[ref_case - 1][c].m() == 0),
+                 ExcInternalError());
+          Assert((prolongation[ref_case - 1][c].n() ==
+                  this->n_dofs_per_cell()) ||
+                   (prolongation[ref_case - 1][c].n() == 0),
+                 ExcInternalError());
+          if ((prolongation[ref_case - 1][c].m() == 0) ||
+              (prolongation[ref_case - 1][c].n() == 0))
+            return false;
+        }
   return true;
 }
 
@@ -750,25 +752,27 @@ template <int dim, int spacedim>
 bool
 FiniteElement<dim, spacedim>::restriction_is_implemented() const
 {
-  for (unsigned int ref_case = RefinementCase<dim>::cut_x;
-       ref_case < RefinementCase<dim>::isotropic_refinement + 1;
-       ++ref_case)
-    for (unsigned int c = 0;
-         c < GeometryInfo<dim>::n_children(RefinementCase<dim>(ref_case));
-         ++c)
-      {
-        // make sure also the lazily initialized matrices are created
-        get_restriction_matrix(c, RefinementCase<dim>(ref_case));
-        Assert((restriction[ref_case - 1][c].m() == this->n_dofs_per_cell()) ||
-                 (restriction[ref_case - 1][c].m() == 0),
-               ExcInternalError());
-        Assert((restriction[ref_case - 1][c].n() == this->n_dofs_per_cell()) ||
-                 (restriction[ref_case - 1][c].n() == 0),
-               ExcInternalError());
-        if ((restriction[ref_case - 1][c].m() == 0) ||
-            (restriction[ref_case - 1][c].n() == 0))
-          return false;
-      }
+  for (const unsigned int ref_case :
+       RefinementCase<dim>::all_refinement_cases())
+    if (ref_case != RefinementCase<dim>::no_refinement)
+      for (unsigned int c = 0;
+           c < GeometryInfo<dim>::n_children(RefinementCase<dim>(ref_case));
+           ++c)
+        {
+          // make sure also the lazily initialized matrices are created
+          get_restriction_matrix(c, RefinementCase<dim>(ref_case));
+          Assert((restriction[ref_case - 1][c].m() ==
+                  this->n_dofs_per_cell()) ||
+                   (restriction[ref_case - 1][c].m() == 0),
+                 ExcInternalError());
+          Assert((restriction[ref_case - 1][c].n() ==
+                  this->n_dofs_per_cell()) ||
+                   (restriction[ref_case - 1][c].n() == 0),
+                 ExcInternalError());
+          if ((restriction[ref_case - 1][c].m() == 0) ||
+              (restriction[ref_case - 1][c].n() == 0))
+            return false;
+        }
   return true;
 }
 
index 21e3f9e434447b92a418ce6332b1ecc87ae51b8d..2e391ff17855b7b306df4e3fd1112100ffac0970 100644 (file)
@@ -52,27 +52,27 @@ FE_DGPNonparametric<dim, spacedim>::FE_DGPNonparametric(
   , polynomial_space(Polynomials::Legendre::generate_complete_basis(degree))
 {
   const unsigned int n_dofs = this->n_dofs_per_cell();
-  for (unsigned int ref_case = RefinementCase<dim>::cut_x;
-       ref_case < RefinementCase<dim>::isotropic_refinement + 1;
-       ++ref_case)
-    {
-      if (dim != 2 && ref_case != RefinementCase<dim>::isotropic_refinement)
-        // do nothing, as anisotropic
-        // refinement is not
-        // implemented so far
-        continue;
-
-      const unsigned int nc =
-        GeometryInfo<dim>::n_children(RefinementCase<dim>(ref_case));
-      for (unsigned int i = 0; i < nc; ++i)
-        {
-          this->prolongation[ref_case - 1][i].reinit(n_dofs, n_dofs);
-          // Fill prolongation matrices with
-          // embedding operators
-          for (unsigned int j = 0; j < n_dofs; ++j)
-            this->prolongation[ref_case - 1][i](j, j) = 1.;
-        }
-    }
+  for (const unsigned int ref_case :
+       RefinementCase<dim>::all_refinement_cases())
+    if (ref_case != RefinementCase<dim>::no_refinement)
+      {
+        if (dim != 2 && ref_case != RefinementCase<dim>::isotropic_refinement)
+          // do nothing, as anisotropic
+          // refinement is not
+          // implemented so far
+          continue;
+
+        const unsigned int nc =
+          GeometryInfo<dim>::n_children(RefinementCase<dim>(ref_case));
+        for (unsigned int i = 0; i < nc; ++i)
+          {
+            this->prolongation[ref_case - 1][i].reinit(n_dofs, n_dofs);
+            // Fill prolongation matrices with
+            // embedding operators
+            for (unsigned int j = 0; j < n_dofs; ++j)
+              this->prolongation[ref_case - 1][i](j, j) = 1.;
+          }
+      }
 
   // restriction can be defined
   // through projection for
index 274ace01a7e345b8e87e9f4b2f76d8ca3561810d..ef72b4cd71a0a99b6ec36a4e8fb7fffc7c694867 100644 (file)
@@ -92,10 +92,10 @@ namespace internal
         const unsigned int nq = q_fine->size();
 
         // loop over all possible refinement cases
-        unsigned int ref_case = (isotropic_only) ?
-                                  RefinementCase<dim>::isotropic_refinement :
-                                  RefinementCase<dim>::cut_x;
-        for (; ref_case <= RefinementCase<dim>::isotropic_refinement;
+        for (unsigned int ref_case =
+               (isotropic_only ? RefinementCase<dim>::isotropic_refinement :
+                                 RefinementCase<dim>::cut_x);
+             ref_case <= RefinementCase<dim>::isotropic_refinement;
              ++ref_case)
           {
             const unsigned int nc =
index 25ff68000c4f725bade0a3bf0f20c8fb238042ef..5613c5ea28c21680f3882fba1ddac37c1881baed 100644 (file)
@@ -68,16 +68,16 @@ FE_RT_Bubbles<dim>::FE_RT_Bubbles(const unsigned int deg)
 
   // Reinit the vectors of prolongation matrices to the
   // right sizes. There are no restriction matrices implemented
-  for (unsigned int ref_case = RefinementCase<dim>::cut_x;
-       ref_case < RefinementCase<dim>::isotropic_refinement + 1;
-       ++ref_case)
-    {
-      const unsigned int nc =
-        GeometryInfo<dim>::n_children(RefinementCase<dim>(ref_case));
+  for (const unsigned int ref_case :
+       RefinementCase<dim>::all_refinement_cases())
+    if (ref_case != RefinementCase<dim>::no_refinement)
+      {
+        const unsigned int nc =
+          GeometryInfo<dim>::n_children(RefinementCase<dim>(ref_case));
 
-      for (unsigned int i = 0; i < nc; ++i)
-        this->prolongation[ref_case - 1][i].reinit(n_dofs, n_dofs);
-    }
+        for (unsigned int i = 0; i < nc; ++i)
+          this->prolongation[ref_case - 1][i].reinit(n_dofs, n_dofs);
+      }
 
   // TODO: the implementation makes the assumption that all faces have the
   // same number of dofs

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.