From: David Wells Date: Wed, 13 May 2020 17:37:24 +0000 (-0400) Subject: Avoid using std::cout in a test. X-Git-Tag: v9.3.0-rc1~1638^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F10194%2Fhead;p=dealii.git Avoid using std::cout in a test. 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. --- diff --git a/tests/mpi/petsc_step-27.cc b/tests/mpi/petsc_step-27.cc index f461b06a80..8698ae9707 100644 --- a/tests/mpi/petsc_step-27.cc +++ b/tests/mpi/petsc_step-27.cc @@ -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(); diff --git a/tests/mpi/petsc_step-27.with_p4est=true.with_petsc_with_hypre=true.with_petsc_with_complex=false.mpirun=1.output b/tests/mpi/petsc_step-27.with_p4est=true.with_petsc_with_hypre=true.with_petsc_with_complex=false.mpirun=1.output index 52edf0d8d4..be5f493842 100644 --- a/tests/mpi/petsc_step-27.with_p4est=true.with_petsc_with_hypre=true.with_petsc_with_complex=false.mpirun=1.output +++ b/tests/mpi/petsc_step-27.with_p4est=true.with_petsc_with_hypre=true.with_petsc_with_complex=false.mpirun=1.output @@ -1,3 +1,4 @@ + Cycle 0: Number of active cells : 768 Number of degrees of freedom: 3264 diff --git a/tests/mpi/petsc_step-27.with_p4est=true.with_petsc_with_hypre=true.with_petsc_with_complex=false.mpirun=1.output.petsc3.13.0 b/tests/mpi/petsc_step-27.with_p4est=true.with_petsc_with_hypre=true.with_petsc_with_complex=false.mpirun=1.output.petsc3.13.0 index 7eaee5e81b..2f32ca4174 100644 --- a/tests/mpi/petsc_step-27.with_p4est=true.with_petsc_with_hypre=true.with_petsc_with_complex=false.mpirun=1.output.petsc3.13.0 +++ b/tests/mpi/petsc_step-27.with_p4est=true.with_petsc_with_hypre=true.with_petsc_with_complex=false.mpirun=1.output.petsc3.13.0 @@ -1,3 +1,4 @@ + Cycle 0: Number of active cells : 768 Number of degrees of freedom: 3264 diff --git a/tests/mpi/petsc_step-27.with_p4est=true.with_petsc_with_hypre=true.with_petsc_with_complex=false.mpirun=2.output b/tests/mpi/petsc_step-27.with_p4est=true.with_petsc_with_hypre=true.with_petsc_with_complex=false.mpirun=2.output index 23fc8f3d17..ac1b765648 100644 --- a/tests/mpi/petsc_step-27.with_p4est=true.with_petsc_with_hypre=true.with_petsc_with_complex=false.mpirun=2.output +++ b/tests/mpi/petsc_step-27.with_p4est=true.with_petsc_with_hypre=true.with_petsc_with_complex=false.mpirun=2.output @@ -1,3 +1,4 @@ + Cycle 0: Number of active cells : 768 Number of degrees of freedom: 3264 diff --git a/tests/mpi/petsc_step-27.with_p4est=true.with_petsc_with_hypre=true.with_petsc_with_complex=false.mpirun=2.output.petsc3.13.0 b/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 cdefeaa01b..6863e70443 100644 --- a/tests/mpi/petsc_step-27.with_p4est=true.with_petsc_with_hypre=true.with_petsc_with_complex=false.mpirun=2.output.petsc3.13.0 +++ b/tests/mpi/petsc_step-27.with_p4est=true.with_petsc_with_hypre=true.with_petsc_with_complex=false.mpirun=2.output.petsc3.13.0 @@ -1,3 +1,4 @@ + Cycle 0: Number of active cells : 768 Number of degrees of freedom: 3264