]> https://gitweb.dealii.org/ - dealii.git/commitdiff
fix step-42
authorTimo Heister <timo.heister@gmail.com>
Fri, 29 Mar 2013 20:30:38 +0000 (20:30 +0000)
committerTimo Heister <timo.heister@gmail.com>
Fri, 29 Mar 2013 20:30:38 +0000 (20:30 +0000)
git-svn-id: https://svn.dealii.org/trunk@29111 0785d39b-7218-0410-832d-ea1e28bc413d

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

index 6cfa030e6772dce8535a8b5f56deeb74e1ede49c..37d5905fa75beda47be610936d97f6af5dd56753 100644 (file)
@@ -717,17 +717,12 @@ namespace Step42
 
       system_matrix_newton.reinit (sp);
 
-      // create a SP that only contains the diagonal
-      sp.reinit(locally_owned_dofs, mpi_communicator);
-      for (unsigned int idx=0; idx < locally_owned_dofs.n_elements();++idx)
-        {
-          unsigned int gidx = locally_owned_dofs.nth_index_in_set(idx);
-          sp.add(gidx, gidx);
-        }
-      sp.compress();
-
-      TrilinosWrappers::SparseMatrix mass_matrix;
-      mass_matrix.reinit (sp);
+                                      // we are going to reuse the system
+                                      // matrix for assembling the diagonal
+                                      // of the mass matrix so that we do not
+                                      // need to allocate two sparse matrices
+                                      // at the same time:
+      TrilinosWrappers::SparseMatrix & mass_matrix = system_matrix_newton;
       assemble_mass_matrix_diagonal (mass_matrix);
       const unsigned int
       start = (system_rhs_newton.local_range().first),
@@ -735,8 +730,12 @@ namespace Step42
       for (unsigned int j=start; j<end; j++)
         diag_mass_matrix_vector (j) = mass_matrix.diag_element (j);
       number_iterations = 0;
-
+      
       diag_mass_matrix_vector.compress (VectorOperation::insert);
+
+                                      // remove the mass matrix entries from the matrix:
+      mass_matrix = 0;
+
       computing_timer.exit_section("Setup: matrix");
     }
   }

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.