]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Move invalid_fe_index to numbers. 14212/head
authorMarc Fehling <mafehling.git@gmail.com>
Thu, 2 Jun 2022 20:14:18 +0000 (14:14 -0600)
committerMarc Fehling <mafehling.git@gmail.com>
Tue, 23 Aug 2022 19:33:48 +0000 (13:33 -0600)
include/deal.II/base/types.h
include/deal.II/dofs/dof_accessor.h
include/deal.II/dofs/dof_accessor.templates.h
include/deal.II/dofs/dof_handler.h
source/dofs/dof_accessor_get.cc
source/dofs/dof_accessor_set.cc
source/dofs/dof_handler.cc
source/hp/fe_collection.cc

index 0b8efbc4812a029d08d8648c60d025609b77fd7c..5b7c96710d84545526bdb061f07516460264d4fb 100644 (file)
@@ -215,6 +215,11 @@ namespace numbers
   const types::global_dof_index invalid_size_type =
     static_cast<types::global_dof_index>(-1);
 
+  /**
+   * An invalid value for active and future fe indices.
+   */
+  const types::fe_index invalid_fe_index = static_cast<types::fe_index>(-1);
+
   /**
    * An invalid value for indices of degrees of freedom.
    */
index 9de534f05f21b5757df090f27f9ca022ea9c2ae7..19eae0834a0d544c10c0271e998c1cc2c8c6927b 100644 (file)
@@ -444,9 +444,9 @@ public:
    * <code>cell-@>active_fe_index</code> as last argument.
    */
   void
-  get_dof_indices(std::vector<types::global_dof_index> &dof_indices,
-                  const unsigned int                    fe_index =
-                    DoFHandler<dim, spacedim>::invalid_fe_index) const;
+  get_dof_indices(
+    std::vector<types::global_dof_index> &dof_indices,
+    const unsigned int fe_index = numbers::invalid_fe_index) const;
 
   /**
    * Return the global multilevel indices of the degrees of freedom that live
@@ -455,19 +455,18 @@ public:
    * level this line lives on.
    */
   void
-  get_mg_dof_indices(const int                             level,
-                     std::vector<types::global_dof_index> &dof_indices,
-                     const unsigned int                    fe_index =
-                       DoFHandler<dim, spacedim>::invalid_fe_index) const;
+  get_mg_dof_indices(
+    const int                             level,
+    std::vector<types::global_dof_index> &dof_indices,
+    const unsigned int fe_index = numbers::invalid_fe_index) const;
 
   /**
    * Set the level DoF indices that are returned by get_mg_dof_indices.
    */
   void
-  set_mg_dof_indices(
-    const int                                   level,
-    const std::vector<types::global_dof_index> &dof_indices,
-    const unsigned int fe_index = DoFHandler<dim, spacedim>::invalid_fe_index);
+  set_mg_dof_indices(const int                                   level,
+                     const std::vector<types::global_dof_index> &dof_indices,
+                     const unsigned int fe_index = numbers::invalid_fe_index);
 
   /**
    * Global DoF index of the <i>i</i> degree associated with the @p vertexth
@@ -491,10 +490,10 @@ public:
    * this is interpreted as equal to `cell->active_fe_index()`.
    */
   types::global_dof_index
-  vertex_dof_index(const unsigned int vertex,
-                   const unsigned int i,
-                   const unsigned int fe_index =
-                     DoFHandler<dim, spacedim>::invalid_fe_index) const;
+  vertex_dof_index(
+    const unsigned int vertex,
+    const unsigned int i,
+    const unsigned int fe_index = numbers::invalid_fe_index) const;
 
   /**
    * Return the global DoF index of the <code>i</code>th degree of freedom
@@ -502,11 +501,11 @@ public:
    * see vertex_dof_index().
    */
   types::global_dof_index
-  mg_vertex_dof_index(const int          level,
-                      const unsigned int vertex,
-                      const unsigned int i,
-                      const unsigned int fe_index =
-                        DoFHandler<dim, spacedim>::invalid_fe_index) const;
+  mg_vertex_dof_index(
+    const int          level,
+    const unsigned int vertex,
+    const unsigned int i,
+    const unsigned int fe_index = numbers::invalid_fe_index) const;
 
   /**
    * Index of the <i>i</i>th degree of freedom of this object.
@@ -537,8 +536,7 @@ public:
    */
   types::global_dof_index
   dof_index(const unsigned int i,
-            const unsigned int fe_index =
-              DoFHandler<dim, spacedim>::invalid_fe_index) const;
+            const unsigned int fe_index = numbers::invalid_fe_index) const;
 
   /**
    * Return the dof_index on the given level. Also see dof_index.
@@ -715,8 +713,7 @@ protected:
   void
   set_dof_index(const unsigned int            i,
                 const types::global_dof_index index,
-                const unsigned int            fe_index =
-                  DoFHandler<dim, spacedim>::invalid_fe_index) const;
+                const unsigned int fe_index = numbers::invalid_fe_index) const;
 
   void
   set_mg_dof_index(const int                     level,
@@ -724,12 +721,12 @@ protected:
                    const types::global_dof_index index) const;
 
   void
-  set_mg_vertex_dof_index(const int                     level,
-                          const unsigned int            vertex,
-                          const unsigned int            i,
-                          const types::global_dof_index index,
-                          const unsigned int            fe_index =
-                            DoFHandler<dim, spacedim>::invalid_fe_index) const;
+  set_mg_vertex_dof_index(
+    const int                     level,
+    const unsigned int            vertex,
+    const unsigned int            i,
+    const types::global_dof_index index,
+    const unsigned int            fe_index = numbers::invalid_fe_index) const;
 
   // Iterator classes need to be friends because they need to access
   // operator== and operator!=.
@@ -1302,8 +1299,7 @@ public:
   void
   set_dof_index(const unsigned int            i,
                 const types::global_dof_index index,
-                const unsigned int            fe_index =
-                  DoFHandler<dim, spacedim>::invalid_fe_index) const;
+                const unsigned int fe_index = numbers::invalid_fe_index) const;
 };
 
 
index cbad821178958f2e112ec11a959d450d170165e2..3515d1ca24d57e3301f4aef3b36e44223ed99981 100644 (file)
@@ -199,7 +199,7 @@ namespace internal
   {
     /**
      * Convert an FE index that might contain the right value but also
-     * invalid_fe_index to a right value if needed/possible.
+     * numbers::invalid_fe_index to a right value if needed/possible.
      */
     template <int structdim, int dim, int spacedim, bool level_dof_access>
     unsigned int
@@ -212,7 +212,7 @@ namespace internal
           // No hp enabled, and the argument is at its default value -> we
           // can translate to the default active fe index
           Assert(
-            (fe_index == DoFHandler<dim, spacedim>::invalid_fe_index) ||
+            (fe_index == numbers::invalid_fe_index) ||
               (fe_index == DoFHandler<dim, spacedim>::default_fe_index),
             ExcMessage(
               "It is not possible to specify a FE index if no hp support is used!"));
@@ -226,15 +226,14 @@ namespace internal
           // we are on a cell (rather than a face/edge/vertex), then we know
           // that there is only one active fe index on this cell and we can
           // use that:
-          if ((dim == structdim) &&
-              (fe_index == DoFHandler<dim, spacedim>::invalid_fe_index))
+          if ((dim == structdim) && (fe_index == numbers::invalid_fe_index))
             {
               AssertDimension(cell.n_active_fe_indices(), 1);
 
               return cell.nth_active_fe_index(0);
             }
 
-          Assert((fe_index != DoFHandler<dim, spacedim>::invalid_fe_index),
+          Assert((fe_index != numbers::invalid_fe_index),
                  ExcMessage(
                    "You need to specify a FE index if hp support is used!"));
 
@@ -1610,7 +1609,7 @@ DoFAccessor<structdim, dim, spacedim, level_dof_access>::vertex_dof_index(
 {
   const unsigned int fe_index =
     (((this->dof_handler->hp_capability_enabled == false) &&
-      (fe_index_ == DoFHandler<dim, spacedim>::invalid_fe_index)) ?
+      (fe_index_ == numbers::invalid_fe_index)) ?
        // No hp enabled, and the argument is at its default value -> we
        // can translate to the default active fe index
        DoFHandler<dim, spacedim>::default_fe_index :
@@ -1619,8 +1618,7 @@ DoFAccessor<structdim, dim, spacedim, level_dof_access>::vertex_dof_index(
        // we are on a cell (rather than a face/edge/vertex), then we know
        // that there is only one active fe index on this cell and we can
        // use that:
-       ((dim == structdim) &&
-            (fe_index_ == DoFHandler<dim, spacedim>::invalid_fe_index) ?
+       ((dim == structdim) && (fe_index_ == numbers::invalid_fe_index) ?
           this->nth_active_fe_index(0) :
           fe_index_));
 
@@ -2213,6 +2211,8 @@ namespace internal
         Assert(static_cast<unsigned int>(accessor.level()) <
                  accessor.dof_handler->hp_cell_future_fe_indices.size(),
                ExcMessage("DoFHandler not initialized"));
+        Assert(i != numbers::invalid_fe_index,
+               ExcMessage("Invalid finite element index."));
 
         accessor.dof_handler
           ->hp_cell_active_fe_indices[accessor.level()]
@@ -2277,6 +2277,8 @@ namespace internal
         Assert(static_cast<unsigned int>(accessor.level()) <
                  accessor.dof_handler->hp_cell_future_fe_indices.size(),
                ExcMessage("DoFHandler not initialized"));
+        Assert(i != numbers::invalid_fe_index,
+               ExcMessage("Invalid finite element index."));
 
         accessor.dof_handler
           ->hp_cell_future_fe_indices[accessor.level()]
@@ -2308,7 +2310,7 @@ namespace internal
         return accessor.dof_handler
                  ->hp_cell_future_fe_indices[accessor.level()]
                                             [accessor.present_index] !=
-               DoFHandler<dim, spacedim>::invalid_active_fe_index;
+               numbers::invalid_fe_index;
       }
 
 
@@ -2336,7 +2338,7 @@ namespace internal
         accessor.dof_handler
           ->hp_cell_future_fe_indices[accessor.level()]
                                      [accessor.present_index] =
-          DoFHandler<dim, spacedim>::invalid_active_fe_index;
+          numbers::invalid_fe_index;
       }
     };
   } // namespace DoFCellAccessorImplementation
index 11af8d9d7a5c72153d1aa6a1527fe719105d2607..786a46129c4327edb3ce8059e8ebdad6bce9307c 100644 (file)
@@ -519,8 +519,11 @@ public:
 
   /**
    * Invalid index of the finite element to be used on a given cell.
+   *
+   * @deprecated Use numbers::invalid_fe_index instead.
    */
-  static const unsigned int invalid_fe_index = numbers::invalid_unsigned_int;
+  static const unsigned int invalid_fe_index DEAL_II_DEPRECATED =
+    numbers::invalid_fe_index;
 
   /**
    * The type in which we store the active FE index.
@@ -537,9 +540,11 @@ public:
   /**
    * Invalid active FE index which will be used as a default value to determine
    * whether a future FE index has been set or not.
+   *
+   * @deprecated Use numbers::invalid_fe_index instead.
    */
-  static const types::fe_index invalid_active_fe_index =
-    static_cast<types::fe_index>(-1);
+  static const types::fe_index invalid_active_fe_index DEAL_II_DEPRECATED =
+    numbers::invalid_fe_index;
 
   /**
    * Standard constructor, not initializing any data. After constructing an
@@ -583,7 +588,8 @@ public:
 
   /**
    * Go through the triangulation and return a vector of active FE indices of
-   * all locally relevant cells.
+   * all locally relevant cells. Artificial cells will have the value
+   * numbers::invalid_fe_index assigned.
    */
   std::vector<unsigned int>
   get_active_fe_indices() const;
@@ -602,7 +608,7 @@ public:
   /**
    * Go through the triangulation and set the future FE indices of all
    * locally owned cells to the values given in @p future_fe_indices.
-   * Cells corresponding to invalid_active_fe_index will be skipped.
+   * Cells corresponding to numbers::invalid_fe_index will be skipped.
    */
   void
   set_future_fe_indices(const std::vector<unsigned int> &future_fe_indices);
@@ -610,7 +616,7 @@ public:
   /**
    * Go through the triangulation and return a vector of future FE indices of
    * all locally owned cells. If no future FE index has been set on a cell,
-   * its value will be invalid_active_fe_index.
+   * its value will be numbers::invalid_fe_index.
    */
   std::vector<unsigned int>
   get_future_fe_indices() const;
index 0909f6805ef89a6c572f397a2319b6c55c805a80..cd7861068faedcdf1e88bf53e30c691dc0cd4d6a 100644 (file)
@@ -50,7 +50,7 @@ DoFCellAccessor<dim, spacedim, lda>::get_interpolated_dof_values(
 {
   const unsigned int fe_index =
     (this->dof_handler->hp_capability_enabled == false &&
-     fe_index_ == DoFHandler<dim, spacedim>::invalid_fe_index) ?
+     fe_index_ == numbers::invalid_fe_index) ?
       DoFHandler<dim, spacedim>::default_fe_index :
       fe_index_;
 
@@ -64,7 +64,7 @@ DoFCellAccessor<dim, spacedim, lda>::get_interpolated_dof_values(
           // active cells, you either don't specify an fe_index,
           // or that you specify the correct one
           (fe_index == this->active_fe_index()) ||
-          (fe_index == DoFHandler<dim, spacedim>::invalid_fe_index))
+          (fe_index == numbers::invalid_fe_index))
         this->get_dof_values(values, interpolated_values);
       else
         {
@@ -102,7 +102,7 @@ DoFCellAccessor<dim, spacedim, lda>::get_interpolated_dof_values(
       // space to this cell's (unknown) FE space unless an explicit
       // fe_index is given
       Assert((this->dof_handler->hp_capability_enabled == false) ||
-               (fe_index != DoFHandler<dim, spacedim>::invalid_fe_index),
+               (fe_index != numbers::invalid_fe_index),
              ExcMessage(
                "You cannot call this function on non-active cells "
                "of DoFHandler objects unless you provide an explicit "
index 6ff52a32cd9ced96c5f57053624c00e962a8d208..feea52deffcab701588b85977b748420370e503f 100644 (file)
@@ -186,7 +186,7 @@ namespace internal
   {
     const unsigned int fe_index =
       (cell.get_dof_handler().has_hp_capabilities() == false &&
-       fe_index_ == DoFHandler<dim, spacedim>::invalid_fe_index) ?
+       fe_index_ == numbers::invalid_fe_index) ?
         DoFHandler<dim, spacedim>::default_fe_index :
         fe_index_;
 
@@ -197,7 +197,7 @@ namespace internal
             // active cells, you either don't specify an fe_index,
             // or that you specify the correct one
             (fe_index == cell.active_fe_index()) ||
-            (fe_index == DoFHandler<dim, spacedim>::invalid_fe_index))
+            (fe_index == numbers::invalid_fe_index))
           // simply set the values on this cell
           processor(cell, local_values, values);
         else
@@ -228,7 +228,7 @@ namespace internal
       // otherwise distribute them to the children
       {
         Assert((cell.get_dof_handler().has_hp_capabilities() == false) ||
-                 (fe_index != DoFHandler<dim, spacedim>::invalid_fe_index),
+                 (fe_index != numbers::invalid_fe_index),
                ExcMessage(
                  "You cannot call this function on non-active cells "
                  "of DoFHandler objects unless you provide an explicit "
index 12dca976a73cc30a56283ba42a9ee80020c91f7b..846a0f60c632416bf2554a193a0d595fb7e5d9b2 100644 (file)
@@ -46,10 +46,6 @@ template <int dim, int spacedim>
 const unsigned int DoFHandler<dim, spacedim>::default_fe_index;
 
 
-template <int dim, int spacedim>
-const types::fe_index DoFHandler<dim, spacedim>::invalid_active_fe_index;
-
-
 namespace internal
 {
   template <int dim, int spacedim>
@@ -2638,7 +2634,7 @@ std::vector<unsigned int>
 DoFHandler<dim, spacedim>::get_active_fe_indices() const
 {
   std::vector<unsigned int> active_fe_indices(
-    this->get_triangulation().n_active_cells(), invalid_active_fe_index);
+    this->get_triangulation().n_active_cells(), numbers::invalid_fe_index);
 
   // we could try to extract the values directly, since they are
   // stored as protected data of this object, but for simplicity we
@@ -2678,7 +2674,8 @@ DoFHandler<dim, spacedim>::set_future_fe_indices(
   // tests which we would have to duplicate ourselves otherwise
   for (const auto &cell : this->active_cell_iterators())
     if (cell->is_locally_owned() &&
-        future_fe_indices[cell->active_cell_index()] != invalid_active_fe_index)
+        future_fe_indices[cell->active_cell_index()] !=
+          numbers::invalid_fe_index)
       cell->set_future_fe_index(future_fe_indices[cell->active_cell_index()]);
 }
 
@@ -2689,7 +2686,7 @@ std::vector<unsigned int>
 DoFHandler<dim, spacedim>::get_future_fe_indices() const
 {
   std::vector<unsigned int> future_fe_indices(
-    this->get_triangulation().n_active_cells(), invalid_active_fe_index);
+    this->get_triangulation().n_active_cells(), numbers::invalid_fe_index);
 
   // we could try to extract the values directly, since they are
   // stored as protected data of this object, but for simplicity we
@@ -2820,7 +2817,7 @@ DoFHandler<dim, spacedim>::create_active_fe_table()
           this->hp_cell_active_fe_indices[level].resize(
             this->tria->n_raw_cells(level), 0);
           this->hp_cell_future_fe_indices[level].resize(
-            this->tria->n_raw_cells(level), invalid_active_fe_index);
+            this->tria->n_raw_cells(level), numbers::invalid_fe_index);
         }
       else
         {
@@ -2879,7 +2876,7 @@ DoFHandler<dim, spacedim>::update_active_fe_table()
       // We have used future FE indices to update all active FE indices
       // before refinement happened, thus we are safe to clear them now.
       this->hp_cell_future_fe_indices[i].assign(this->tria->n_raw_cells(i),
-                                                invalid_active_fe_index);
+                                                numbers::invalid_fe_index);
     }
 }
 
index c840c63da2aca7fdfed0d0fd87a2560115e640a7..dfee75622aabb0baaa9ab340744b331d9bcb4f1c 100644 (file)
@@ -72,6 +72,11 @@ namespace hp
            ExcMessage("All elements inside a collection need to have the "
                       "same number of vector components!"));
 
+    Assert(this->size() <= std::numeric_limits<types::fe_index>::max() &&
+             this->size() != numbers::invalid_fe_index,
+           ExcMessage(
+             "You reached the maximum possible number of finite elements."));
+
     Collection<FiniteElement<dim, spacedim>>::push_back(new_fe.clone());
   }
 

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.