From f0691504af14dc0131d9edf9ef0cba2f44b8b575 Mon Sep 17 00:00:00 2001 From: Markus Blatt Date: Fri, 8 May 2015 13:15:59 +0200 Subject: [PATCH] Prevent printing stats on more than 1 process for CPR. --- examples/flow_cp.cpp | 47 ++++++++++++++++++++---------- opm/autodiff/CPRPreconditioner.hpp | 3 +- 2 files changed, 33 insertions(+), 17 deletions(-) diff --git a/examples/flow_cp.cpp b/examples/flow_cp.cpp index 6e8c1714b..7885bd663 100644 --- a/examples/flow_cp.cpp +++ b/examples/flow_cp.cpp @@ -93,7 +93,7 @@ namespace { - void warnIfUnusedParams(const Opm::parameter::ParameterGroup& param) +void warnIfUnusedParams(const Opm::parameter::ParameterGroup& param) { if (param.anyUnused()) { std::cout << "-------------------- Unused parameters: --------------------\n"; @@ -113,20 +113,34 @@ try // Must ensure an instance of the helper is created to initialise MPI. const Dune::MPIHelper& mpi_helper = Dune::MPIHelper::instance(argc, argv); using namespace Opm; + // Write parameters used for later reference. (only if rank is zero) + bool output_cout = ( mpi_helper.rank() == 0 ); - std::cout << "******************************************************************************************\n"; - std::cout << "* *\n"; - std::cout << "* This is Flow (version 2015.04, experimental variant using dune-cornerpoint) *\n"; - std::cout << "* *\n"; - std::cout << "* Flow is a simulator for fully implicit three-phase black-oil flow that is part of OPM. *\n"; - std::cout << "* For more information see: *\n"; - std::cout << "* http://opm-project.org *\n"; - std::cout << "* *\n"; - std::cout << "******************************************************************************************\n\n"; - + if(output_cout) + { + std::cout << "******************************************************************************************\n"; + std::cout << "* *\n"; + std::cout << "* This is Flow (version 2015.04, experimental variant using dune-cornerpoint) *\n"; + std::cout << "* *\n"; + std::cout << "* Flow is a simulator for fully implicit three-phase black-oil flow that is part of OPM. *\n"; + std::cout << "* For more information see: *\n"; + std::cout << "* http://opm-project.org *\n"; + std::cout << "* *\n"; + std::cout << "******************************************************************************************\n\n"; + } + // Read parameters, see if a deck was specified on the command line. - std::cout << "--------------- Reading parameters ---------------" << std::endl; - parameter::ParameterGroup param(argc, argv, false); + if ( output_cout ) + { + std::cout << "--------------- Reading parameters ---------------" << std::endl; + } + + parameter::ParameterGroup param(argc, argv, false, output_cout); + if( !output_cout ) + { + param.disableOutput(); + } + if (!param.unhandledArguments().empty()) { if (param.unhandledArguments().size() != 1) { std::cerr << "You can only specify a single input deck on the command line.\n"; @@ -336,7 +350,7 @@ try threshold_pressures); if (!schedule->initOnly()){ - if( grid->comm().rank()==0 ) + if( output_cout ) { std::cout << "\n\n================ Starting main simulation loop ===============\n" << std::flush; @@ -344,7 +358,7 @@ try SimulatorReport fullReport = simulator.run(simtimer, must_distribute ? distributed_state : state); - if( grid->comm().rank()==0 ) + if( output_cout ) { std::cout << "\n\n================ End of simulation ===============\n\n"; fullReport.reportFullyImplicit(std::cout); @@ -358,7 +372,8 @@ try } } else { outputWriter.writeInit( simtimer ); - std::cout << "\n\n================ Simulation turned off ===============\n" << std::flush; + if ( output_cout ) + std::cout << "\n\n================ Simulation turned off ===============\n" << std::flush; } } catch (const std::exception &e) { diff --git a/opm/autodiff/CPRPreconditioner.hpp b/opm/autodiff/CPRPreconditioner.hpp index 335694ab6..56cffe7e5 100644 --- a/opm/autodiff/CPRPreconditioner.hpp +++ b/opm/autodiff/CPRPreconditioner.hpp @@ -459,7 +459,8 @@ createEllipticPreconditionerPointer(const M& Ae, double relax, // Linear solver parameters const double tolerance = param_.cpr_solver_tol_; const int maxit = param_.cpr_max_ell_iter_; - const int verbosity = param_.cpr_solver_verbose_ ? 1 : 0; + const int verbosity = ( param_.cpr_solver_verbose_ && + comm_.communicator().rank()==0 ) ? 1 : 0; // operator result containing iterations etc. Dune::InverseOperatorResult result;