From: Wolfgang Bangerth Date: Mon, 22 Oct 2007 18:39:49 +0000 (+0000) Subject: Add a few code snippets that I will later use to discuss a few aspects. X-Git-Tag: v8.0.0~9724 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4e98e8df125c10dcf2a0fc7a1be716560b8ae4e6;p=dealii.git Add a few code snippets that I will later use to discuss a few aspects. git-svn-id: https://svn.dealii.org/trunk@15361 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/examples/step-22/doc/intro.dox b/deal.II/examples/step-22/doc/intro.dox index c59cfdf609..7708deecc1 100644 --- a/deal.II/examples/step-22/doc/intro.dox +++ b/deal.II/examples/step-22/doc/intro.dox @@ -1,2 +1,162 @@

Introduction

+ + +@code +template +Tensor<1,dim> +extract_u (const FEValuesBase &fe_values, + const unsigned int i, + const unsigned int q) +{ + Tensor<1,dim> tmp; + + const unsigned int component + = fe_values.get_fe().system_to_component_index(i).first; + + if (component < dim) + tmp[component] = fe_values.shape_value (i,q); + + return tmp; +} + + + +template +double +extract_div_u (const FEValuesBase &fe_values, + const unsigned int i, + const unsigned int q) +{ + const unsigned int component + = fe_values.get_fe().system_to_component_index(i).first; + + if (component < dim) + return fe_values.shape_grad (i,q)[component]; + else + return 0; +} + + + +template +Tensor<2,dim> +extract_grad_s_u (const FEValuesBase &fe_values, + const unsigned int i, + const unsigned int q) +{ + Tensor<2,dim> tmp; + + const unsigned int component + = fe_values.get_fe().system_to_component_index(i).first; + + if (component < dim) + { + const Tensor<1,dim> grad_phi_over_2 = fe_values.shape_grad (i,q) / 2; + + for (unsigned int e=0; e +double extract_p (const FEValuesBase &fe_values, + const unsigned int i, + const unsigned int q) +{ + const unsigned int component + = fe_values.get_fe().system_to_component_index(i).first; + + if (component == dim) + return fe_values.shape_value (i,q); + else + return 0; +} + + + +template +double extract_T (const FEValuesBase &fe_values, + const unsigned int i, + const unsigned int q) +{ + const unsigned int component + = fe_values.get_fe().system_to_component_index(i).first; + + if (component == dim+1) + return fe_values.shape_value (i,q); + else + return 0; +} + + + +template +Tensor<1,dim> +extract_grad_T (const FEValuesBase &fe_values, + const unsigned int i, + const unsigned int q) +{ + Tensor<1,dim> tmp; + + const unsigned int component + = fe_values.get_fe().system_to_component_index(i).first; + + if (component == dim+1) + tmp = fe_values.shape_grad (i,q); + + return tmp; +} +@endcode + +@code + { + Vector xx(dof_handler.n_dofs()); + std::vector p_component (dof_handler.n_dofs()); + std::vector p_boundary (dof_handler.n_dofs()); + std::vector component_mask (dim+2, false); + component_mask[dim] = true; + DoFTools::extract_dofs (dof_handler, component_mask, p_component); + DoFTools::extract_boundary_dofs (dof_handler, component_mask, p_boundary); + + QGauss quadrature_formula(degree+2); + FEValues fe_values (fe, quadrature_formula, + update_values | update_gradients | update_JxW_values); + std::vector > > solution_grads(fe_values.n_quadrature_points, + std::vector > (dim+2)); + std::vector local_dof_indices (fe.dofs_per_cell); + + typename DoFHandler::active_cell_iterator + cell = dof_handler.begin_active(), + endc = dof_handler.end(); + for (; cell!=endc; ++cell) + { + fe_values.reinit (cell); + fe_values.get_function_gradients (solution, solution_grads); + + cell->get_dof_indices (local_dof_indices); + + for (unsigned int q=0; q