]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Simplify copying elements into Trilinos in the same way.
authorbangerth <bangerth@0785d39b-7218-0410-832d-ea1e28bc413d>
Wed, 20 Aug 2008 13:06:50 +0000 (13:06 +0000)
committerbangerth <bangerth@0785d39b-7218-0410-832d-ea1e28bc413d>
Wed, 20 Aug 2008 13:06:50 +0000 (13:06 +0000)
git-svn-id: https://svn.dealii.org/trunk@16609 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/examples/step-31/step-31.cc

index 8c9599a55b9bf3136b6fe045ee30622e0c1a68e9..c99e0061d48b98ea7860f98408bcd8bf6b5e6df1 100644 (file)
@@ -170,26 +170,17 @@ void PreconditionerTrilinosAmg::initialize (
   
     for (unsigned int row=0; row<n_u; ++row)
       {
-       const unsigned int temporary_row_length = 
-           sparsity_pattern->row_length (row);
-       
-       row_indices.resize (row_lengths[row], 0);
-       values.resize (row_lengths[row], 0.);
-  
-       unsigned int col_counter = 0;
-       for (unsigned int col=0; col<temporary_row_length; ++col)
-         {
-           unsigned int col_index = sparsity_pattern->column_number (row, col);
-           if (std::abs(matrix (row, col_index)) > 1e-13)
-             {
-               row_indices[col_counter] = 
-                   sparsity_pattern->column_number (row, col);
-               values[col_counter] = 
-                   matrix (row, row_indices[col_counter]);
-               ++col_counter;
-             }
-         }
-       Assert (col_counter == static_cast<unsigned int>(row_lengths[row]),
+       unsigned int index = 0;
+       for (SparseMatrix<double>::const_iterator p = matrix.begin(row);
+            p != matrix.end(row); ++p)
+         if (std::abs(p->value()) > 1e-13)
+           {
+             row_indices[index] = p->column();
+             values[index]      = p->value();
+             ++index;
+           }
+
+       Assert (index == static_cast<unsigned int>(row_lengths[row]),
                ExcMessage("Filtering out zeros could not "
                            "be successfully finished!"));
   

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.