]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Slim interface for DoFHandler initialization.
authorMarc Fehling <mafehling.git@gmail.com>
Tue, 3 Nov 2020 01:51:36 +0000 (18:51 -0700)
committerMarc Fehling <mafehling.git@gmail.com>
Tue, 17 Nov 2020 19:36:48 +0000 (12:36 -0700)
doc/news/changes/incompatibilities/20201030Fehling [new file with mode: 0644]
include/deal.II/dofs/dof_handler.h
source/dofs/dof_handler.cc

diff --git a/doc/news/changes/incompatibilities/20201030Fehling b/doc/news/changes/incompatibilities/20201030Fehling
new file mode 100644 (file)
index 0000000..b3f7651
--- /dev/null
@@ -0,0 +1,8 @@
+Deprecated: The initialization interface for the DoFHandler class has
+changed. DoFHandler::initialize() and DoFHandler::set_fe() have been
+deprecated. Instead, use the constructor DoFHandler::DoFHandler(tria) or
+DoFHandler::DoFHandler() followed by DoFHandler::reinit(tria) to attach
+a Triangulation tria, and DoFHandler::distribute_dofs() to enumerate
+degrees of freedom.
+<br>
+(Marc Fehling, 2020/10/30)
index 91228ebebc1f47dfcabebc7ad11584775ee7dd60..a535398f207f1c4ea718d9e712c1b21962705aaa 100644 (file)
@@ -542,8 +542,7 @@ public:
 
   /**
    * Standard constructor, not initializing any data. After constructing an
-   * object with this constructor, use initialize() to make a valid
-   * DoFHandler.
+   * object with this constructor, use reinit() to get a valid DoFHandler.
    */
   DoFHandler();
 
@@ -577,14 +576,20 @@ public:
   /**
    * Assign a Triangulation and a FiniteElement to the DoFHandler and compute
    * the distribution of degrees of freedom over the mesh.
+   *
+   * @deprecated Use reinit() and distribute_dofs() instead.
    */
+  DEAL_II_DEPRECATED
   void
   initialize(const Triangulation<dim, spacedim> &tria,
              const FiniteElement<dim, spacedim> &fe);
 
   /**
    * Same as above but taking an hp::FECollection object.
+   *
+   * @deprecated Use reinit() and distribute_dofs() instead.
    */
+  DEAL_II_DEPRECATED
   void
   initialize(const Triangulation<dim, spacedim> &   tria,
              const hp::FECollection<dim, spacedim> &fe);
@@ -609,13 +614,19 @@ public:
    * either not been distributed yet, or are distributed using a previously set
    * element. In both cases, accessing degrees of freedom will lead to invalid
    * results. To restore consistency, call distribute_dofs().
+   *
+   * @deprecated Use distribute_dofs() instead.
    */
+  DEAL_II_DEPRECATED
   void
   set_fe(const FiniteElement<dim, spacedim> &fe);
 
   /**
    * Same as above but taking an hp::FECollection object.
+   *
+   * @deprecated Use distribute_dofs() instead.
    */
+  DEAL_II_DEPRECATED
   void
   set_fe(const hp::FECollection<dim, spacedim> &fe);
 
@@ -634,6 +645,16 @@ public:
   void
   get_active_fe_indices(std::vector<unsigned int> &active_fe_indices) const;
 
+  /**
+   * Assign a Triangulation to the DoFHandler.
+   *
+   * Remove all associations with the previous Triangulation object and
+   * establish connections with the new one. All information about previous
+   * degrees of freedom will be removed. Activates hp-mode.
+   */
+  void
+  reinit(const Triangulation<dim, spacedim> &tria);
+
   /**
    * Go through the triangulation and "distribute" the degrees of
    * freedom needed for the given finite element. "Distributing"
index d2e755e4e182dc4ebb5a39f3eb2196a868744105..a57e987a64c4840f0cfcdd4a2f33d828dd966302 100644 (file)
@@ -2008,15 +2008,9 @@ DoFHandler<dim, spacedim>::DoFHandler()
 
 template <int dim, int spacedim>
 DoFHandler<dim, spacedim>::DoFHandler(const Triangulation<dim, spacedim> &tria)
-  : hp_capability_enabled(true)
-  , tria(&tria, typeid(*this).name())
-  , mg_faces(nullptr)
+  : DoFHandler()
 {
-  this->setup_policy();
-
-  // provide all hp functionalities before finite elements are registered
-  this->connect_to_triangulation_signals();
-  this->create_active_fe_table();
+  reinit(tria);
 }
 
 
@@ -2059,37 +2053,39 @@ void
 DoFHandler<dim, spacedim>::initialize(const Triangulation<dim, spacedim> &tria,
                                       const hp::FECollection<dim, spacedim> &fe)
 {
-  if (hp_capability_enabled)
-    {
-      this->clear();
+  this->reinit(tria);
+  this->distribute_dofs(fe);
+}
 
-      if (this->tria != &tria)
-        {
-          // remove association with old triangulation
-          for (auto &connection : this->tria_listeners)
-            connection.disconnect();
-          this->tria_listeners.clear();
-        }
-    }
-  else
-    {
-      // this->faces                      = nullptr;
-      this->number_cache.n_global_dofs = 0;
-    }
 
-  if (this->tria != &tria)
-    {
-      // establish connection to new triangulation
-      this->tria = &tria;
-      this->setup_policy();
-
-      // start in hp-mode and let distribute_dofs toggle it if necessary
-      hp_capability_enabled = true;
-      this->connect_to_triangulation_signals();
-      this->create_active_fe_table();
-    }
 
-  this->distribute_dofs(fe);
+template <int dim, int spacedim>
+void
+DoFHandler<dim, spacedim>::reinit(const Triangulation<dim, spacedim> &tria)
+{
+  //
+  // call destructor
+  //
+  // remove association with old triangulation
+  for (auto &connection : this->tria_listeners)
+    connection.disconnect();
+  this->tria_listeners.clear();
+
+  // release allocated memory and policy
+  DoFHandler<dim, spacedim>::clear();
+  this->policy.reset();
+
+  //
+  // call constructor
+  //
+  // establish connection to new triangulation
+  this->tria = &tria;
+  this->setup_policy();
+
+  // start in hp-mode and let distribute_dofs toggle it if necessary
+  hp_capability_enabled = true;
+  this->connect_to_triangulation_signals();
+  this->create_active_fe_table();
 }
 
 
@@ -2681,17 +2677,9 @@ template <int dim, int spacedim>
 void
 DoFHandler<dim, spacedim>::clear()
 {
-  if (hp_capability_enabled)
-    {
-      // release memory
-      this->clear_space();
-    }
-  else
-    {
-      // release memory
-      this->clear_space();
-      this->clear_mg_space();
-    }
+  // release memory
+  this->clear_space();
+  this->clear_mg_space();
 }
 
 
@@ -2708,17 +2696,10 @@ DoFHandler<dim, spacedim>::clear_space()
 
   object_dof_ptr.clear();
 
-  if (hp_capability_enabled)
-    {
-      this->hp_cell_active_fe_indices.clear();
-      this->hp_cell_active_fe_indices.shrink_to_fit();
-      this->hp_cell_future_fe_indices.clear();
-      this->hp_cell_future_fe_indices.shrink_to_fit();
-    }
-  else
-    {
-      this->number_cache.clear();
-    }
+  this->number_cache.clear();
+
+  this->hp_cell_active_fe_indices.clear();
+  this->hp_cell_future_fe_indices.clear();
 }
 
 

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.