From 8c0788452c9906d1bb94bce8c605c4331a54a0e9 Mon Sep 17 00:00:00 2001 From: Marc Fehling Date: Tue, 10 Nov 2020 14:30:14 -0700 Subject: [PATCH] Avoid using deprecated DoFHandler functions in source. --- source/dofs/dof_handler.cc | 68 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 66 insertions(+), 2 deletions(-) diff --git a/source/dofs/dof_handler.cc b/source/dofs/dof_handler.cc index a57e987a64..7587c2fa12 100644 --- a/source/dofs/dof_handler.cc +++ b/source/dofs/dof_handler.cc @@ -2429,7 +2429,7 @@ DoFHandler::set_fe(const hp::FECollection &ff) Assert( this->tria != nullptr, ExcMessage( - "You need to set the Triangulation in the DoFHandler using initialize() or " + "You need to set the Triangulation in the DoFHandler using reinit() or " "in the constructor before you can distribute DoFs.")); Assert(this->tria->n_levels() > 0, ExcMessage("The Triangulation you are using is empty!")); @@ -2502,10 +2502,74 @@ void DoFHandler::distribute_dofs( const hp::FECollection &ff) { - this->set_fe(ff); + Assert( + this->tria != nullptr, + ExcMessage( + "You need to set the Triangulation in the DoFHandler using reinit() or " + "in the constructor before you can distribute DoFs.")); + Assert(this->tria->n_levels() > 0, + ExcMessage("The Triangulation you are using is empty!")); + Assert(ff.size() > 0, ExcMessage("The hp::FECollection given is empty!")); + + // register the new finite element collection + // don't create a new object if the one we have is identical + if (this->fe_collection != ff) + { + this->fe_collection = hp::FECollection(ff); + + const bool contains_multiple_fes = (this->fe_collection.size() > 1); + // disable hp-mode if only a single finite element has been registered + if (hp_capability_enabled && !contains_multiple_fes) + { + hp_capability_enabled = false; + + // unsubscribe connections to signals + for (auto &connection : this->tria_listeners) + connection.disconnect(); + this->tria_listeners.clear(); + + // release active and future finite element tables + this->hp_cell_active_fe_indices.clear(); + this->hp_cell_active_fe_indices.shrink_to_fit(); + this->hp_cell_future_fe_indices.clear(); + this->hp_cell_future_fe_indices.shrink_to_fit(); + } + + // re-enabling hp-mode is not permitted since the active and future fe + // tables are no longer available + AssertThrow( + hp_capability_enabled || !contains_multiple_fes, + ExcMessage( + "You cannot re-enable hp capabilities after you registered a single " + "finite element. Please call reinit() or create a new DoFHandler " + "object instead.")); + } + + // enumerate all degrees of freedom if (hp_capability_enabled) { + // make sure every processor knows the active_fe_indices + // on both its own cells and all ghost cells + dealii::internal::hp::DoFHandlerImplementation::Implementation:: + communicate_active_fe_indices(*this); + +#ifdef DEBUG + // make sure that the fe collection is large enough to + // cover all fe indices presently in use on the mesh + for (const auto &cell : this->active_cell_iterators()) + { + if (!cell->is_artificial()) + Assert(cell->active_fe_index() < this->fe_collection.size(), + ExcInvalidFEIndex(cell->active_fe_index(), + this->fe_collection.size())); + if (cell->is_locally_owned()) + Assert(cell->future_fe_index() < this->fe_collection.size(), + ExcInvalidFEIndex(cell->future_fe_index(), + this->fe_collection.size())); + } +#endif + object_dof_indices.resize(this->tria->n_levels()); object_dof_ptr.resize(this->tria->n_levels()); cell_dof_cache_indices.resize(this->tria->n_levels()); -- 2.39.5