mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
Print status output only on rank 0 for parallel runs.
This commit is contained in:
parent
fec50b491a
commit
d35d301a4b
@ -265,8 +265,8 @@ try
|
||||
fis_solver.reset(new NewtonIterationBlackoilSimple(param, parallel_information));
|
||||
}
|
||||
|
||||
// Write parameters used for later reference.
|
||||
bool output = param.getDefault("output", true);
|
||||
// Write parameters used for later reference. (only if rank is zero)
|
||||
bool output = param.getDefault("output", true) && ( grid->comm().rank()==0 );
|
||||
std::string output_dir;
|
||||
if (output) {
|
||||
// Create output directory if needed.
|
||||
@ -306,13 +306,19 @@ try
|
||||
outputWriter,
|
||||
threshold_pressures);
|
||||
|
||||
std::cout << "\n\n================ Starting main simulation loop ===============\n"
|
||||
<< std::flush;
|
||||
if( grid->comm().rank()==0 )
|
||||
{
|
||||
std::cout << "\n\n================ Starting main simulation loop ===============\n"
|
||||
<< std::flush;
|
||||
}
|
||||
|
||||
SimulatorReport fullReport = simulator.run(simtimer, must_distribute ? distributed_state : state);
|
||||
|
||||
if( grid->comm().rank()==0 )
|
||||
{
|
||||
std::cout << "\n\n================ End of simulation ===============\n\n";
|
||||
fullReport.report(std::cout);
|
||||
}
|
||||
|
||||
if (output) {
|
||||
std::string filename = output_dir + "/walltime.txt";
|
||||
|
@ -196,6 +196,9 @@ namespace Opm {
|
||||
|
||||
LinearisedBlackoilResidual residual_;
|
||||
|
||||
/// \brief Wether we print something to std::cout
|
||||
bool verbosity_;
|
||||
|
||||
std::vector<int> primalVariable_;
|
||||
|
||||
// Private methods.
|
||||
|
@ -212,7 +212,17 @@ namespace detail {
|
||||
, residual_ ( { std::vector<ADB>(fluid.numPhases(), ADB::null()),
|
||||
ADB::null(),
|
||||
ADB::null() } )
|
||||
, verbosity_ (true)
|
||||
{
|
||||
#if HAVE_MPI
|
||||
if(linsolver_.parallelInformation().type()==typeid(ParallelISTLInformation))
|
||||
{
|
||||
const ParallelISTLInformation& info =
|
||||
boost::any_cast<const ParallelISTLInformation&>(linsolver_.parallelInformation());
|
||||
// Only rank 0 does print to std::cout
|
||||
verbosity_= (info.communicator().rank()==0);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@ -286,7 +296,7 @@ namespace detail {
|
||||
|
||||
detectNewtonOscillations(residual_norms_history, it, relaxRelTol(), isOscillate, isStagnate);
|
||||
|
||||
if (isOscillate) {
|
||||
if (isOscillate && verbosity_) {
|
||||
omega -= relaxIncrement();
|
||||
omega = std::max(omega, relaxMax());
|
||||
std::cout << " Oscillating behavior detected: Relaxation set to " << omega << std::endl;
|
||||
@ -1113,9 +1123,12 @@ namespace detail {
|
||||
}
|
||||
if (ctrl_index != nwc) {
|
||||
// Constraint number ctrl_index was broken, switch to it.
|
||||
std::cout << "Switching control mode for well " << wells().name[w]
|
||||
<< " from " << modestring[well_controls_iget_type(wc, current)]
|
||||
<< " to " << modestring[well_controls_iget_type(wc, ctrl_index)] << std::endl;
|
||||
if (verbosity_)
|
||||
{
|
||||
std::cout << "Switching control mode for well " << wells().name[w]
|
||||
<< " from " << modestring[well_controls_iget_type(wc, current)]
|
||||
<< " to " << modestring[well_controls_iget_type(wc, ctrl_index)] << std::endl;
|
||||
}
|
||||
xw.currentControls()[w] = ctrl_index;
|
||||
// Also updating well state and primary variables.
|
||||
// We can only be switching to BHP and SURFACE_RATE
|
||||
@ -1993,23 +2006,27 @@ namespace detail {
|
||||
OPM_THROW(Opm::NumericalProblem,"One of the residuals is NaN or to large!");
|
||||
}
|
||||
|
||||
if (iteration == 0) {
|
||||
std::cout << "\nIter MB(OIL) MB(WATER) MB(GAS) CNVW CNVO CNVG WELL-FLOW WELL-CNTRL\n";
|
||||
if ( verbosity_ )
|
||||
{
|
||||
// Only rank 0 does print to std::cout
|
||||
if (iteration == 0) {
|
||||
std::cout << "\nIter MB(OIL) MB(WATER) MB(GAS) CNVW CNVO CNVG WELL-FLOW WELL-CNTRL\n";
|
||||
}
|
||||
const std::streamsize oprec = std::cout.precision(3);
|
||||
const std::ios::fmtflags oflags = std::cout.setf(std::ios::scientific);
|
||||
std::cout << std::setw(4) << iteration
|
||||
<< std::setw(11) << mass_balance_residual[Water]
|
||||
<< std::setw(11) << mass_balance_residual[Oil]
|
||||
<< std::setw(11) << mass_balance_residual[Gas]
|
||||
<< std::setw(11) << CNV[Water]
|
||||
<< std::setw(11) << CNV[Oil]
|
||||
<< std::setw(11) << CNV[Gas]
|
||||
<< std::setw(11) << residualWellFlux
|
||||
<< std::setw(11) << residualWell
|
||||
<< std::endl;
|
||||
std::cout.precision(oprec);
|
||||
std::cout.flags(oflags);
|
||||
}
|
||||
const std::streamsize oprec = std::cout.precision(3);
|
||||
const std::ios::fmtflags oflags = std::cout.setf(std::ios::scientific);
|
||||
std::cout << std::setw(4) << iteration
|
||||
<< std::setw(11) << mass_balance_residual[Water]
|
||||
<< std::setw(11) << mass_balance_residual[Oil]
|
||||
<< std::setw(11) << mass_balance_residual[Gas]
|
||||
<< std::setw(11) << CNV[Water]
|
||||
<< std::setw(11) << CNV[Oil]
|
||||
<< std::setw(11) << CNV[Gas]
|
||||
<< std::setw(11) << residualWellFlux
|
||||
<< std::setw(11) << residualWell
|
||||
<< std::endl;
|
||||
std::cout.precision(oprec);
|
||||
std::cout.flags(oflags);
|
||||
return converged;
|
||||
}
|
||||
|
||||
|
@ -112,6 +112,7 @@ namespace Opm
|
||||
std::vector<int> allcells_;
|
||||
const bool has_disgas_;
|
||||
const bool has_vapoil_;
|
||||
bool verbosity_;
|
||||
// eclipse_state
|
||||
std::shared_ptr<EclipseState> eclipse_state_;
|
||||
// output_writer
|
||||
@ -184,6 +185,7 @@ namespace Opm
|
||||
solver_(linsolver),
|
||||
has_disgas_(has_disgas),
|
||||
has_vapoil_(has_vapoil),
|
||||
verbosity_(true),
|
||||
eclipse_state_(eclipse_state),
|
||||
output_writer_(output_writer),
|
||||
rateConverter_(props_, std::vector<int>(AutoDiffGrid::numCells(grid_), 0)),
|
||||
@ -195,6 +197,15 @@ namespace Opm
|
||||
for (int cell = 0; cell < num_cells; ++cell) {
|
||||
allcells_[cell] = cell;
|
||||
}
|
||||
#if HAVE_MPI
|
||||
if(solver_.parallelInformation().type()==typeid(ParallelISTLInformation))
|
||||
{
|
||||
const ParallelISTLInformation& info =
|
||||
boost::any_cast<const ParallelISTLInformation&>(solver_.parallelInformation());
|
||||
// Only rank 0 does print to std::cout
|
||||
verbosity_= (info.communicator().rank()==0);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@ -239,7 +250,10 @@ namespace Opm
|
||||
while (!timer.done()) {
|
||||
// Report timestep.
|
||||
step_timer.start();
|
||||
timer.report(std::cout);
|
||||
if ( verbosity_ )
|
||||
{
|
||||
timer.report(std::cout);
|
||||
}
|
||||
|
||||
// Create wells and well state.
|
||||
WellsManager wells_manager(eclipse_state_,
|
||||
@ -292,7 +306,12 @@ namespace Opm
|
||||
|
||||
// Report timing.
|
||||
const double st = solver_timer.secsSinceStart();
|
||||
std::cout << "Fully implicit solver took: " << st << " seconds." << std::endl;
|
||||
|
||||
if ( verbosity_ )
|
||||
{
|
||||
std::cout << "Fully implicit solver took: " << st << " seconds." << std::endl;
|
||||
}
|
||||
|
||||
stime += st;
|
||||
if ( output_writer_.output() ) {
|
||||
SimulatorReport step_report;
|
||||
|
Loading…
Reference in New Issue
Block a user