From cc9dd1a4ca8b15a1bc70fd8a99dd07b31a061ebc Mon Sep 17 00:00:00 2001 From: bangerth Date: Thu, 22 Sep 2011 12:40:54 +0000 Subject: [PATCH] Leave a code block we may want to discuss. git-svn-id: https://svn.dealii.org/trunk@24365 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/examples/step-32/doc/intro.dox | 60 +++++++++++++++++++++++++- 1 file changed, 59 insertions(+), 1 deletion(-) diff --git a/deal.II/examples/step-32/doc/intro.dox b/deal.II/examples/step-32/doc/intro.dox index 0f142b3555..2212c3855d 100644 --- a/deal.II/examples/step-32/doc/intro.dox +++ b/deal.II/examples/step-32/doc/intro.dox @@ -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 output_results 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 err_quadrature(q_base, 2); + + const unsigned int n_q_points = err_quadrature.size(); + FEValues 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 local_dof_indices (fe_values.dofs_per_cell); + + std::vector local_div (n_q_points); + std::vector > local_grad (n_q_points); + + typename DoFHandler::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 +

Changes to the Stokes preconditioner

@@ -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] -- 2.39.5