]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Submit the essence of the last bit of the patch by Oleh Krehel, now that I actually...
authorWolfgang Bangerth <bangerth@math.tamu.edu>
Thu, 8 Aug 2013 19:58:46 +0000 (19:58 +0000)
committerWolfgang Bangerth <bangerth@math.tamu.edu>
Thu, 8 Aug 2013 19:58:46 +0000 (19:58 +0000)
git-svn-id: https://svn.dealii.org/trunk@30259 0785d39b-7218-0410-832d-ea1e28bc413d

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

index af5ebd5d29f3086cbf0b06cdde440d3a6cdae628..794e09f8703fef1f26a8988d4a344a542e77f3b2 100644 (file)
@@ -358,6 +358,21 @@ namespace Step25
     system_matrix.add (-std::pow(time_step*theta,2), tmp_matrix);
 
     // Then, we compute the right-hand side vector $-F_h(U^{n,l})$.
+    //
+    // We have to first build up the matrix
+    // $M+k^2\theta^2 A$, which we put into <code>tmp_matrix</code>
+    // use it to compute a contribution to the right hand side vector, and
+    // then build the matrix $M-k^2\theta(1-\theta) A$. We could
+    // build it in the same way as before, i.e., using code like
+    // @code
+    // tmp_matrix.copy_from (mass_matrix);
+    // tmp_matrix.add (-std::pow(time_step,2)*theta*(1-theta), laplace_matrix);
+    // @endcode
+    // but we can save the expense of the <code>copy_from</code> operation
+    // by starting from what is already in the <code>tmp_matrix</code>
+    // variable (i.e., $M+k^2\theta^2 A$) and subtracting from this
+    // $k^2\theta^2 A+k^2\theta(1-\theta) A=k^2\theta A$ when computing the
+    // second matrix:
     system_rhs = 0;
 
     tmp_matrix.copy_from (mass_matrix);
@@ -367,8 +382,8 @@ namespace Step25
     tmp_matrix.vmult (tmp_vector, solution);
     system_rhs += tmp_vector;
 
-    tmp_matrix.copy_from (mass_matrix);
-    tmp_matrix.add (-std::pow(time_step,2)*theta*(1-theta), laplace_matrix);
+
+    tmp_matrix.add(-std::pow(time_step, 2) * theta, laplace_matrix);
 
     tmp_matrix.vmult (tmp_vector, old_solution);
     system_rhs -= tmp_vector;

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.