static const unsigned int default_fe_index = numbers::invalid_unsigned_int;
+ /**
+ * Default Constructor.
+ */
+ DoFHandler ();
+
/**
* Constructor. Take @p tria as the triangulation to work on.
*/
*/
DoFHandler &operator = (const DoFHandler &) = delete;
+ /**
+ * Assign a Triangulation and a FECollection to the DoFHandler and compute
+ * the distribution of degrees of freedom over the mesh.
+ */
+ void initialize(const Triangulation<dim,spacedim> &tria,
+ const hp::FECollection<dim,spacedim> &fe);
+
/**
* Go through the triangulation and "distribute" the degrees of
* freedoms needed for the given finite element. "Distributing"
std::unique_ptr<dealii::internal::DoFHandlerImplementation::Policy::PolicyBase<dim,spacedim> > policy;
+ /**
+ * Setup policy and listeners based on the underlying Triangulation.
+ */
+ void setup_policy_and_listeners ();
+
/**
* Free all used memory.
*/
+ template <int dim, int spacedim>
+ DoFHandler<dim,spacedim>::DoFHandler ()
+ :
+ tria(nullptr, typeid(*this).name()),
+ faces (nullptr)
+ {}
+
+
template <int dim, int spacedim>
DoFHandler<dim,spacedim>::DoFHandler (const Triangulation<dim,spacedim> &tria)
:
tria(&tria, typeid(*this).name()),
faces (nullptr)
{
- // decide whether we need a sequential or a parallel shared/distributed policy
- if (dynamic_cast<const parallel::shared::Triangulation< dim, spacedim>*> (&*this->tria) != nullptr)
- policy = std_cxx14::make_unique<internal::DoFHandlerImplementation::Policy::ParallelShared<DoFHandler<dim,spacedim> >> (*this);
- else if (dynamic_cast<const parallel::distributed::Triangulation< dim, spacedim >*> (&*this->tria) != nullptr)
- policy = std_cxx14::make_unique<internal::DoFHandlerImplementation::Policy::ParallelDistributed<DoFHandler<dim,spacedim> >> (*this);
- else
- policy = std_cxx14::make_unique<internal::DoFHandlerImplementation::Policy::Sequential<DoFHandler<dim,spacedim> >> (*this);
+ setup_policy_and_listeners ();
create_active_fe_table ();
-
- tria_listeners.push_back
- (tria.signals.pre_refinement
- .connect (std::bind (&DoFHandler<dim,spacedim>::pre_refinement_action,
- std::ref(*this))));
- tria_listeners.push_back
- (tria.signals.post_refinement
- .connect (std::bind (&DoFHandler<dim,spacedim>::post_refinement_action,
- std::ref(*this))));
- tria_listeners.push_back
- (tria.signals.create
- .connect (std::bind (&DoFHandler<dim,spacedim>::post_refinement_action,
- std::ref(*this))));
}
active_fe_indices[i] = cell->active_fe_index();
}
+ template <int dim, int spacedim>
+ void DoFHandler<dim,spacedim>::initialize(const Triangulation<dim,spacedim> &tria,
+ const hp::FECollection<dim,spacedim> &fe)
+ {
+ if (this->tria != &tria)
+ {
+ for (unsigned int i=0; i<tria_listeners.size(); ++i)
+ tria_listeners[i].disconnect ();
+ tria_listeners.clear ();
+
+ this->tria = &tria;
+
+ setup_policy_and_listeners ();
+ }
+
+ create_active_fe_table ();
+
+ distribute_dofs (fe);
+ }
template <int dim, int spacedim>
}
+ template <int dim, int spacedim>
+ void DoFHandler<dim,spacedim>::setup_policy_and_listeners ()
+ {
+ // decide whether we need a sequential or a parallel shared/distributed policy
+ if (dynamic_cast<const parallel::shared::Triangulation< dim, spacedim>*> (&*this->tria) != nullptr)
+ policy = std_cxx14::make_unique<internal::DoFHandlerImplementation::Policy::ParallelShared<DoFHandler<dim,spacedim> >> (*this);
+ else if (dynamic_cast<const parallel::distributed::Triangulation< dim, spacedim >*> (&*this->tria) != nullptr)
+ policy = std_cxx14::make_unique<internal::DoFHandlerImplementation::Policy::ParallelDistributed<DoFHandler<dim,spacedim> >> (*this);
+ else
+ policy = std_cxx14::make_unique<internal::DoFHandlerImplementation::Policy::Sequential<DoFHandler<dim,spacedim> >> (*this);
+
+ tria_listeners.push_back
+ (this->tria->signals.pre_refinement
+ .connect (std::bind (&DoFHandler<dim,spacedim>::pre_refinement_action,
+ std::ref(*this))));
+ tria_listeners.push_back
+ (this->tria->signals.post_refinement
+ .connect (std::bind (&DoFHandler<dim,spacedim>::post_refinement_action,
+ std::ref(*this))));
+ tria_listeners.push_back
+ (this->tria->signals.create
+ .connect (std::bind (&DoFHandler<dim,spacedim>::post_refinement_action,
+ std::ref(*this))));
+ }
+
template <int dim, int spacedim>
void DoFHandler<dim,spacedim>::clear ()