From: bangerth Date: Thu, 2 Jun 2011 14:32:04 +0000 (+0000) Subject: Switch hp::DoFHandler from old-style RefinementListener to new-style signals. X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=771cad2251a97e7e9739dc8b7c64c1b08926e479;p=dealii-svn.git Switch hp::DoFHandler from old-style RefinementListener to new-style signals. git-svn-id: https://svn.dealii.org/trunk@23762 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/include/deal.II/hp/dof_handler.h b/deal.II/include/deal.II/hp/dof_handler.h index f573d229c9..c0524cd3da 100644 --- a/deal.II/include/deal.II/hp/dof_handler.h +++ b/deal.II/include/deal.II/hp/dof_handler.h @@ -74,8 +74,7 @@ namespace hp * @ingroup hp */ template - class DoFHandler : public Subscriptor, - protected Triangulation::RefinementListener + class DoFHandler : public Subscriptor { typedef internal::DoFHandler::Iterators > IteratorSelector; public: @@ -1125,17 +1124,17 @@ namespace hp void create_active_fe_table (); /** - * Methods of the - * RefinementListener coming - * from the Triangulation. - * Here they are used to + * Functions that will be triggered + * through signals whenever the + * triangulation is modified. + * + * Here they are used to * administrate the the * active_fe_fields during the * spatial refinement. */ - virtual void pre_refinement_notification (const Triangulation &tria); - virtual void post_refinement_notification (const Triangulation &tria); - virtual void create_notification (const Triangulation &tria); + void pre_refinement_action (); + void post_refinement_action (); /** @@ -1291,6 +1290,13 @@ namespace hp */ std::vector *> has_children; + /** + * A list of connections with which this object connects + * to the triangulation to get information about when the + * triangulation changes. + */ + std::vector tria_listeners; + /** * Make accessor objects friends. */ diff --git a/deal.II/source/hp/dof_handler.cc b/deal.II/source/hp/dof_handler.cc index f29f4fb1dd..c3175e6d4c 100644 --- a/deal.II/source/hp/dof_handler.cc +++ b/deal.II/source/hp/dof_handler.cc @@ -1607,7 +1607,19 @@ namespace hp "this class does not currently support this.")); create_active_fe_table (); - tria.add_refinement_listener (*this); + + tria_listeners.push_back + (tria.signals.pre_refinement + .connect (std_cxx1x::bind (&DoFHandler::pre_refinement_action, + std_cxx1x::ref(*this)))); + tria_listeners.push_back + (tria.signals.post_refinement + .connect (std_cxx1x::bind (&DoFHandler::post_refinement_action, + std_cxx1x::ref(*this)))); + tria_listeners.push_back + (tria.signals.create + .connect (std_cxx1x::bind (&DoFHandler::post_refinement_action, + std_cxx1x::ref(*this)))); } @@ -1616,8 +1628,10 @@ namespace hp { // unsubscribe as a listener to refinement // of the underlying triangulation - tria->remove_refinement_listener (*this); - + for (unsigned int i=0; i - void DoFHandler::pre_refinement_notification (const Triangulation &tria) + void DoFHandler::pre_refinement_action () { create_active_fe_table (); @@ -3905,13 +3919,13 @@ namespace hp Assert (has_children.size () == 0, ExcInternalError ()); for (unsigned int i=0; in_raw_cells(i); std::vector *has_children_level = new std::vector (cells_on_level); // Check for each cell, if it has children. - std::transform (tria.levels[i]->cells.refinement_cases.begin (), - tria.levels[i]->cells.refinement_cases.end (), + std::transform (tria->levels[i]->cells.refinement_cases.begin (), + tria->levels[i]->cells.refinement_cases.end (), has_children_level->begin (), std::bind2nd (std::not_equal_to(), static_cast(RefinementCase::no_refinement))); @@ -3923,7 +3937,7 @@ namespace hp template <> - void DoFHandler<1>::pre_refinement_notification (const Triangulation<1> &tria) + void DoFHandler<1>::pre_refinement_action () { create_active_fe_table (); @@ -3934,7 +3948,7 @@ namespace hp Assert (has_children.size () == 0, ExcInternalError ()); for (unsigned int i=0; in_raw_cells (i); std::vector *has_children_level = new std::vector (cells_on_level); @@ -3944,8 +3958,8 @@ namespace hp // 1d (as there is only one choice // anyway). use the 'children' vector // instead - std::transform (tria.levels[i]->cells.children.begin (), - tria.levels[i]->cells.children.end (), + std::transform (tria->levels[i]->cells.children.begin (), + tria->levels[i]->cells.children.end (), has_children_level->begin (), std::bind2nd (std::not_equal_to(), -1)); @@ -3956,7 +3970,7 @@ namespace hp template <> - void DoFHandler<1,2>::pre_refinement_notification (const Triangulation<1,2> &tria) + void DoFHandler<1,2>::pre_refinement_action () { create_active_fe_table (); @@ -3967,13 +3981,13 @@ namespace hp Assert (has_children.size () == 0, ExcInternalError ()); for (unsigned int i=0; in_raw_lines(i); std::vector *has_children_level = new std::vector (lines_on_level); // Check for each cell, if it has children. - std::transform (tria.levels[i]->cells.children.begin (), - tria.levels[i]->cells.children.end (), + std::transform (tria->levels[i]->cells.children.begin (), + tria->levels[i]->cells.children.end (), has_children_level->begin (), std::bind2nd (std::not_equal_to(), -1)); @@ -3985,8 +3999,7 @@ namespace hp template void - DoFHandler:: - post_refinement_notification (const Triangulation &tria) + DoFHandler::post_refinement_action () { Assert (has_children.size () == levels.size (), ExcInternalError ()); @@ -3994,12 +4007,12 @@ namespace hp // new level may appear. If that happened // it is appended to the DoFHandler // levels. - if (levels.size () < tria.n_levels ()) + if (levels.size () < tria->n_levels ()) levels.push_back (new internal::hp::DoFLevel); // Coarsening can lead to the loss // of levels. Hence remove them. - while (levels.size () > tria.n_levels ()) + while (levels.size () > tria->n_levels ()) { delete levels[levels.size ()-1]; levels.pop_back (); @@ -4009,7 +4022,7 @@ namespace hp // vectors. use zero indicator to // extend for (unsigned int i=0; iactive_fe_indices.resize (tria.n_raw_cells(i), 0); + levels[i]->active_fe_indices.resize (tria->n_raw_cells(i), 0); // if a finite element collection // has already been set, then @@ -4070,18 +4083,6 @@ namespace hp } - template - void - DoFHandler:: - create_notification (const Triangulation &tria) - { - // do the same here as needs to be done - // in the post_refinement hook - post_refinement_notification (tria); - } - - - template void DoFHandler::clear_space () {