]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Simplify code internal::extract_remote_rows() 16417/head
authorPeter Munch <peterrmuench@gmail.com>
Sat, 6 Jan 2024 12:49:04 +0000 (13:49 +0100)
committerPeter Munch <peterrmuench@gmail.com>
Sat, 6 Jan 2024 12:49:04 +0000 (13:49 +0100)
include/deal.II/lac/sparse_matrix_tools.h

index c3e0eae385da25e914aa4997f25530513d79fd43..fac58460cc3f014f796d44a57186a25851ca4538 100644 (file)
@@ -252,6 +252,10 @@ namespace SparseMatrixTools
 
       std::map<unsigned int, T1> data;
 
+      std::pair<types::global_dof_index,
+                std::vector<std::pair<types::global_dof_index, Number>>>
+        buffer;
+
       for (unsigned int i = 0; i < row_to_procs.size(); ++i)
         {
           if (row_to_procs[i].empty())
@@ -262,22 +266,13 @@ namespace SparseMatrixTools
 
           const unsigned int row_length = sparsity_pattern.row_length(row);
 
-
-          std::pair<types::global_dof_index,
-                    std::vector<std::pair<types::global_dof_index, Number>>>
-            buffer;
           buffer.first = row;
+          buffer.second.resize(row_length);
 
-          for (unsigned int i = 0; i < row_length; ++i)
-            {
-              buffer.second.emplace_back(entry->column(), entry->value());
-
-              if (i + 1 != row_length)
-                ++entry;
-            }
+          for (unsigned int j = 0; j < row_length; ++j, ++entry)
+            buffer.second[j] = {entry->column(), entry->value()};
 
-          for (const auto &proc :
-               row_to_procs[locally_owned_dofs.index_within_set(buffer.first)])
+          for (const auto &proc : row_to_procs[i])
             data[proc].emplace_back(buffer);
         }
 

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.