From 12e271fcad3a3a0b3a183b9e982bb2a3a02a8877 Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Fri, 23 Jun 2017 09:52:20 -0600 Subject: [PATCH] Convert the final policy function. Also let the renumber_dofs() functions return the NumberCache, rather than doing so via a reference argument. No drama this time. --- include/deal.II/dofs/dof_handler_policy.h | 31 +++++++++------------- source/dofs/dof_handler.cc | 2 +- source/dofs/dof_handler_policy.cc | 32 +++++++++++------------ 3 files changed, 29 insertions(+), 36 deletions(-) diff --git a/include/deal.II/dofs/dof_handler_policy.h b/include/deal.II/dofs/dof_handler_policy.h index 375ffd04b8..8fcefd75ad 100644 --- a/include/deal.II/dofs/dof_handler_policy.h +++ b/include/deal.II/dofs/dof_handler_policy.h @@ -83,17 +83,13 @@ namespace internal distribute_mg_dofs () const = 0; /** - * Renumber degrees of freedom as specified by the first argument. The - * reference to the NumberCache of the DoFHandler object has to be - * passed in a second argument. It could then be modified to make - * DoFHandler related functions work properly when called within the - * policies classes. The updated NumberCache is written to that - * argument. + * Renumber degrees of freedom as specified by the first argument. + * + * Return an updated NumberCache for the DoFHandler after renumbering. */ virtual - void - renumber_dofs (const std::vector &new_numbers, - NumberCache &number_cache) const = 0; + NumberCache + renumber_dofs (const std::vector &new_numbers) const = 0; }; @@ -124,9 +120,8 @@ namespace internal // documentation is inherited virtual - void - renumber_dofs (const std::vector &new_numbers, - NumberCache &number_cache) const; + NumberCache + renumber_dofs (const std::vector &new_numbers) const; protected: /** @@ -175,13 +170,12 @@ namespace internal * The input argument @p new_numbers may either have as many entries * as there are global degrees of freedom (i.e. dof_handler.n_dofs() ) * or dof_handler.locally_owned_dofs().n_elements(). Therefore it can - * be utilised with renumbering functions implemented for the + * be utilized with renumbering functions implemented for the * parallel::distributed case. */ virtual - void - renumber_dofs (const std::vector &new_numbers, - NumberCache &number_cache) const; + NumberCache + renumber_dofs (const std::vector &new_numbers) const; }; @@ -212,9 +206,8 @@ namespace internal // documentation is inherited virtual - void - renumber_dofs (const std::vector &new_numbers, - NumberCache &number_cache) const; + NumberCache + renumber_dofs (const std::vector &new_numbers) const; private: /** diff --git a/source/dofs/dof_handler.cc b/source/dofs/dof_handler.cc index 18be6f1882..3cce7dc7b1 100644 --- a/source/dofs/dof_handler.cc +++ b/source/dofs/dof_handler.cc @@ -1215,7 +1215,7 @@ DoFHandler::renumber_dofs (const std::vectorrenumber_dofs (new_numbers, number_cache); + number_cache = policy->renumber_dofs (new_numbers); } diff --git a/source/dofs/dof_handler_policy.cc b/source/dofs/dof_handler_policy.cc index 17a074f515..52cbae372e 100644 --- a/source/dofs/dof_handler_policy.cc +++ b/source/dofs/dof_handler_policy.cc @@ -995,10 +995,9 @@ namespace internal template - void + NumberCache Sequential:: - renumber_dofs (const std::vector &new_numbers, - NumberCache &number_cache_current) const + renumber_dofs (const std::vector &new_numbers) const { Implementation::renumber_dofs (new_numbers, IndexSet(0), *dof_handler, true); @@ -1022,7 +1021,7 @@ namespace internal number_cache.locally_owned_dofs_per_processor = std::vector (1, number_cache.locally_owned_dofs); - number_cache_current = std::move(number_cache); + return number_cache; } @@ -1195,7 +1194,7 @@ namespace internal // version of the function because we do things on all // cells and all cells have their subdomain ids and DoFs // correctly set - this->Sequential::renumber_dofs (new_dof_indices, number_cache); + number_cache = this->Sequential::renumber_dofs (new_dof_indices); // update the number cache. for this, we first have to find the subdomain @@ -1296,16 +1295,15 @@ namespace internal template - void + NumberCache ParallelShared:: - renumber_dofs (const std::vector &new_numbers, - NumberCache &number_cache) const + renumber_dofs (const std::vector &new_numbers) const { #ifndef DEAL_II_WITH_MPI (void)new_numbers; - (void)number_cache; Assert (false, ExcNotImplemented()); + return NumberCache(); #else // Similar to distribute_dofs() we need to have a special treatment in // case artificial cells are present. @@ -1387,8 +1385,8 @@ namespace internal std::vector flag_2 (this->dof_handler->n_dofs (), 0); for (unsigned int i = 0; i < n_cpu; i++) { - const IndexSet &iset = - number_cache.locally_owned_dofs_per_processor[i]; + const IndexSet iset = + this->dof_handler->locally_owned_dofs_per_processor()[i]; for (types::global_dof_index ind = 0; ind < iset.n_elements (); ind++) { @@ -1413,7 +1411,8 @@ namespace internal ExcInternalError()); } - this->Sequential::renumber_dofs (global_gathered_numbers, number_cache); + NumberCache number_cache + = this->Sequential::renumber_dofs (global_gathered_numbers); // correct number_cache: number_cache.locally_owned_dofs_per_processor = DoFTools::locally_owned_dofs_per_subdomain (*this->dof_handler); @@ -1434,6 +1433,8 @@ namespace internal if (tr->with_artificial_cells()) for (unsigned int index=0; cell != endc; cell++, index++) cell->set_subdomain_id(current_subdomain_ids[index]); + + return number_cache; #endif } @@ -2751,10 +2752,9 @@ namespace internal template - void + NumberCache ParallelDistributed:: - renumber_dofs (const std::vector &new_numbers, - NumberCache &number_cache_current) const + renumber_dofs (const std::vector &new_numbers) const { (void)new_numbers; @@ -2983,7 +2983,7 @@ namespace internal } #endif - number_cache_current = std::move(number_cache); + return number_cache; } } } -- 2.39.5