/**
* 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();
/**
* 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);
* 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);
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"
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);
}
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();
}
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();
}
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();
}