]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Do not copy RefinementListeners by default. Instead, introduce new function Refinemen...
authorleicht <leicht@0785d39b-7218-0410-832d-ea1e28bc413d>
Tue, 5 Jun 2007 07:52:44 +0000 (07:52 +0000)
committerleicht <leicht@0785d39b-7218-0410-832d-ea1e28bc413d>
Tue, 5 Jun 2007 07:52:44 +0000 (07:52 +0000)
git-svn-id: https://svn.dealii.org/trunk@14752 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/deal.II/include/grid/tria.h
deal.II/deal.II/source/grid/tria.cc
deal.II/doc/news/changes.html

index b98c15cd1b796020bab30b69e52d681c7f9382fa..564f0394fff8642f2dcff43ad5ee90886dc2d067 100644 (file)
@@ -1291,6 +1291,25 @@ class Triangulation : public Subscriptor
         virtual
         void
         post_refinement_notification (const Triangulation<dim> &tria);
+
+                                         /**
+                                          * At the end of a call to
+                                          * copy_triangulation() the
+                                          * Triangulation class calls this
+                                          * method on all objects derived from
+                                          * this class and registered with the
+                                          * original Triangulation @p old_tria
+                                          * so that they might subscribe to the
+                                          * copied one @p new_tria as well, if
+                                          * that is desired. By default this
+                                          * method does nothing, a different
+                                          * behavior has to be implemented in
+                                          * derived classes.
+                                          */
+        virtual
+        void
+        copy_notification (const Triangulation<dim> &old_tria,
+                          const Triangulation<dim> &new_tria);
     };
     
                                     /**
@@ -1470,6 +1489,16 @@ class Triangulation : public Subscriptor
                                      *  disable or extend the
                                      *  functionality of this
                                      *  function.
+                                     *
+                                     *  Note, that the list of
+                                     *  RefinementListeners is not
+                                     *  copied. However, each
+                                     *  RefinementListener is notified of the
+                                     *  copy operation through the
+                                     *  RefinementListener::copy_notification()
+                                     *  function, so it might subscribe to the
+                                     *  new Triangulation as well, if that is
+                                     *  desired.
                                      */
     virtual void copy_triangulation (const Triangulation<dim> &old_tria);
 
index 4d8e5a6377fe1b9978a5a129d3bbd8e950180e2d..bff40d2c2d44e3c7b5040b3ac1339af7c9a5867c 100644 (file)
@@ -243,9 +243,6 @@ void Triangulation<dim>::copy_triangulation (const Triangulation<dim> &old_tria)
   vertices      = old_tria.vertices;
   vertices_used = old_tria.vertices_used;
   smooth_grid   = old_tria.smooth_grid;
-                                  // do a shallow copy of the list of
-                                  // RefinementListeners
-  refinement_listeners = old_tria.refinement_listeners;
   
   faces         = new internal::Triangulation::TriaFaces<dim>(*old_tria.faces);
 
@@ -258,6 +255,14 @@ void Triangulation<dim>::copy_triangulation (const Triangulation<dim> &old_tria)
 
   number_cache = old_tria.number_cache;
   
+                                  // inform RefinementListeners of old_tria of
+                                  // the copy operation
+  typename std::list<RefinementListener *>::iterator ref_listener =
+    old_tria.refinement_listeners.begin (),
+    end_listener = old_tria.refinement_listeners.end ();
+  for (; ref_listener != end_listener; ++ref_listener)
+    (*ref_listener)->copy_notification (old_tria, *this);
+  
                                   // note that we need not copy the
                                   // subscriptor!
 }
@@ -9920,6 +9925,14 @@ RefinementListener::post_refinement_notification (const Triangulation<dim> &)
 
 
 
+template<int dim>
+void Triangulation<dim>::
+RefinementListener::copy_notification (const Triangulation<dim> &,
+                                      const Triangulation<dim> &)
+{}
+
+
+
 template<int dim>
 void
 Triangulation<dim>::add_refinement_listener (RefinementListener &listener) const
index b1d73c0bbf90551f3c9d54857c08183bd3666f11..e38a0acc2a4afb7e186ef212129114572e4ec2ac 100644 (file)
@@ -1033,6 +1033,18 @@ inconvenience this causes.
 <h3>deal.II</h3>
 
 <ol>
+   <li> <p>Extended: the function
+       <code>Triangulation::copy_triangulation</code> 
+       copies all members of a triangulation except for the list of
+       <code>RefinementListener</code>s. In most cases this is exactly the
+       intended behavior. However, if a RefinementListener should be copied to
+       the new triangulation, e.g. if a Persistent Triangulation is created from
+       an ordinary one, it can do so now through implementing the new
+       function <code>RefinementListener::copy_notification</code>.
+       <br>
+       (Tobias Leicht 2007/06/05)
+       </p>
+
    <li> <p>New: the function
        <code>DoFTools::make_sparsity_pattern</code> 
        now takes an optional constraint matrix argument that can be used to

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.