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),
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");
}
}