]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Correct sample code.
authorMartin Kronbichler <kronbichler@lnm.mw.tum.de>
Fri, 4 Sep 2009 09:42:27 +0000 (09:42 +0000)
committerMartin Kronbichler <kronbichler@lnm.mw.tum.de>
Fri, 4 Sep 2009 09:42:27 +0000 (09:42 +0000)
git-svn-id: https://svn.dealii.org/trunk@19392 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/examples/step-37/doc/intro.dox

index 1ec698b4a8f51471740b6ca171d52cb632b6c934..33c4e5dd907f769abbd800122312913260716365 100644 (file)
@@ -230,20 +230,21 @@ write:
         for (unsigned int d=0; d<dim; ++d)
           for (unsigned int i=0; i<dofs_per_cell; ++i)
            temp_vector(q_point*dim+d) += fe_values.shape_grad(i,q_point)[d] *
-                                         src(i);
+                                         cell_src(i);
 
       for (unsigned int q_point=0; q_point<n_q_points; ++q_point)
         for (unsigned int d=0; d<dim; ++d)
          temp_vector(q_point*dim+d) *= fe_values.JxW(q_point);
 
+      cell_dst = 0;
       for (unsigned int i=0; i<dofs_per_cell; ++i)
         for (unsigned int q_point=0; q_point<n_q_points; ++q_point)
           for (unsigned int d=0; d<dim; ++d)
-           dst(i) += fe_values.shape_grad(i,q_point)[d] *
-                     temp_vector(q_point*dim+d);
+           cell_dst(i) += fe_values.shape_grad(i,q_point)[d] *
+                          temp_vector(q_point*dim+d);
 
       for (unsigned int i=0; i<dofs_per_cell; ++i)
-        dst(local_dof_indices(i)) += cell_dst;
+        dst(local_dof_indices(i)) += cell_dst(i);
     }
 }
 @endcode
@@ -306,21 +307,22 @@ Let's see how we can implement this:
         for (unsigned int d=0; d<dim; ++d)
           for (unsigned int i=0; i<dofs_per_cell; ++i)
            temp_vector(q_point*dim+d) +=
-             fe_values_reference.shape_grad(i,q_point)[d] * src(i);
+             fe_values_reference.shape_grad(i,q_point)[d] * cell_src(i);
 
       for (unsigned int q_point=0; q_point<n_q_points; ++q_point)
         {
           // apply the Jacobian of the mapping from unit to real cell
          Tensor<1,dim> temp;
          for (unsigned int d=0; d<dim; ++d)
-            {
-             temp[d] = temp_vector(q_point*dim+d);
-             temp_vector(q_point*dim+d);
-           }
+           temp[d] = temp_vector(q_point*dim+d);
          for (unsigned int d=0; d<dim; ++d)
-           for (unsigned int e=0; e<dim; ++e)
-             temp_vector(q_point*dim+d) += fe_values.inverse_jacobian(q_point)[d][e] *
-                                           temp[e];
+           {
+             double sum = 0;
+             for (unsigned int e=0; e<dim; ++e)
+               sum += fe_values.inverse_jacobian(q_point)[d][e] *
+                      temp[e];
+             temp_vector(q_point*dim+d) = sum;
+           }
 
           // multiply with integration weight
          for (unsigned int d=0; d<dim; ++d)
@@ -329,23 +331,26 @@ Let's see how we can implement this:
           // apply the transpose of the Jacobian of the mapping from unit
          // to real cell
          for (unsigned int d=0; d<dim; ++d)
-            {
-             temp[d] = temp_vector(q_point*dim+d);
-             temp_vector(q_point*dim+d);
-           }
+           temp[d] = temp_vector(q_point*dim+d);
          for (unsigned int d=0; d<dim; ++d)
-           for (unsigned int e=0; e<dim; ++e)
-             temp_vector(q_point*dim+d) += fe_values.inverse_jacobian(q_point)[e][d] *
-                                           temp[e];
+           {
+             double sum = 0;
+             for (unsigned int e=0; e<dim; ++e)
+               sum += fe_values.inverse_jacobian(q_point)[e][d] *
+                      temp[e];
+             temp_vector(q_point*dim+d) = sum;
+           }
         }
+
+      cell_dst = 0;
       for (unsigned int i=0; i<dofs_per_cell; ++i)
         for (unsigned int q_point=0; q_point<n_q_points; ++q_point)
           for (unsigned int d=0; d<dim; ++d)
-           dst(i) += fe_values_reference.shape_grad(i,q_point)[d] *
-                     temp_vector(q_point*dim+d);
+           cell_dst(i) += fe_values_reference.shape_grad(i,q_point)[d] *
+                          temp_vector(q_point*dim+d);
 
       for (unsigned int i=0; i<dofs_per_cell; ++i)
-        dst(local_dof_indices(i)) += cell_dst;
+        dst(local_dof_indices(i)) += cell_dst(i);
     }
 }
 @endcode

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.