]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
reworked DoFTools::locally_owned_dofs_with_subdomain again; Sum of locally owned...
authordenis.davydov <denis.davydov@0785d39b-7218-0410-832d-ea1e28bc413d>
Fri, 2 May 2014 11:24:23 +0000 (11:24 +0000)
committerdenis.davydov <denis.davydov@0785d39b-7218-0410-832d-ea1e28bc413d>
Fri, 2 May 2014 11:24:23 +0000 (11:24 +0000)
git-svn-id: https://svn.dealii.org/branches/branch_sharedtria@32873 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/source/dofs/dof_handler_policy.cc
deal.II/source/dofs/dof_tools.cc

index 0e03d7342b185d789ed9ae6b8839d3c27d44a1dc..4f8fe256fb576aebc77693f585d788fbc4dedc9e 100644 (file)
@@ -976,12 +976,14 @@ namespace internal
          NumberCache number_cache = Sequential<dim,spacedim>::distribute_dofs (dof_handler,number_cache_current);
          //update current number cache in DoFHandler
          number_cache_current = number_cache;
+         //number_cache.n_global_dofs;
          DoFRenumbering::subdomain_wise (dof_handler);
          number_cache.locally_owned_dofs_per_processor = DoFTools::locally_owned_dofs_with_subdomain (dof_handler);
          number_cache.locally_owned_dofs = number_cache.locally_owned_dofs_per_processor[dof_handler.get_tria().locally_owned_subdomain()];
          number_cache.n_locally_owned_dofs_per_processor.resize (number_cache.locally_owned_dofs_per_processor.size());
          for (unsigned int i = 0; i < number_cache.n_locally_owned_dofs_per_processor.size(); i++)
                  number_cache.n_locally_owned_dofs_per_processor[i] = number_cache.locally_owned_dofs_per_processor[i].n_elements();
+         number_cache.n_locally_owned_dofs = number_cache.n_locally_owned_dofs_per_processor[dof_handler.get_tria().locally_owned_subdomain()];
          return number_cache;
       }
 
index 5f01c410d2234582afac52a1a3e5634b751d553a..0b43671c1385e78423e11406fbeb49f7c0bd69ac 100644 (file)
@@ -1086,54 +1086,33 @@ namespace DoFTools
          const unsigned int num_subdomains = 1 + (*max_element(subdomain_association.begin(), subdomain_association.end()));
 
          std::vector<IndexSet> index_sets (num_subdomains,IndexSet(dof_handler.n_dofs()));
-         std::vector<types::global_dof_index> i_min(num_subdomains,0),
-                                                      i_max_plus_1(num_subdomains,0);
 
          //loop over subdomain_association
          //and populate IndexSet when
-         //a given subdomain is found
-         std::vector<bool> found_start(num_subdomains,false);
-         for (types::global_dof_index ind = 0; ind < subdomain_association.size(); ind++)
+         //a change in subdomain ID is found
+         types::global_dof_index i_min = 0;
+         types::global_dof_index cur_subdomain = subdomain_association[0];
+         for (types::global_dof_index ind = 1; ind < subdomain_association.size(); ind++)
          {
-                 for (unsigned int i = 0; i < num_subdomains; i++)
+                 //found index different from the current one
+                 if (subdomain_association[ind] != cur_subdomain)
                  {
-                         if (!found_start[i] && (subdomain_association[ind]== i) )
-                         {
-                                 found_start[i] = true;
-                                 i_min[i] = ind;
-                                 break;
-                         }
-                         if (found_start[i] && (subdomain_association[ind] != i) )
-                         {
-                                 found_start[i] = false;
-                                 i_max_plus_1[i] = ind;
-                                 index_sets[i].add_range(i_min[i],i_max_plus_1[i]);
-                                 break;
-                         }
+                         index_sets[cur_subdomain].add_range(i_min,ind);
+                         i_min = ind;
+                         cur_subdomain = subdomain_association[ind];
                  }
          }
-         //check that only 1 found_start[i] is true:
+         //the very last element is of different index
+         if (i_min == subdomain_association.size()-1)
          {
-                 bool found = false;
-                 for (unsigned int i = 0; i < num_subdomains; i++)
-                 {
-                         if (found_start[i])
-                         {
-                                 Assert(!found, ExcInternalError())
-                                 found = true;
-                         }
-                 }
+                 index_sets[cur_subdomain].add_index(i_min);
          }
-         // we have found the starting element, but not the end.
-         // the last element must have the same subdomain id,
-         // thus use it to add the range
-         for (unsigned int i = 0;i< num_subdomains; i++)
+         else //there are at least two different indices
          {
-                 if (found_start[i]) {
-                         index_sets[i].add_range(i_min[i],subdomain_association.size());
-                 }
-                 index_sets[i].compress();
+                 index_sets[cur_subdomain].add_range(i_min,subdomain_association.size());
          }
+         for (unsigned int i = 0;i< num_subdomains; i++)
+                 index_sets[i].compress();
          return index_sets;
   }
 

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.