From 6870ccd8980377cdfb843f48fdce2fd2f2b5729f Mon Sep 17 00:00:00 2001 From: Matthias Maier Date: Fri, 15 Jun 2018 18:21:26 -0500 Subject: [PATCH] step-5: make bilinear forms more readable Also use "0." instead of "0" for zeroing two matrices. --- examples/step-5/step-5.cc | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/examples/step-5/step-5.cc b/examples/step-5/step-5.cc index 102c04906a..08298a65cf 100644 --- a/examples/step-5/step-5.cc +++ b/examples/step-5/step-5.cc @@ -134,7 +134,8 @@ void Step5::setup_system() { dof_handler.distribute_dofs(fe); - std::cout << " Number of degrees of freedom: " << dof_handler.n_dofs() + std::cout << " Number of degrees of freedom: " // + << dof_handler.n_dofs() // << std::endl; DynamicSparsityPattern dsp(dof_handler.n_dofs()); @@ -184,8 +185,8 @@ void Step5::assemble_system() // coefficient value at each quadrature point. for (const auto &cell : dof_handler.active_cell_iterators()) { - cell_matrix = 0; - cell_rhs = 0; + cell_matrix = 0.; + cell_rhs = 0.; fe_values.reinit(cell); @@ -196,11 +197,13 @@ void Step5::assemble_system() for (unsigned int i = 0; i < dofs_per_cell; ++i) { for (unsigned int j = 0; j < dofs_per_cell; ++j) - cell_matrix(i, j) += - (current_coefficient * fe_values.shape_grad(i, q_index) * - fe_values.shape_grad(j, q_index) * fe_values.JxW(q_index)); + cell_matrix(i, j) += (current_coefficient * // + fe_values.shape_grad(i, q_index) * // + fe_values.shape_grad(j, q_index) * // + fe_values.JxW(q_index)); - cell_rhs(i) += (fe_values.shape_value(i, q_index) * 1.0 * + cell_rhs(i) += (fe_values.shape_value(i, q_index) * // + 1.0 * // fe_values.JxW(q_index)); } } @@ -269,8 +272,10 @@ void Step5::solve() solver.solve(system_matrix, solution, system_rhs, preconditioner); - std::cout << " " << solver_control.last_step() - << " CG iterations needed to obtain convergence." << std::endl; + std::cout << " " // + << solver_control.last_step() // + << " CG iterations needed to obtain convergence." // + << std::endl; } @@ -452,9 +457,11 @@ void Step5::run() // Now that we have a mesh for sure, we write some output and do all the // things that we have already seen in the previous examples. - std::cout << " Number of active cells: " - << triangulation.n_active_cells() << std::endl - << " Total number of cells: " << triangulation.n_cells() + std::cout << " Number of active cells: " // + << triangulation.n_active_cells() // + << std::endl // + << " Total number of cells: " // + << triangulation.n_cells() // << std::endl; setup_system(); -- 2.39.5