From: leicht Date: Tue, 5 Jun 2007 07:52:44 +0000 (+0000) Subject: Do not copy RefinementListeners by default. Instead, introduce new function Refinemen... X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6b614ddb46733be237ee3be35fa6a8fb7c8b9609;p=dealii-svn.git Do not copy RefinementListeners by default. Instead, introduce new function RefinementListener::copy_notification(), so that each RefinementListener can decide itself, whether it wants to subscribe to the copied triangulation or not. git-svn-id: https://svn.dealii.org/trunk@14752 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/deal.II/include/grid/tria.h b/deal.II/deal.II/include/grid/tria.h index b98c15cd1b..564f0394ff 100644 --- a/deal.II/deal.II/include/grid/tria.h +++ b/deal.II/deal.II/include/grid/tria.h @@ -1291,6 +1291,25 @@ class Triangulation : public Subscriptor virtual void post_refinement_notification (const Triangulation &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 &old_tria, + const Triangulation &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 &old_tria); diff --git a/deal.II/deal.II/source/grid/tria.cc b/deal.II/deal.II/source/grid/tria.cc index 4d8e5a6377..bff40d2c2d 100644 --- a/deal.II/deal.II/source/grid/tria.cc +++ b/deal.II/deal.II/source/grid/tria.cc @@ -243,9 +243,6 @@ void Triangulation::copy_triangulation (const Triangulation &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(*old_tria.faces); @@ -258,6 +255,14 @@ void Triangulation::copy_triangulation (const Triangulation &old_tria) number_cache = old_tria.number_cache; + // inform RefinementListeners of old_tria of + // the copy operation + typename std::list::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 &) +template +void Triangulation:: +RefinementListener::copy_notification (const Triangulation &, + const Triangulation &) +{} + + + template void Triangulation::add_refinement_listener (RefinementListener &listener) const diff --git a/deal.II/doc/news/changes.html b/deal.II/doc/news/changes.html index b1d73c0bbf..e38a0acc2a 100644 --- a/deal.II/doc/news/changes.html +++ b/deal.II/doc/news/changes.html @@ -1033,6 +1033,18 @@ inconvenience this causes.

deal.II

    +
  1. Extended: the function + Triangulation::copy_triangulation + copies all members of a triangulation except for the list of + RefinementListeners. 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 RefinementListener::copy_notification. +
    + (Tobias Leicht 2007/06/05) +

    +
  2. New: the function DoFTools::make_sparsity_pattern now takes an optional constraint matrix argument that can be used to