]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Leave a code block we may want to discuss.
authorbangerth <bangerth@0785d39b-7218-0410-832d-ea1e28bc413d>
Thu, 22 Sep 2011 12:40:54 +0000 (12:40 +0000)
committerbangerth <bangerth@0785d39b-7218-0410-832d-ea1e28bc413d>
Thu, 22 Sep 2011 12:40:54 +0000 (12:40 +0000)
git-svn-id: https://svn.dealii.org/trunk@24365 0785d39b-7218-0410-832d-ea1e28bc413d

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

index 0f142b3555f2332db8772c522d83e71c6e708b77..2212c3855d36c53dc4965e151234df09e07382f5 100644 (file)
@@ -250,6 +250,64 @@ $\frac{\eta}{L}$, and we will use this factor in the assembly of the system
 matrix and preconditioner. We will recover the unscaled pressure in the
 <code>output_results</code> function.
 
+@code
+  //calculate l2 norm of divergence and
+  //norm of gradient
+  {
+    double my_cells_error[2] = {0, 0};
+    QGauss<1>      q_base(parameters.stokes_velocity_degree);
+    QIterated<dim> err_quadrature(q_base, 2);
+
+    const unsigned int n_q_points =  err_quadrature.size();
+    FEValues<dim> fe_values (mapping, stokes_fe,  err_quadrature,
+                             update_JxW_values | update_gradients);
+    const unsigned int dofs_per_cell = fe_values.get_fe().dofs_per_cell;
+    const FEValuesExtractors::Vector velocities (0);
+
+    std::vector<unsigned int> local_dof_indices (fe_values.dofs_per_cell);
+
+    std::vector<double>         local_div (n_q_points);
+    std::vector<Tensor<2,dim> > local_grad (n_q_points);
+
+    typename DoFHandler<dim>::active_cell_iterator
+    cell = stokes_dof_handler.begin_active(),
+    endc = stokes_dof_handler.end();
+    for (; cell!=endc; ++cell)
+      if (cell->subdomain_id() ==
+          Utilities::System::get_this_mpi_process(MPI_COMM_WORLD))
+        {
+          fe_values.reinit (cell);
+          cell->get_dof_indices(local_dof_indices);
+
+          fe_values[velocities].get_function_divergences (stokes_solution,
+                                                          local_div);
+          fe_values[velocities].get_function_gradients (stokes_solution,
+                                                        local_grad);
+
+          double cell_error = 0.0;
+          for (unsigned int q = 0; q < n_q_points; ++q)
+            {
+              my_cells_error[0] += local_div[q] * local_div[q] * fe_values.JxW(q);
+              my_cells_error[1] += scalar_product(local_grad[q], local_grad[q]) * fe_values.JxW(q);
+            }
+        }
+
+    double div_error[2] = {0,0};
+#ifdef DEAL_II_COMPILER_SUPPORTS_MPI
+    MPI_Allreduce (&my_cells_error, &div_error, 2, MPI_DOUBLE,
+                   MPI_SUM, MPI_COMM_WORLD);
+#else
+    div_error[0] = my_cells_error[0];
+    div_error[1] = my_cells_error[1];
+#endif
+
+    div_error[0] = std::sqrt(div_error[0]);
+    div_error[1] = std::sqrt(div_error[1]);
+    pcout << "> ||divergence||=" << div_error[0] << std::endl;
+    pcout << "> || gradient ||=" << div_error[1] << std::endl;
+  }
+@endcode
+
 
 <h3> Changes to the Stokes preconditioner </h3>
 
@@ -726,7 +784,7 @@ the following quantities:
   temperature equation, lead to the equation
   @f[
     \gamma(\mathbf x)
-     = 
+     =
      \frac{\rho q+2\eta \varepsilon(\mathbf u):\varepsilon(\mathbf u)}
      {\rho c_p},
   @f]

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.