]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Unify if-else branches with common code. 16410/head
authorWolfgang Bangerth <bangerth@colostate.edu>
Tue, 2 Jan 2024 21:43:08 +0000 (14:43 -0700)
committerWolfgang Bangerth <bangerth@colostate.edu>
Tue, 2 Jan 2024 21:43:08 +0000 (14:43 -0700)
source/lac/trilinos_sparsity_pattern.cc

index ccf17e785fd241c6f7437bfffa39fd4eaf14d8fc..3b7bcb23cdd48f3466992e630b05c9df9d41c5b6 100644 (file)
@@ -412,58 +412,40 @@ namespace TrilinosWrappers
 
       std::vector<TrilinosWrappers::types::int_type> row_indices;
 
-      // Include possibility to exchange data since DynamicSparsityPattern is
-      // able to do so
-      if (exchange_data == false)
-        for (size_type row = first_row; row < last_row; ++row)
-          {
-            const TrilinosWrappers::types::int_type row_length =
-              sp.row_length(row);
-            if (row_length == 0)
-              continue;
+      for (size_type row = first_row; row < last_row; ++row)
+        {
+          const TrilinosWrappers::types::int_type row_length =
+            sp.row_length(row);
+          if (row_length == 0)
+            continue;
 
-            row_indices.resize(row_length, -1);
-            {
-              typename SparsityPatternType::iterator p = sp.begin(row);
-              // avoid incrementing p over the end of the current row because
-              // it is slow for DynamicSparsityPattern in parallel
-              for (int col = 0; col < row_length;)
-                {
-                  row_indices[col++] = p->column();
-                  if (col < row_length)
-                    ++p;
-                }
-            }
+          row_indices.resize(row_length, -1);
+          {
+            typename SparsityPatternType::iterator p = sp.begin(row);
+            // avoid incrementing p over the end of the current row because
+            // it is slow for DynamicSparsityPattern in parallel
+            for (int col = 0; col < row_length;)
+              {
+                row_indices[col++] = p->column();
+                if (col < row_length)
+                  ++p;
+              }
+          }
+          if (exchange_data == false)
             graph->Epetra_CrsGraph::InsertGlobalIndices(row,
                                                         row_length,
                                                         row_indices.data());
-          }
-      else
-        for (size_type row = 0; row < sp.n_rows(); ++row)
-          {
-            const TrilinosWrappers::types::int_type row_length =
-              sp.row_length(row);
-            if (row_length == 0)
-              continue;
-
-            row_indices.resize(row_length, -1);
+          else
             {
-              typename SparsityPatternType::iterator p = sp.begin(row);
-              // avoid incrementing p over the end of the current row because
-              // it is slow for DynamicSparsityPattern in parallel
-              for (int col = 0; col < row_length;)
-                {
-                  row_indices[col++] = p->column();
-                  if (col < row_length)
-                    ++p;
-                }
+              // Include possibility to exchange data since
+              // DynamicSparsityPattern is able to do so
+              const TrilinosWrappers::types::int_type trilinos_row = row;
+              graph->InsertGlobalIndices(1,
+                                         &trilinos_row,
+                                         row_length,
+                                         row_indices.data());
             }
-            const TrilinosWrappers::types::int_type trilinos_row = row;
-            graph->InsertGlobalIndices(1,
-                                       &trilinos_row,
-                                       row_length,
-                                       row_indices.data());
-          }
+        }
 
       // TODO A dynamic_cast fails here, this is suspicious.
       const auto &range_map =

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.