]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Cache end_active() when assigning hp dofs.
authorDavid Wells <wellsd2@rpi.edu>
Wed, 7 Dec 2016 15:01:57 +0000 (10:01 -0500)
committerDavid Wells <wellsd2@rpi.edu>
Wed, 7 Dec 2016 19:07:41 +0000 (14:07 -0500)
This fixes a performance bug where distributing dofs on some grids would take an
amount of time quadratic in the number of dofs when it should be linear.

doc/news/changes.h
source/hp/dof_handler.cc

index 116b67a09e8722fe78dffba654c2258f657e8281..9faa80be667ea3044df3416099054584703ece6f 100644 (file)
@@ -235,6 +235,12 @@ inconvenience this causes.
 
 <ol>
 
+<li> Improved: The run time for the method hp::DoFHandler::distribute_dofs was
+     quadratic in the total number of dofs for some grids. This has been fixed.
+     <br>
+     (David Wells, 2016/12/07)
+</li>
+
 <li> New: The inverse of a rank-2 SymmetricTensor can now be directly computed
      with SymmetricTensor::invert() instead of having to use the
      Tensor::invert() function.
index c0bcf19470d09b3840b90814a34f75a269417f6a..18d7c11403658a550bd1b8d278c328a00b666601 100644 (file)
@@ -607,9 +607,10 @@ namespace internal
 
               types::global_dof_index next_free_dof = 0;
               types::global_dof_index cache_size = 0;
-              for (typename HpDoFHandler<dim,spacedim>::active_cell_iterator
-                   cell=dof_handler.begin_active(level);
-                   cell!=dof_handler.end_active(level); ++cell)
+              typename HpDoFHandler<dim,spacedim>::active_cell_iterator
+              cell=dof_handler.begin_active(level),
+              endc=dof_handler.end_active(level);
+              for (; cell!=endc; ++cell)
                 if (!cell->has_children())
                   {
                     dof_handler.levels[level]->dof_offsets[cell->index()] = next_free_dof;
@@ -638,9 +639,10 @@ namespace internal
           for (unsigned int level=0; level<dof_handler.tria->n_levels(); ++level)
             {
               types::global_dof_index counter = 0;
-              for (typename HpDoFHandler<dim,spacedim>::cell_iterator
-                   cell=dof_handler.begin_active(level);
-                   cell!=dof_handler.end_active(level); ++cell)
+              typename HpDoFHandler<dim,spacedim>::active_cell_iterator
+              cell=dof_handler.begin_active(level),
+              endc=dof_handler.end_active(level);
+              for (; cell!=endc; ++cell)
                 if (!cell->has_children())
                   counter += cell->get_fe().dofs_per_line;
 
@@ -705,7 +707,6 @@ namespace internal
             dof_handler.faces = new internal::hp::DoFIndicesOnFaces<2>;
           }
 
-
           // QUAD (CELL) DOFs
 
           // count how much space we need
@@ -735,9 +736,10 @@ namespace internal
 
               types::global_dof_index next_free_dof = 0;
               types::global_dof_index cache_size = 0;
-              for (typename HpDoFHandler<dim, spacedim>::active_cell_iterator
-                   cell=dof_handler.begin_active(level);
-                   cell!=dof_handler.end_active(level); ++cell)
+              typename HpDoFHandler<dim,spacedim>::active_cell_iterator
+              cell=dof_handler.begin_active(level),
+              endc=dof_handler.end_active(level);
+              for (; cell!=endc; ++cell)
                 if (!cell->has_children())
                   {
                     dof_handler.levels[level]->dof_offsets[cell->index()] = next_free_dof;
@@ -766,9 +768,10 @@ namespace internal
           for (unsigned int level=0; level<dof_handler.tria->n_levels(); ++level)
             {
               types::global_dof_index counter = 0;
-              for (typename HpDoFHandler<dim,spacedim>::cell_iterator
-                   cell=dof_handler.begin_active(level);
-                   cell!=dof_handler.end_active(level); ++cell)
+              typename HpDoFHandler<dim,spacedim>::active_cell_iterator
+              cell=dof_handler.begin_active(level),
+              endc=dof_handler.end_active(level);
+              for (; cell!=endc; ++cell)
                 if (!cell->has_children())
                   counter += cell->get_fe().dofs_per_quad;
 
@@ -1081,7 +1084,6 @@ namespace internal
             dof_handler.faces = new internal::hp::DoFIndicesOnFaces<3>;
           }
 
-
           // HEX (CELL) DOFs
 
           // count how much space we need
@@ -1111,9 +1113,10 @@ namespace internal
 
               types::global_dof_index next_free_dof = 0;
               types::global_dof_index cache_size = 0;
-              for (typename HpDoFHandler<dim,spacedim>::active_cell_iterator
-                   cell=dof_handler.begin_active(level);
-                   cell!=dof_handler.end_active(level); ++cell)
+              typename HpDoFHandler<dim,spacedim>::active_cell_iterator
+              cell=dof_handler.begin_active(level),
+              endc=dof_handler.end_active(level);
+              for (; cell!=endc; ++cell)
                 if (!cell->has_children())
                   {
                     dof_handler.levels[level]->dof_offsets[cell->index()] = next_free_dof;
@@ -1142,9 +1145,10 @@ namespace internal
           for (unsigned int level=0; level<dof_handler.tria->n_levels(); ++level)
             {
               types::global_dof_index counter = 0;
-              for (typename HpDoFHandler<dim,spacedim>::cell_iterator
-                   cell=dof_handler.begin_active(level);
-                   cell!=dof_handler.end_active(level); ++cell)
+              typename HpDoFHandler<dim,spacedim>::active_cell_iterator
+              cell=dof_handler.begin_active(level),
+              endc=dof_handler.end_active(level);
+              for (; cell!=endc; ++cell)
                 if (!cell->has_children())
                   counter += cell->get_fe().dofs_per_hex;
 

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.