* @ingroup hp
*/
template <int dim, int spacedim=dim>
- class DoFHandler : public Subscriptor,
- protected Triangulation<dim,spacedim>::RefinementListener
+ class DoFHandler : public Subscriptor
{
typedef internal::DoFHandler::Iterators<DoFHandler<dim,spacedim> > IteratorSelector;
public:
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<dim,spacedim> &tria);
- virtual void post_refinement_notification (const Triangulation<dim,spacedim> &tria);
- virtual void create_notification (const Triangulation<dim,spacedim> &tria);
+ void pre_refinement_action ();
+ void post_refinement_action ();
/**
*/
std::vector<std::vector<bool> *> has_children;
+ /**
+ * A list of connections with which this object connects
+ * to the triangulation to get information about when the
+ * triangulation changes.
+ */
+ std::vector<boost::signals2::connection> tria_listeners;
+
/**
* Make accessor objects friends.
*/
"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<dim,spacedim>::pre_refinement_action,
+ std_cxx1x::ref(*this))));
+ tria_listeners.push_back
+ (tria.signals.post_refinement
+ .connect (std_cxx1x::bind (&DoFHandler<dim,spacedim>::post_refinement_action,
+ std_cxx1x::ref(*this))));
+ tria_listeners.push_back
+ (tria.signals.create
+ .connect (std_cxx1x::bind (&DoFHandler<dim,spacedim>::post_refinement_action,
+ std_cxx1x::ref(*this))));
}
{
// unsubscribe as a listener to refinement
// of the underlying triangulation
- tria->remove_refinement_listener (*this);
-
+ for (unsigned int i=0; i<tria_listeners.size(); ++i)
+ tria_listeners[i].disconnect ();
+ tria_listeners.clear ();
+
// ...and release allocated memory
clear ();
}
template <int dim, int spacedim>
- void DoFHandler<dim,spacedim>::pre_refinement_notification (const Triangulation<dim,spacedim> &tria)
+ void DoFHandler<dim,spacedim>::pre_refinement_action ()
{
create_active_fe_table ();
Assert (has_children.size () == 0, ExcInternalError ());
for (unsigned int i=0; i<levels.size(); ++i)
{
- const unsigned int cells_on_level = tria.n_raw_cells(i);
+ const unsigned int cells_on_level = tria->n_raw_cells(i);
std::vector<bool> *has_children_level =
new std::vector<bool> (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<unsigned char>(),
static_cast<unsigned char>(RefinementCase<dim>::no_refinement)));
template <>
- void DoFHandler<1>::pre_refinement_notification (const Triangulation<1> &tria)
+ void DoFHandler<1>::pre_refinement_action ()
{
create_active_fe_table ();
Assert (has_children.size () == 0, ExcInternalError ());
for (unsigned int i=0; i<levels.size(); ++i)
{
- const unsigned int cells_on_level = tria.n_raw_cells (i);
+ const unsigned int cells_on_level = tria->n_raw_cells (i);
std::vector<bool> *has_children_level =
new std::vector<bool> (cells_on_level);
// 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<int>(), -1));
template <>
- void DoFHandler<1,2>::pre_refinement_notification (const Triangulation<1,2> &tria)
+ void DoFHandler<1,2>::pre_refinement_action ()
{
create_active_fe_table ();
Assert (has_children.size () == 0, ExcInternalError ());
for (unsigned int i=0; i<levels.size(); ++i)
{
- const unsigned int lines_on_level = tria.n_raw_lines(i);
+ const unsigned int lines_on_level = tria->n_raw_lines(i);
std::vector<bool> *has_children_level =
new std::vector<bool> (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<int>(), -1));
template<int dim, int spacedim>
void
- DoFHandler<dim,spacedim>::
- post_refinement_notification (const Triangulation<dim,spacedim> &tria)
+ DoFHandler<dim,spacedim>::post_refinement_action ()
{
Assert (has_children.size () == levels.size (), ExcInternalError ());
// 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<dim>);
// 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 ();
// vectors. use zero indicator to
// extend
for (unsigned int i=0; i<levels.size(); ++i)
- levels[i]->active_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
}
- template<int dim, int spacedim>
- void
- DoFHandler<dim,spacedim>::
- create_notification (const Triangulation<dim,spacedim> &tria)
- {
- // do the same here as needs to be done
- // in the post_refinement hook
- post_refinement_notification (tria);
- }
-
-
-
template<int dim, int spacedim>
void DoFHandler<dim,spacedim>::clear_space ()
{