From: wolf Date: Wed, 25 Nov 1998 13:18:27 +0000 (+0000) Subject: Implement a method to free the memory used by the DoFHandler object and to release... X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7c086c33e082b8c0e4f8510126388442e9725ecb;p=dealii-svn.git Implement a method to free the memory used by the DoFHandler object and to release the lock to the FiniteElement object. git-svn-id: https://svn.dealii.org/trunk@670 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/deal.II/include/dofs/dof_handler.h b/deal.II/deal.II/include/dofs/dof_handler.h index 3ed6858986..66d10cbcdc 100644 --- a/deal.II/deal.II/include/dofs/dof_handler.h +++ b/deal.II/deal.II/include/dofs/dof_handler.h @@ -490,8 +490,15 @@ class DoFHandler : public DoFDimensionInfo { * according to the given distribution * method. * - * A copy of the transferred finite - * element is stored. + * A pointer of the transferred finite + * element is stored. Therefore, the + * lifetime of the finite element object + * shall be longer than that of this + * object. If you don't want this + * behaviour, you may want to call + * the #clear# member function which also + * releases the lock of this object to the + * finite element. * * This function uses the user flags of the * triangulation object, so make sure you @@ -500,6 +507,14 @@ class DoFHandler : public DoFDimensionInfo { */ virtual void distribute_dofs (const FiniteElement &); + /** + * Clear all data of this object and + * especially delete the lock this object + * has to the finite element used the last + * time when #distribute_dofs# was called. + */ + virtual void clear (); + /** * Renumber the degrees of freedom according * to the given scheme, eventually using @@ -1338,6 +1353,11 @@ class DoFHandler : public DoFDimensionInfo { */ void reserve_space (); + /** + * Free all used memory. + */ + void clear_space (); + /** * Distribute dofs on the given cell, * with new dofs starting with index diff --git a/deal.II/deal.II/source/dofs/dof_handler.cc b/deal.II/deal.II/source/dofs/dof_handler.cc index 5a79b35868..fa5a5a71be 100644 --- a/deal.II/deal.II/source/dofs/dof_handler.cc +++ b/deal.II/deal.II/source/dofs/dof_handler.cc @@ -909,6 +909,18 @@ void DoFHandler::distribute_dofs (const FiniteElement &ff) { +template +void DoFHandler::clear () { + // release lock to old fe + selected_fe = 0; + + // release memory + clear_space (); +}; + + + + #if deal_II_dimension == 1 template <> @@ -1966,10 +1978,8 @@ void DoFHandler<1>::reserve_space () { // newly, since vectors are // troublesome if you want to change // their size - for (unsigned int i=0; i(tria->vertices.size()* selected_fe->dofs_per_vertex, -1); @@ -1984,6 +1994,7 @@ void DoFHandler<1>::reserve_space () { }; }; + #endif @@ -1998,10 +2009,8 @@ void DoFHandler<2>::reserve_space () { // newly, since vectors are // troublesome if you want to change // their size - for (unsigned int i=0; i(tria->vertices.size()* selected_fe->dofs_per_vertex, -1); @@ -2021,6 +2030,14 @@ void DoFHandler<2>::reserve_space () { #endif +template +void DoFHandler::clear_space () { + for (unsigned int i=0; i;