]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Optimize certain issues.
authorWolfgang Bangerth <bangerth@math.tamu.edu>
Mon, 4 Apr 2005 19:00:10 +0000 (19:00 +0000)
committerWolfgang Bangerth <bangerth@math.tamu.edu>
Mon, 4 Apr 2005 19:00:10 +0000 (19:00 +0000)
git-svn-id: https://svn.dealii.org/trunk@10347 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/lac/source/petsc_parallel_sparse_matrix.cc

index 05fd72b0aade03cc09c1cd6dc417663e236b5473..b18a77ced17ad562535161a3c2c521ab4bc2faa6 100644 (file)
@@ -415,22 +415,29 @@ namespace PETScWrappers
                                            //
                                            // note that we actually have to
                                            // set the entries to something
-                                           // non-zero!
-          for (unsigned int i=local_row_start; i<local_row_end; ++i)
-            for (unsigned int j=0; j<sparsity_pattern.row_length(i);
-                 ++j)
+                                           // non-zero! do the allocation one
+                                           // row at a time
+          {
+            const std::vector<PetscScalar>
+              values (sparsity_pattern.max_entries_per_row(),
+                      1.);
+            
+            for (unsigned int i=local_row_start; i<local_row_end; ++i)
               {
                 const int petsc_i = i;
-                const int petsc_j = sparsity_pattern.column_number(i,j);
-                const double value = 1;
-                MatSetValues (matrix, 1, &petsc_i, 1, &petsc_j,
-                              &value, INSERT_VALUES);
+                MatSetValues (matrix, 1, &petsc_i,
+                              sparsity_pattern.row_length(i),
+                              &colnums_in_window[rowstart_in_window[i-local_row_start]],
+                              &values[0], INSERT_VALUES);
               }
+          }
+          
           compress ();
 
                                            // set the dummy entries set above
                                            // back to zero
           *this = 0;
+          compress ();
           
 #endif
 

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.