]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Refactor and fix IndexSet::is_ascending_ad_one_to_one 4094/head
authorDaniel Arndt <daniel.arndt@iwr.uni-heidelberg.de>
Wed, 22 Mar 2017 17:17:06 +0000 (18:17 +0100)
committerDaniel Arndt <daniel.arndt@iwr.uni-heidelberg.de>
Wed, 22 Mar 2017 17:17:06 +0000 (18:17 +0100)
source/base/index_set.cc

index 8066b9ec0465cb981ee0e1cb1077259b7e9783c0..7e74c4964f2bac23f9635461212fe80f5fe7e79d 100644 (file)
@@ -636,20 +636,23 @@ IndexSet::is_ascending_and_one_to_one (const MPI_Comm &communicator) const
   if (my_rank == 0)
     {
       // find out if the received std::vector is ascending
-      types::global_dof_index old_dof = global_dofs[0], new_dof = 0;
+      types::global_dof_index old_dof = global_dofs[0];
       types::global_dof_index index = 0;
       while (global_dofs[index] == numbers::invalid_dof_index)
         ++index;
       old_dof = global_dofs[index++];
       for (; index<global_dofs.size(); ++index)
         {
-          new_dof = global_dofs[index];
-          if (new_dof == numbers::invalid_dof_index)
-            new_dof = old_dof;
-          else if (new_dof<=old_dof)
+          const types::global_dof_index new_dof = global_dofs[index];
+          if (new_dof !=  numbers::invalid_dof_index)
             {
-              is_globally_ascending = false;
-              break;
+              if  (new_dof <= old_dof)
+                {
+                  is_globally_ascending = false;
+                  break;
+                }
+              else
+                old_dof = new_dof;
             }
         }
     }

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.