From: Wolfgang Bangerth Date: Sun, 4 Jan 2015 21:27:34 +0000 (-0600) Subject: Remove the deprecated RefinementListener approach in the Triangulation class. X-Git-Tag: v8.3.0-rc1~563^2~15 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=96e742e9e0b80b0e33d3e948b5a922a4f7dcf9ee;p=dealii.git Remove the deprecated RefinementListener approach in the Triangulation class. This method has been supplanted by the far more versatile signals approach. --- diff --git a/doc/news/changes.h b/doc/news/changes.h index 9a962faa56..cc4cbc701c 100644 --- a/doc/news/changes.h +++ b/doc/news/changes.h @@ -92,6 +92,10 @@ inconvenience this causes. +- The refinement listener concept of the Triangulation class. This + approach to getting notified about what happens to triangulations + has been superseded by the signals defined by the triangulation + class. diff --git a/include/deal.II/grid/tria.h b/include/deal.II/grid/tria.h index ad344e9d73..22d249d7a1 100644 --- a/include/deal.II/grid/tria.h +++ b/include/deal.II/grid/tria.h @@ -1431,99 +1431,6 @@ public: typedef typename IteratorSelector::hex_iterator hex_iterator; typedef typename IteratorSelector::active_hex_iterator active_hex_iterator; - - /** - * Base class for refinement listeners. Other classes, which need to be - * informed about refinements of the Triangulation, can be derived from - * RefinementListener. - * - * @note The use of this class has been superseded by the signals mechanism. - * See the general documentation of the Triangulation class for more - * information. - * - * @deprecated - */ - class RefinementListener - { - public: - /** - * Destructor. Does nothing, but is declared virtual because this class - * also has virtual functions. - * - * @note The use of this class has been superseded by the signals - * mechanism. See the general documentation of the Triangulation class for - * more information. - * - * @deprecated - */ - virtual ~RefinementListener (); - - /** - * Before refinement is actually performed, the triangulation class calls - * this method on all objects derived from this class and registered with - * the triangulation. - * - * @note The use of this class has been superseded by the signals - * mechanism. See the general documentation of the Triangulation class for - * more information. - * - * @deprecated - */ - virtual - void - pre_refinement_notification (const Triangulation &tria); - - /** - * After refinement is actually performed, the triangulation class calls - * this method on all objects derived from this class and registered with - * the triangulation. - * - * @note The use of this class has been superseded by the signals - * mechanism. See the general documentation of the Triangulation class for - * more information. - * - * @deprecated - */ - 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. - * - * @note The use of this class has been superseded by the signals - * mechanism. See the general documentation of the Triangulation class for - * more information. - * - * @deprecated - */ - virtual - void - copy_notification (const Triangulation &old_tria, - const Triangulation &new_tria); - - /** - * At the end of a call to create_triangulation() the Triangulation class - * calls this method on all objects derived from this class and registered - * with the current Triangulation object. By default this method does - * nothing, a different behavior has to be implemented in derived classes. - * - * @note The use of this class has been superseded by the signals - * mechanism. See the general documentation of the Triangulation class for - * more information. - * - * @deprecated - */ - virtual - void - create_notification (const Triangulation &tria); - }; - /** * A structure that is used as an exception object by the * create_triangulation() function to indicate which cells among the coarse @@ -1982,31 +1889,6 @@ public: * @{ */ - /** - * Add a RefinementListener. Adding listeners to the Triangulation allows - * other classes to be informed when the Triangulation is refined. - * - * @note The use of this function has been superseded by the signals - * mechanism. See the general documentation of the Triangulation class for - * more information. - * - * @deprecated - */ - void add_refinement_listener (RefinementListener &listener) const DEAL_II_DEPRECATED; - - /** - * Remove a RefinementListener. When some class needs no longer to be - * informed about refinements, the listener should be removed from the - * Triangulation. - * - * @note The use of this function has been superseded by the signals - * mechanism. See the general documentation of the Triangulation class for - * more information. - * - * @deprecated - */ - void remove_refinement_listener (RefinementListener &listener) const DEAL_II_DEPRECATED; - /** * A structure that has boost::signal objects for a number of actions that a * triangulation can do to itself. See the general documentation of the @@ -3252,24 +3134,7 @@ private: */ std::map *vertex_to_manifold_id_map_1d; - - /** - * A map that correlates each refinement listener that has been added - * through the outdated RefinementListener interface via - * add_refinement_listener(), with the new-style boost::signal connections - * for each of the member function. We need to keep this list around so that - * we can later terminate the connection again when someone calls - * remove_refinement_listener(). - * - * The data type is a multimap since, although this would be weird, the same - * object may add itself multiple times as a listener. - */ - mutable - std::multimap > - refinement_listener_map; - - // make a couple of classes - // friends + // make a couple of classes friends template friend class TriaAccessorBase; template friend class TriaAccessor; friend class TriaAccessor<0, 1, spacedim>; diff --git a/source/grid/tria.cc b/source/grid/tria.cc index 107b65eab2..de79df8f7a 100644 --- a/source/grid/tria.cc +++ b/source/grid/tria.cc @@ -12997,12 +12997,6 @@ Triangulation::memory_consumption () const -template -Triangulation::RefinementListener::~RefinementListener () -{} - - - template Triangulation::DistortedCellList::~DistortedCellList () throw () { @@ -13012,93 +13006,6 @@ Triangulation::DistortedCellList::~DistortedCellList () throw () } - - -template -void Triangulation:: -RefinementListener::pre_refinement_notification (const Triangulation &) -{} - - - -template -void Triangulation:: -RefinementListener::post_refinement_notification (const Triangulation &) -{} - - - -template -void Triangulation:: -RefinementListener::copy_notification (const Triangulation &, - const Triangulation &) -{} - - - -template -void Triangulation:: -RefinementListener::create_notification (const Triangulation &) -{} - - - -template -void -Triangulation::add_refinement_listener (RefinementListener &listener) const -{ - // in this compatibility mode with the old-style refinement - // listeners, an external class presents itself as one that may or - // may not have overloaded all of the functions that the - // RefinementListener class has. consequently, we need to connect - // each of its functions to the relevant signals. for those - // functions that haven't been overloaded, that means that - // triggering the signal yields a call to the function in the - // RefinementListener base class which simply does nothing - std::vector connections; - - connections.push_back - (signals.create.connect (std_cxx11::bind (&RefinementListener::create_notification, - std_cxx11::ref(listener), - std_cxx11::cref(*this)))); - connections.push_back - (signals.copy.connect (std_cxx11::bind (&RefinementListener::copy_notification, - std_cxx11::ref(listener), - std_cxx11::cref(*this), - std_cxx11::_1))); - connections.push_back - (signals.pre_refinement.connect (std_cxx11::bind (&RefinementListener::pre_refinement_notification, - std_cxx11::ref(listener), - std_cxx11::cref(*this)))); - connections.push_back - (signals.post_refinement.connect (std_cxx11::bind (&RefinementListener::post_refinement_notification, - std_cxx11::ref(listener), - std_cxx11::cref(*this)))); - - // now push the set of connections into the map - refinement_listener_map.insert (std::make_pair(&listener, connections)); -} - - - -template -void -Triangulation::remove_refinement_listener (RefinementListener &listener) const -{ - Assert (refinement_listener_map.find (&listener) != refinement_listener_map.end(), - ExcMessage("You try to remove a refinement listener that does " - "not appear to have been added previously.")); - - // get the element of the map, and terminate these connections. then - // erase the element from the list - std::vector connections - = refinement_listener_map.find(&listener)->second; - for (unsigned int i=0; i const Manifold<2,1> &Triangulation<2, 1>::get_manifold(const types::manifold_id) const { diff --git a/tests/deal.II/refinement_listener_01.cc b/tests/deal.II/refinement_listener_01.cc deleted file mode 100644 index 7d268c727f..0000000000 --- a/tests/deal.II/refinement_listener_01.cc +++ /dev/null @@ -1,123 +0,0 @@ -// --------------------------------------------------------------------- -// -// Copyright (C) 2006 - 2013 by the deal.II authors -// -// This file is part of the deal.II library. -// -// The deal.II library is free software; you can use it, redistribute -// it, and/or modify it under the terms of the GNU Lesser General -// Public License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// The full text of the license can be found in the file LICENSE at -// the top level of the deal.II distribution. -// -// --------------------------------------------------------------------- - - - -// test the various refinement listener functions - - -#include "../tests.h" -#include -#include -#include - -#include -#include -#include - -std::ofstream logfile("output"); - - -template -class RefinementListener : - public Triangulation::RefinementListener -{ -public: - RefinementListener (const std::string &prefix) - : - prefix(prefix) - {} - - virtual - void - pre_refinement_notification (const Triangulation &tria) - { - deallog << prefix << ' ' << "Pre-refinement: " << tria.n_active_cells() << std::endl; - } - - virtual - void - post_refinement_notification (const Triangulation &tria) - { - deallog << prefix << ' ' << "Post-refinement: " << tria.n_active_cells() << std::endl; - } - - virtual - void - copy_notification (const Triangulation &old_tria, - const Triangulation &new_tria) - { - deallog << prefix << ' ' << "Copy: " - << old_tria.n_active_cells() << ' ' - << new_tria.n_active_cells() << std::endl; - } - - virtual - void - create_notification (const Triangulation &tria) - { - deallog << prefix << ' ' << "Create: " << tria.n_active_cells() << std::endl; - } - -private: - std::string prefix; -}; - - -template -void test () -{ - deallog << dim << "D" << std::endl; - - Triangulation tria_1, tria_2; - - GridGenerator::hyper_cube(tria_2); - - RefinementListener rl_1 ("tria_1"); - RefinementListener rl_2 ("tria_2"); - tria_1.add_refinement_listener (rl_1); - tria_2.add_refinement_listener (rl_2); - - // this should print the create note - GridGenerator::hyper_cube(tria_1); - - // this should print the pre- and - // post-refinement note - tria_1.refine_global (1); - - // this should print the copy note - tria_1.clear (); - tria_1.copy_triangulation (tria_2); - - // no longer print anything - tria_1.remove_refinement_listener (rl_1); - tria_1.refine_global (2); -} - - -int main () -{ - deallog << std::setprecision(2); - logfile << std::setprecision(2); - deallog.attach(logfile); - deallog.depth_console(0); - deallog.threshold_double(1.e-10); - - test<1> (); - test<2> (); - test<3> (); - - return 0; -} diff --git a/tests/deal.II/refinement_listener_01.output b/tests/deal.II/refinement_listener_01.output deleted file mode 100644 index 4a4c71d0f4..0000000000 --- a/tests/deal.II/refinement_listener_01.output +++ /dev/null @@ -1,19 +0,0 @@ - -DEAL::1D -DEAL::tria_1 Create: 1 -DEAL::tria_1 Pre-refinement: 1 -DEAL::tria_1 Post-refinement: 2 -DEAL::tria_2 Copy: 1 1 -DEAL::tria_1 Create: 1 -DEAL::2D -DEAL::tria_1 Create: 1 -DEAL::tria_1 Pre-refinement: 1 -DEAL::tria_1 Post-refinement: 4 -DEAL::tria_2 Copy: 1 1 -DEAL::tria_1 Create: 1 -DEAL::3D -DEAL::tria_1 Create: 1 -DEAL::tria_1 Pre-refinement: 1 -DEAL::tria_1 Post-refinement: 8 -DEAL::tria_2 Copy: 1 1 -DEAL::tria_1 Create: 1