]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Avoid using std::cout in a test. 10194/head
authorDavid Wells <drwells@email.unc.edu>
Wed, 13 May 2020 17:37:24 +0000 (13:37 -0400)
committerDavid Wells <drwells@email.unc.edu>
Wed, 13 May 2020 17:37:24 +0000 (13:37 -0400)
This is problematic on misconfigured MPI implementations that print
warnings for one reason or another every time they are run (e.g., the
default MPI implementation on Ubuntu 16.04).

It is easy enough in this case to do the normal thing and print
everything to deallog.

tests/mpi/petsc_step-27.cc
tests/mpi/petsc_step-27.with_p4est=true.with_petsc_with_hypre=true.with_petsc_with_complex=false.mpirun=1.output
tests/mpi/petsc_step-27.with_p4est=true.with_petsc_with_hypre=true.with_petsc_with_complex=false.mpirun=1.output.petsc3.13.0
tests/mpi/petsc_step-27.with_p4est=true.with_petsc_with_hypre=true.with_petsc_with_complex=false.mpirun=2.output
tests/mpi/petsc_step-27.with_p4est=true.with_petsc_with_hypre=true.with_petsc_with_complex=false.mpirun=2.output.petsc3.13.0

index f461b06a80916ea8ad39e35faecc52cc77f674bf..8698ae97079f851735a99876f676004a6aadca57 100644 (file)
@@ -171,7 +171,7 @@ namespace Step27
     , triangulation(mpi_communicator)
     , dof_handler(triangulation)
     , max_degree(dim <= 2 ? 7 : 5)
-    , pcout(std::cout,
+    , pcout(deallog.get_file_stream(),
             (Utilities::MPI::this_mpi_process(mpi_communicator) == 0))
   {
     for (unsigned int degree = 2; degree <= max_degree; ++degree)
@@ -329,10 +329,13 @@ namespace Step27
     LA::MPI::Vector completely_distributed_solution(locally_owned_dofs,
                                                     mpi_communicator);
 
-    SolverControl solver_control(system_rhs.size(),
-                                 1e-8 * system_rhs.l2_norm());
-    //                           ^~~~
-    // Loss of precision with a factor of 1e-12 with Trilinos
+    SolverControl solver_control(
+      system_rhs.size(),
+      1e-8 * system_rhs.l2_norm(),
+      // ^~~~
+      // Loss of precision with a factor of 1e-12 with Trilinos
+      false,
+      false);
     LA::SolverCG cg(solver_control, mpi_communicator);
 
     LA::MPI::PreconditionAMG                 preconditioner;
@@ -340,13 +343,10 @@ namespace Step27
     data.symmetric_operator = true;
     preconditioner.initialize(system_matrix, data);
 
-    check_solver_within_range(cg.solve(system_matrix,
-                                       completely_distributed_solution,
-                                       system_rhs,
-                                       preconditioner),
-                              solver_control.last_step(),
-                              5,
-                              40);
+    cg.solve(system_matrix,
+             completely_distributed_solution,
+             system_rhs,
+             preconditioner);
 
     pcout << "   Solved in " << solver_control.last_step() << " iterations."
           << std::endl;
@@ -476,6 +476,9 @@ main(int argc, char *argv[])
       using namespace Step27;
 
       Utilities::MPI::MPI_InitFinalize mpi_initialization(argc, argv, 1);
+      // This is the right choice (e.g., vs. mpi_initlog()) since the test
+      // uses ConditionalOStream
+      initlog();
 
       LaplaceProblem<2> laplace_problem;
       laplace_problem.run();

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.