From f0be287b03e17256ae1e98adf76f0ace5c57a2d6 Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Thu, 2 Feb 2006 06:00:57 +0000 Subject: [PATCH] Remove the code again that uses deallog. There was a careful explanation of what happens when we suppress deallog output, which was replaced by unexplained use of deallog instead of std::cout, followed by a completely useless use of push() and pop(). It is my belief that if we introduce new features of the library, then we should do so in a context where this makes sense, not gratuitously. git-svn-id: https://svn.dealii.org/trunk@12218 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/examples/step-4/step-4.cc | 73 +++++++++++++++++++++++-------- 1 file changed, 55 insertions(+), 18 deletions(-) diff --git a/deal.II/examples/step-4/step-4.cc b/deal.II/examples/step-4/step-4.cc index bb6007aa9d..d1208be47d 100644 --- a/deal.II/examples/step-4/step-4.cc +++ b/deal.II/examples/step-4/step-4.cc @@ -327,18 +327,18 @@ void LaplaceProblem::make_grid_and_dofs () GridGenerator::hyper_cube (triangulation, -1, 1); triangulation.refine_global (4); - deallog << "Number of active cells: " - << triangulation.n_active_cells() - << std::endl - << "Total number of cells: " - << triangulation.n_cells() - << std::endl; + std::cout << " Number of active cells: " + << triangulation.n_active_cells() + << std::endl + << " Total number of cells: " + << triangulation.n_cells() + << std::endl; dof_handler.distribute_dofs (fe); - deallog << "Number of degrees of freedom: " - << dof_handler.n_dofs() - << std::endl; + std::cout << " Number of degrees of freedom: " + << dof_handler.n_dofs() + << std::endl; sparsity_pattern.reinit (dof_handler.n_dofs(), dof_handler.n_dofs(), @@ -570,6 +570,15 @@ void LaplaceProblem::solve () SolverCG<> cg (solver_control); cg.solve (system_matrix, solution, system_rhs, PreconditionIdentity()); + + // We have made one addition, + // though: since we suppress output + // from the linear solvers, we have + // to print the number of + // iterations by hand. + std::cout << " " << solver_control.last_step() + << " CG iterations needed to obtain convergence." + << std::endl; } @@ -629,25 +638,21 @@ void LaplaceProblem::output_results () const template void LaplaceProblem::run () { - deallog << "Solving problem in " << dim << " space dimensions." << std::endl; - // Here we make use of the feature - // of LogStream that allows us - // indenting output inside blocks. - deallog.push(" "); + std::cout << "Solving problem in " << dim << " space dimensions." << std::endl; + make_grid_and_dofs(); assemble_system (); solve (); output_results (); - // Remove the indentation of output again - deallog.pop(); } // @sect4{The ``main'' function} // And this is the main function. It also - // looks mostly like in step-3, but note how - // we first create a variable of type + // looks mostly like in step-3, but if you + // look at the code below, note how we first + // create a variable of type // ``LaplaceProblem<2>'' (forcing the // compiler to compile the class template // with ``dim'' replaced by ``2'') and run a @@ -685,8 +690,40 @@ void LaplaceProblem::run () // i.e. after running the 3d problem, and // would needlessly hog memory while the 3d // run could actually use it. + // + // Finally, the first line of the function is + // used to suppress some output. Remember + // that in the previous example, we had the + // output from the linear solvers about the + // starting residual and the number of the + // iteration where convergence was + // detected. This can be suppressed through + // the ``deallog.depth_console(0)'' call. + // + // The rationale here is the following: the + // deallog (i.e. deal-log, not de-allog) + // variable represents a stream to which some + // parts of the library write output. It + // redirects this output to the console and + // if required to a file. The output is + // nested in a way so that each function can + // use a prefix string (separated by colons) + // for each line of output; if it calls + // another function, that may also use its + // prefix which is then printed after the one + // of the calling function. Since output from + // functions which are nested deep below is + // usually not as important as top-level + // output, you can give the deallog variable + // a maximal depth of nested output for + // output to console and file. The depth zero + // which we gave here means that no output is + // written. By changing it you can get more + // information about the innards of the + // library. int main () { + deallog.depth_console (0); { LaplaceProblem<2> laplace_problem_2d; laplace_problem_2d.run (); -- 2.39.5