From 154196830ce0894129b9bd0e4a2cfd1cbf5bc264 Mon Sep 17 00:00:00 2001 From: "denis.davydov" Date: Tue, 25 Mar 2014 21:13:07 +0000 Subject: [PATCH] Changed Policy methods to recieve NumberCache by reference git-svn-id: https://svn.dealii.org/branches/branch_sharedtria@32694 0785d39b-7218-0410-832d-ea1e28bc413d --- .../include/deal.II/dofs/dof_handler_policy.h | 40 ++++++++++------- deal.II/source/dofs/dof_handler.cc | 4 +- deal.II/source/dofs/dof_handler_policy.cc | 44 +++++++++---------- 3 files changed, 46 insertions(+), 42 deletions(-) diff --git a/deal.II/include/deal.II/dofs/dof_handler_policy.h b/deal.II/include/deal.II/dofs/dof_handler_policy.h index f588ba63f8..102687b0dd 100644 --- a/deal.II/include/deal.II/dofs/dof_handler_policy.h +++ b/deal.II/include/deal.II/dofs/dof_handler_policy.h @@ -70,8 +70,9 @@ namespace internal * the object given as last argument. */ virtual - NumberCache - distribute_dofs (dealii::DoFHandler &dof_handler) const = 0; + void + distribute_dofs (dealii::DoFHandler &dof_handler, + NumberCache &number_cache) const = 0; /** * Distribute the multigrid dofs on each level @@ -86,9 +87,10 @@ namespace internal * specified by the first argument. */ virtual - NumberCache + void renumber_dofs (const std::vector &new_numbers, - dealii::DoFHandler &dof_handler) const = 0; + dealii::DoFHandler &dof_handler, + NumberCache & number_cache) const = 0; }; @@ -107,8 +109,9 @@ namespace internal * the object given as last argument. */ virtual - NumberCache - distribute_dofs (dealii::DoFHandler &dof_handler) const; + void + distribute_dofs (dealii::DoFHandler &dof_handler, + NumberCache &number_cache) const; /** * Distribute multigrid DoFs. @@ -123,9 +126,10 @@ namespace internal * specified by the first argument. */ virtual - NumberCache + void renumber_dofs (const std::vector &new_numbers, - dealii::DoFHandler &dof_handler) const; + dealii::DoFHandler &dof_handler, + NumberCache & number_cache) const; }; template @@ -133,8 +137,9 @@ namespace internal { public: virtual - NumberCache - distribute_dofs (dealii::DoFHandler &dof_handler) const; + void + distribute_dofs (dealii::DoFHandler &dof_handler, + NumberCache & number_cache) const; virtual void @@ -142,9 +147,10 @@ namespace internal std::vector &number_caches) const; virtual - NumberCache + void renumber_dofs (const std::vector &new_numbers, - dealii::DoFHandler &dof_handler) const; + dealii::DoFHandler &dof_handler, + NumberCache & number_cache) const; }; @@ -164,8 +170,9 @@ namespace internal * the object given as last argument. */ virtual - NumberCache - distribute_dofs (dealii::DoFHandler &dof_handler) const; + void + distribute_dofs (dealii::DoFHandler &dof_handler, + NumberCache &number_cache) const; /** * Distribute multigrid DoFs. @@ -180,9 +187,10 @@ namespace internal * specified by the first argument. */ virtual - NumberCache + void renumber_dofs (const std::vector &new_numbers, - dealii::DoFHandler &dof_handler) const; + dealii::DoFHandler &dof_handler, + NumberCache &number_cache) const; }; } } diff --git a/deal.II/source/dofs/dof_handler.cc b/deal.II/source/dofs/dof_handler.cc index 32cd024bff..5d1bd08b21 100644 --- a/deal.II/source/dofs/dof_handler.cc +++ b/deal.II/source/dofs/dof_handler.cc @@ -1172,7 +1172,7 @@ void DoFHandler::distribute_dofs (const FiniteElementdistribute_dofs (*this); + policy->distribute_dofs (*this,number_cache); //since get_subdomain_association querry n_dofs() //the need to re-work locally_owned_dofs outside of policy class @@ -1290,7 +1290,7 @@ DoFHandler::renumber_dofs (const std::vectorrenumber_dofs (new_numbers, *this); + policy->renumber_dofs (new_numbers, *this,number_cache); } diff --git a/deal.II/source/dofs/dof_handler_policy.cc b/deal.II/source/dofs/dof_handler_policy.cc index eb755a5758..bdb1d57b50 100644 --- a/deal.II/source/dofs/dof_handler_policy.cc +++ b/deal.II/source/dofs/dof_handler_policy.cc @@ -870,9 +870,10 @@ namespace internal template - NumberCache + void Sequential:: - distribute_dofs (DoFHandler &dof_handler) const + distribute_dofs (DoFHandler &dof_handler, + NumberCache & number_cache ) const { const types::global_dof_index n_dofs = Implementation::distribute_dofs (0, @@ -881,7 +882,6 @@ namespace internal // now set the elements of the // number cache appropriately - NumberCache number_cache; number_cache.n_global_dofs = n_dofs; number_cache.n_locally_owned_dofs = number_cache.n_global_dofs; @@ -898,7 +898,6 @@ namespace internal number_cache.locally_owned_dofs_per_processor = std::vector (1, number_cache.locally_owned_dofs); - return number_cache; } @@ -929,10 +928,11 @@ namespace internal } template - NumberCache + void Sequential:: renumber_dofs (const std::vector &new_numbers, - dealii::DoFHandler &dof_handler) const + dealii::DoFHandler &dof_handler, + NumberCache &number_cache) const { Implementation::renumber_dofs (new_numbers, IndexSet(0), dof_handler, true); @@ -943,7 +943,6 @@ namespace internal // have to set the elements // of the structure // appropriately anyway - NumberCache number_cache; number_cache.n_global_dofs = dof_handler.n_dofs(); number_cache.n_locally_owned_dofs = number_cache.n_global_dofs; @@ -960,17 +959,16 @@ namespace internal number_cache.locally_owned_dofs_per_processor = std::vector (1, number_cache.locally_owned_dofs); - return number_cache; } /* --------------------- class ParallelSequential ---------------- */ template - NumberCache + void ParallelShared:: - distribute_dofs (DoFHandler &dof_handler) const + distribute_dofs (DoFHandler &dof_handler, + NumberCache & number_cache) const { - NumberCache number_cache = Sequential::distribute_dofs (dof_handler); - return number_cache; + Sequential::distribute_dofs (dof_handler,number_cache); } template @@ -984,15 +982,15 @@ namespace internal } template - NumberCache + void ParallelShared:: renumber_dofs (const std::vector &new_numbers, - dealii::DoFHandler &dof_handler) const + dealii::DoFHandler &dof_handler, + NumberCache &number_cache) const { - NumberCache number_cache = Sequential::renumber_dofs (new_numbers,dof_handler); + Sequential::renumber_dofs (new_numbers,dof_handler,number_cache); //correct number_cache: number_cache.locally_owned_dofs = dealii::DoFTools::locally_owned_dofs_with_subdomain(dof_handler,dof_handler.get_tria().locally_owned_subdomain() ); - return number_cache; } /* --------------------- class ParallelDistributed ---------------- */ @@ -1958,11 +1956,11 @@ namespace internal template - NumberCache + void ParallelDistributed:: - distribute_dofs (DoFHandler &dof_handler) const + distribute_dofs (DoFHandler &dof_handler, + NumberCache &number_cache) const { - NumberCache number_cache; #ifndef DEAL_II_WITH_P4EST (void)dof_handler; @@ -2174,7 +2172,6 @@ namespace internal #endif // DEBUG #endif // DEAL_II_WITH_P4EST - return number_cache; } @@ -2425,15 +2422,15 @@ namespace internal template - NumberCache + void ParallelDistributed:: renumber_dofs (const std::vector &new_numbers, - dealii::DoFHandler &dof_handler) const + dealii::DoFHandler &dof_handler, + NumberCache &number_cache) const { Assert (new_numbers.size() == dof_handler.locally_owned_dofs().n_elements(), ExcInternalError()); - NumberCache number_cache; #ifndef DEAL_II_WITH_P4EST Assert (false, ExcNotImplemented()); @@ -2677,7 +2674,6 @@ namespace internal } #endif - return number_cache; } } } -- 2.39.5