From: Ce Qin Date: Wed, 18 Apr 2018 13:22:08 +0000 (+0800) Subject: Add default constructor for hp::DoFHandler. X-Git-Tag: v9.0.0-rc1~156^2~1 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=86b5c9a80946481a1b4969e0c496d7761006842b;p=dealii.git Add default constructor for hp::DoFHandler. --- diff --git a/include/deal.II/hp/dof_handler.h b/include/deal.II/hp/dof_handler.h index 5545ef6501..fd9547d766 100644 --- a/include/deal.II/hp/dof_handler.h +++ b/include/deal.II/hp/dof_handler.h @@ -253,6 +253,11 @@ namespace hp static const unsigned int default_fe_index = numbers::invalid_unsigned_int; + /** + * Default Constructor. + */ + DoFHandler (); + /** * Constructor. Take @p tria as the triangulation to work on. */ @@ -279,6 +284,13 @@ namespace hp */ 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 &tria, + const hp::FECollection &fe); + /** * Go through the triangulation and "distribute" the degrees of * freedoms needed for the given finite element. "Distributing" @@ -836,6 +848,11 @@ namespace hp std::unique_ptr > policy; + /** + * Setup policy and listeners based on the underlying Triangulation. + */ + void setup_policy_and_listeners (); + /** * Free all used memory. */ diff --git a/source/hp/dof_handler.cc b/source/hp/dof_handler.cc index a8bf50e9ed..bb8f2ec2f2 100644 --- a/source/hp/dof_handler.cc +++ b/source/hp/dof_handler.cc @@ -959,34 +959,23 @@ namespace hp + template + DoFHandler::DoFHandler () + : + tria(nullptr, typeid(*this).name()), + faces (nullptr) + {} + + template DoFHandler::DoFHandler (const Triangulation &tria) : tria(&tria, typeid(*this).name()), faces (nullptr) { - // decide whether we need a sequential or a parallel shared/distributed policy - if (dynamic_cast*> (&*this->tria) != nullptr) - policy = std_cxx14::make_unique >> (*this); - else if (dynamic_cast*> (&*this->tria) != nullptr) - policy = std_cxx14::make_unique >> (*this); - else - policy = std_cxx14::make_unique >> (*this); + setup_policy_and_listeners (); create_active_fe_table (); - - tria_listeners.push_back - (tria.signals.pre_refinement - .connect (std::bind (&DoFHandler::pre_refinement_action, - std::ref(*this)))); - tria_listeners.push_back - (tria.signals.post_refinement - .connect (std::bind (&DoFHandler::post_refinement_action, - std::ref(*this)))); - tria_listeners.push_back - (tria.signals.create - .connect (std::bind (&DoFHandler::post_refinement_action, - std::ref(*this)))); } @@ -1269,6 +1258,25 @@ namespace hp active_fe_indices[i] = cell->active_fe_index(); } + template + void DoFHandler::initialize(const Triangulation &tria, + const hp::FECollection &fe) + { + if (this->tria != &tria) + { + for (unsigned int i=0; itria = &tria; + + setup_policy_and_listeners (); + } + + create_active_fe_table (); + + distribute_dofs (fe); + } template @@ -1372,6 +1380,31 @@ namespace hp } + template + void DoFHandler::setup_policy_and_listeners () + { + // decide whether we need a sequential or a parallel shared/distributed policy + if (dynamic_cast*> (&*this->tria) != nullptr) + policy = std_cxx14::make_unique >> (*this); + else if (dynamic_cast*> (&*this->tria) != nullptr) + policy = std_cxx14::make_unique >> (*this); + else + policy = std_cxx14::make_unique >> (*this); + + tria_listeners.push_back + (this->tria->signals.pre_refinement + .connect (std::bind (&DoFHandler::pre_refinement_action, + std::ref(*this)))); + tria_listeners.push_back + (this->tria->signals.post_refinement + .connect (std::bind (&DoFHandler::post_refinement_action, + std::ref(*this)))); + tria_listeners.push_back + (this->tria->signals.create + .connect (std::bind (&DoFHandler::post_refinement_action, + std::ref(*this)))); + } + template void DoFHandler::clear ()