virtual void distribute_dofs (const FiniteElement<dim> &,
const unsigned int offset = 0);
+ /**
+ * Clear all data of this object
+ * and call the respective
+ * function of the base class.
+ */
+ virtual void clear ();
+
/**
* Actually do the renumbering based on
* a list of new dof numbers for all the
};
-/**
- * Distribute dofs on the given cell,
- * with new dofs starting with index
- * @p{next_free_dof}. Return the next
- * unused index number. The finite
- * element used is the one given to
- * @p{distribute_dofs}, which is copied
- * to @p{selected_fe}.
- *
- * This function is excluded from the
- * @p{distribute_dofs} function since
- * it can not be implemented dimension
- * independent.
- *
- * Note that unlike for the usual dofs,
- * here all cells and not only active
- * ones are allowed.
- */
+ /**
+ * Distribute dofs on the given
+ * cell, with new dofs starting
+ * with index
+ * @p{next_free_dof}. Return the
+ * next unused index number. The
+ * finite element used is the one
+ * given to @p{distribute_dofs},
+ * which is copied to
+ * @p{selected_fe}.
+ *
+ * This function is excluded from
+ * the @p{distribute_dofs}
+ * function since it can not be
+ * implemented dimension
+ * independent.
+ *
+ * Note that unlike for the usual
+ * dofs, here all cells and not
+ * only active ones are allowed.
+ */
unsigned int distribute_dofs_on_cell (cell_iterator &cell,
unsigned int next_free_dof);
*/
void reserve_space ();
+ /**
+ * Free all used memory.
+ */
+ void clear_space ();
+
/**
* Space to store the DoF numbers for the
* different levels. Unlike the @p{levels}
template <int dim>
-MGDoFHandler<dim>::~MGDoFHandler () {};
+MGDoFHandler<dim>::~MGDoFHandler ()
+{
+ clear ();
+};
#if deal_II_dimension == 1
DoFHandler<dim>::distribute_dofs (fe, offset);
-// reserve space for the MG dof numbers
+ // reserve space for the MG dof numbers
reserve_space ();
mg_used_dofs.resize (tria->n_levels(), 0);
#endif
+template <int dim>
+void
+MGDoFHandler<dim>::clear ()
+{
+ // release own memory
+ clear_space ();
+
+ // let base class release its mem
+ // as well
+ DoFHandler<dim>::clear ();
+};
+
+
template <int dim>
unsigned int MGDoFHandler<dim>::n_dofs (const unsigned int level) const {
Assert (level < mg_used_dofs.size(), ExcInvalidLevel(level));
//////////////////////////
// DESTRUCTION
-
- // delete all levels and set them up
- // newly, since vectors are
- // troublesome if you want to change
- // their size
- for (unsigned int i=0; i<mg_levels.size(); ++i)
- delete mg_levels[i];
- mg_levels.resize (0);
-
- // also delete vector of vertex indices
- // this calls the destructor which
- // must free the space
- mg_vertex_dofs.resize (0);
+ clear_space ();
////////////////////////////
// CONSTRUCTION
////////////////////////////
// DESTRUCTION
-
- // delete all levels and set them up
- // newly, since vectors are
- // troublesome if you want to change
- // their size
- for (unsigned int i=0; i<mg_levels.size(); ++i)
- delete mg_levels[i];
- mg_levels.clear ();
-
- // also delete vector of vertex indices
- // this calls the destructor which
- // must free the space
- mg_vertex_dofs.clear ();
-
+ clear_space ();
////////////////////////////
// CONSTRUCTION
////////////////////////////
// DESTRUCTION
-
- // delete all levels and set them up
- // newly, since vectors are
- // troublesome if you want to change
- // their size
- for (unsigned int i=0; i<mg_levels.size(); ++i)
- delete mg_levels[i];
- mg_levels.clear ();
-
- // also delete vector of vertex indices
- // this calls the destructor which
- // must free the space
- mg_vertex_dofs.clear ();
-
+ clear_space ();
////////////////////////////
// CONSTRUCTION
#endif
+template <int dim>
+void MGDoFHandler<dim>::clear_space ()
+{
+ // delete all levels and set them up
+ // newly, since vectors are
+ // troublesome if you want to change
+ // their size
+ for (unsigned int i=0; i<mg_levels.size(); ++i)
+ delete mg_levels[i];
+ mg_levels.clear ();
+
+ // also delete vector of vertex
+ // indices
+ typename std::vector<MGVertexDoFs> tmp;
+ std::swap (mg_vertex_dofs, tmp);
+};
+
+
+
// explicit instantiations
template class MGDoFHandler<deal_II_dimension>;
+