]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Implement a method to free the memory used by the DoFHandler object and to release...
authorwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Wed, 25 Nov 1998 13:18:27 +0000 (13:18 +0000)
committerwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Wed, 25 Nov 1998 13:18:27 +0000 (13:18 +0000)
git-svn-id: https://svn.dealii.org/trunk@670 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/deal.II/include/dofs/dof_handler.h
deal.II/deal.II/source/dofs/dof_handler.cc

index 3ed68589866d75d1eb201b425115fd8823d9b56e..66d10cbcdca963c7bf055242d701d84146a29ac5 100644 (file)
@@ -490,8 +490,15 @@ class DoFHandler : public DoFDimensionInfo<dim> {
                                      * 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<dim> {
                                      */
     virtual void distribute_dofs (const FiniteElement<dim> &);
 
+                                    /**
+                                     * 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<dim> {
                                      */
     void reserve_space ();
 
+                                    /**
+                                     * Free all used memory.
+                                     */
+    void clear_space ();
+    
                                     /**
                                      * Distribute dofs on the given cell,
                                      * with new dofs starting with index
index 5a79b3586887caf8b4198bac1110235fe3568a1a..fa5a5a71be65feb23a1bb5f0aa029a2f5219e0cc 100644 (file)
@@ -909,6 +909,18 @@ void DoFHandler<dim>::distribute_dofs (const FiniteElement<dim> &ff) {
 
 
 
+template <int dim>
+void DoFHandler<dim>::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<levels.size(); ++i)
-    delete levels[i];
-  levels.resize (0);
-
+  clear_space ();
+  
   vertex_dofs = vector<int>(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<levels.size(); ++i)
-    delete levels[i];
-  levels.resize (0);
-
+  clear_space ();
+  
   vertex_dofs = vector<int>(tria->vertices.size()*
                            selected_fe->dofs_per_vertex,
                            -1);
@@ -2021,6 +2030,14 @@ void DoFHandler<2>::reserve_space () {
 #endif
 
 
+template <int dim>
+void DoFHandler<dim>::clear_space () {  
+  for (unsigned int i=0; i<levels.size(); ++i)
+    delete levels[i];
+  levels.resize (0);
+};
+
+
 
 /*-------------- Explicit Instantiations -------------------------------*/
 template class DoFHandler<deal_II_dimension>;

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.