From: bangerth Date: Thu, 31 May 2012 12:21:48 +0000 (+0000) Subject: Minor formatting changes. Remove unnecessary code to set a vector to zero. X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=70092583eb48f049d1d2517f571ce3ceeec20111;p=dealii-svn.git Minor formatting changes. Remove unnecessary code to set a vector to zero. git-svn-id: https://svn.dealii.org/trunk@25584 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/examples/step-15/step-15.cc b/deal.II/examples/step-15/step-15.cc index fd0f7738dc..6ab31f48b4 100644 --- a/deal.II/examples/step-15/step-15.cc +++ b/deal.II/examples/step-15/step-15.cc @@ -215,10 +215,7 @@ namespace Step15 { dof_handler.distribute_dofs (fe); present_solution.reinit (dof_handler.n_dofs()); - for(unsigned int i=0; i > gradients(n_q_points); - fe_values.get_function_gradients(present_solution, gradients); - - // Having the gradients of - // the old solution in the - // quadrature points, we - // are able to compute the - // coefficients $a_{n}$ in - // these points. - - const double coeff = 1/sqrt(1 + gradients[q_point] * gradients[q_point]); - - // The assembly of the - // system then is the same - // as always, except of the - // damping parameter of the - // Newton method, which we - // set on 0.1 in this case. - - for (unsigned int i = 0; i < dofs_per_cell; ++i) { - for (unsigned int j = 0; j < dofs_per_cell; ++j) { - cell_matrix(i, j) += (fe_values.shape_grad(i, q_point) - * coeff - * (fe_values.shape_grad(j, q_point) - - coeff * coeff - * (fe_values.shape_grad(j, q_point) - * gradients[q_point]) - * gradients[q_point]) - * fe_values.JxW(q_point)); - } - - cell_rhs(i) -= (fe_values.shape_grad(i, q_point) * coeff - * gradients[q_point] * fe_values.JxW(q_point)); + for (unsigned int q_point = 0; q_point < n_q_points; ++q_point) + { + + // To setup up the linear + // system, the gradient of + // the old solution in the + // quadrature points is + // needed. For this purpose + // there is is a function, + // which will write these + // gradients in a vector, + // where every component of + // the vector is a vector + // itself: + + std::vector > gradients(n_q_points); + fe_values.get_function_gradients(present_solution, gradients); + + // Having the gradients of + // the old solution in the + // quadrature points, we + // are able to compute the + // coefficients $a_{n}$ in + // these points. + + const double coeff = 1/sqrt(1 + gradients[q_point] * gradients[q_point]); + + // The assembly of the + // system then is the same + // as always, except of the + // damping parameter of the + // Newton method, which we + // set on 0.1 in this case. + + for (unsigned int i = 0; i < dofs_per_cell; ++i) + { + for (unsigned int j = 0; j < dofs_per_cell; ++j) + { + cell_matrix(i, j) += (fe_values.shape_grad(i, q_point) + * coeff + * (fe_values.shape_grad(j, q_point) + - coeff * coeff + * (fe_values.shape_grad(j, q_point) + * gradients[q_point]) + * gradients[q_point]) + * fe_values.JxW(q_point)); + } + + cell_rhs(i) -= (fe_values.shape_grad(i, q_point) * coeff + * gradients[q_point] * fe_values.JxW(q_point)); + } } - } cell->get_dof_indices (local_dof_indices); for (unsigned int i=0; i > gradients(n_q_points); - fe_values.get_function_gradients(linearization_point, gradients); - - // Having the gradients of - // the old solution in the - // quadrature points, we - // are able to compute the - // coefficients $a_{n}$ in - // these points. - - const double coeff = 1/sqrt(1 + gradients[q_point] * gradients[q_point]); - - // The assembly of the - // system then is the same - // as always, except of the - // damping parameter of the - // Newton method, which we - // set on 0.1 in this case. - - for (unsigned int i = 0; i < dofs_per_cell; ++i) { - cell_rhs(i) -= (fe_values.shape_grad(i, q_point) * coeff - * gradients[q_point] * fe_values.JxW(q_point)); + for (unsigned int q_point = 0; q_point < n_q_points; ++q_point) + { + + // To setup up the linear + // system, the gradient of + // the old solution in the + // quadrature points is + // needed. For this purpose + // there is is a function, + // which will write these + // gradients in a vector, + // where every component of + // the vector is a vector + // itself: + + std::vector > gradients(n_q_points); + fe_values.get_function_gradients(linearization_point, gradients); + + // Having the gradients of + // the old solution in the + // quadrature points, we + // are able to compute the + // coefficients $a_{n}$ in + // these points. + + const double coeff = 1/sqrt(1 + gradients[q_point] * gradients[q_point]); + + // The assembly of the + // system then is the same + // as always, except of the + // damping parameter of the + // Newton method, which we + // set on 0.1 in this case. + + for (unsigned int i = 0; i < dofs_per_cell; ++i) + cell_rhs(i) -= (fe_values.shape_grad(i, q_point) * coeff + * gradients[q_point] * fe_values.JxW(q_point)); } - } cell->get_dof_indices (local_dof_indices); for (unsigned int i=0; i1e-3)) + while (first_step || (previous_res>1e-3)) { // In the first step, we @@ -698,7 +698,7 @@ namespace Step15 // the first thing done every // time we restart the // process in the while-loop. - if(!first_step) + if (!first_step) { refine_grid();