]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Convert the final policy function. 4538/head
authorWolfgang Bangerth <bangerth@colostate.edu>
Fri, 23 Jun 2017 15:52:20 +0000 (09:52 -0600)
committerWolfgang Bangerth <bangerth@colostate.edu>
Fri, 23 Jun 2017 15:52:20 +0000 (09:52 -0600)
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
source/dofs/dof_handler.cc
source/dofs/dof_handler_policy.cc

index 375ffd04b82f4aa839346bc7290532c900e1f487..8fcefd75ad6e27990733a3332ac8cc742610c49f 100644 (file)
@@ -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<types::global_dof_index> &new_numbers,
-                       NumberCache &number_cache) const = 0;
+        NumberCache
+        renumber_dofs (const std::vector<types::global_dof_index> &new_numbers) const = 0;
       };
 
 
@@ -124,9 +120,8 @@ namespace internal
 
         // documentation is inherited
         virtual
-        void
-        renumber_dofs (const std::vector<types::global_dof_index>  &new_numbers,
-                       NumberCache &number_cache) const;
+        NumberCache
+        renumber_dofs (const std::vector<types::global_dof_index>  &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<types::global_dof_index>  &new_numbers,
-                       NumberCache &number_cache) const;
+        NumberCache
+        renumber_dofs (const std::vector<types::global_dof_index>  &new_numbers) const;
       };
 
 
@@ -212,9 +206,8 @@ namespace internal
 
         // documentation is inherited
         virtual
-        void
-        renumber_dofs (const std::vector<types::global_dof_index>  &new_numbers,
-                       NumberCache &number_cache) const;
+        NumberCache
+        renumber_dofs (const std::vector<types::global_dof_index>  &new_numbers) const;
 
       private:
         /**
index 18be6f188273a3120d17e2dea06909d7e83abd2c..3cce7dc7b11306b19af947a6d3786e74ad8f99b3 100644 (file)
@@ -1215,7 +1215,7 @@ DoFHandler<dim,spacedim>::renumber_dofs (const std::vector<types::global_dof_ind
               ExcMessage ("New DoF index is not less than the total number of dofs."));
 #endif
 
-  policy->renumber_dofs (new_numbers, number_cache);
+  number_cache = policy->renumber_dofs (new_numbers);
 }
 
 
index 17a074f5151a6ab900bbed266e4986fd4fe035cd..52cbae372ea0805b59a3bcda5ad02d8af1329456 100644 (file)
@@ -995,10 +995,9 @@ namespace internal
 
 
       template <int dim, int spacedim>
-      void
+      NumberCache
       Sequential<dim,spacedim>::
-      renumber_dofs (const std::vector<types::global_dof_index> &new_numbers,
-                     NumberCache &number_cache_current) const
+      renumber_dofs (const std::vector<types::global_dof_index> &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<IndexSet> (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<dim, spacedim>::renumber_dofs (new_dof_indices, number_cache);
+        number_cache = this->Sequential<dim, spacedim>::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 <int dim, int spacedim>
-      void
+      NumberCache
       ParallelShared<dim,spacedim>::
-      renumber_dofs (const std::vector<types::global_dof_index> &new_numbers,
-                     NumberCache                                &number_cache) const
+      renumber_dofs (const std::vector<types::global_dof_index> &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<unsigned int> 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<dim, spacedim>::renumber_dofs (global_gathered_numbers, number_cache);
+        NumberCache number_cache
+          = this->Sequential<dim, spacedim>::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 <int dim, int spacedim>
-      void
+      NumberCache
       ParallelDistributed<dim, spacedim>::
-      renumber_dofs (const std::vector<dealii::types::global_dof_index> &new_numbers,
-                     NumberCache &number_cache_current) const
+      renumber_dofs (const std::vector<dealii::types::global_dof_index> &new_numbers) const
       {
         (void)new_numbers;
 
@@ -2983,7 +2983,7 @@ namespace internal
         }
 #endif
 
-        number_cache_current = std::move(number_cache);
+        return number_cache;
       }
     }
   }

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.