From d170bbb10990324aaa49f58cad5bebebeaad6705 Mon Sep 17 00:00:00 2001 From: Markus Blatt Date: Tue, 7 Jun 2016 16:56:37 +0000 Subject: [PATCH] Print all well switching in parallel. As for each well only one process is responsible, the output process does not see all wells. Ergo some well switching information was never printed in a parallel run. Therefore with this commit the well switching message is printed regardless on which process it appears. --- opm/autodiff/BlackoilModelBase_impl.hpp | 4 ++-- .../BlackoilMultiSegmentModel_impl.hpp | 2 +- opm/autodiff/MultisegmentWells.hpp | 3 +-- opm/autodiff/MultisegmentWells_impl.hpp | 13 +++++-------- opm/autodiff/StandardWells.hpp | 3 +-- opm/autodiff/StandardWells_impl.hpp | 18 ++++++++---------- .../BlackoilPolymerModel_impl.hpp | 2 +- 7 files changed, 19 insertions(+), 26 deletions(-) diff --git a/opm/autodiff/BlackoilModelBase_impl.hpp b/opm/autodiff/BlackoilModelBase_impl.hpp index 8352f9e0e..1804a8643 100644 --- a/opm/autodiff/BlackoilModelBase_impl.hpp +++ b/opm/autodiff/BlackoilModelBase_impl.hpp @@ -745,7 +745,7 @@ namespace detail { // Possibly switch well controls and updating well state to // get reasonable initial conditions for the wells - asImpl().wellModel().updateWellControls(terminal_output_, well_state); + asImpl().wellModel().updateWellControls(well_state); // Create the primary variables. SolutionState state = asImpl().variableState(reservoir_state, well_state); @@ -1034,7 +1034,7 @@ namespace detail { const Eigen::VectorXd& dx = solver.solve(total_residual_v.matrix()); assert(dx.size() == total_residual_v.size()); asImpl().wellModel().updateWellState(dx.array(), dpMaxRel(), well_state); - asImpl().wellModel().updateWellControls(terminal_output_, well_state); + asImpl().wellModel().updateWellControls(well_state); } } while (it < 15); diff --git a/opm/autodiff/BlackoilMultiSegmentModel_impl.hpp b/opm/autodiff/BlackoilMultiSegmentModel_impl.hpp index 9e1fba145..f6975083f 100644 --- a/opm/autodiff/BlackoilMultiSegmentModel_impl.hpp +++ b/opm/autodiff/BlackoilMultiSegmentModel_impl.hpp @@ -147,7 +147,7 @@ namespace Opm { // Possibly switch well controls and updating well state to // get reasonable initial conditions for the wells - wellModel().updateWellControls(terminal_output_, well_state); + wellModel().updateWellControls(well_state); // Create the primary variables. SolutionState state = asImpl().variableState(reservoir_state, well_state); diff --git a/opm/autodiff/MultisegmentWells.hpp b/opm/autodiff/MultisegmentWells.hpp index 3eeebfec6..13bad0857 100644 --- a/opm/autodiff/MultisegmentWells.hpp +++ b/opm/autodiff/MultisegmentWells.hpp @@ -193,8 +193,7 @@ namespace Opm { template void - updateWellControls(const bool terminal_output, - WellState& xw) const; + updateWellControls(WellState& xw) const; // TODO: these code are same with the StandardWells // to find a better solution later. diff --git a/opm/autodiff/MultisegmentWells_impl.hpp b/opm/autodiff/MultisegmentWells_impl.hpp index 7c4257150..65c732beb 100644 --- a/opm/autodiff/MultisegmentWells_impl.hpp +++ b/opm/autodiff/MultisegmentWells_impl.hpp @@ -822,8 +822,7 @@ namespace Opm template void MultisegmentWells:: - updateWellControls(const bool terminal_output, - WellState& xw) const + updateWellControls(WellState& xw) const { if( msWells().empty() ) return ; @@ -860,12 +859,10 @@ namespace Opm if (ctrl_index != nwc) { // Constraint number ctrl_index was broken, switch to it. - if (terminal_output) - { - std::cout << "Switching control mode for well " << msWells()[w]->name() - << " from " << modestring[well_controls_iget_type(wc, current)] - << " to " << modestring[well_controls_iget_type(wc, ctrl_index)] << std::endl; - } + // Each well is only active on one process. Therefore we always print the sitch info. + std::cout << "Switching control mode for well " << msWells()[w]->name() + << " from " << modestring[well_controls_iget_type(wc, current)] + << " to " << modestring[well_controls_iget_type(wc, ctrl_index)] << std::endl; xw.currentControls()[w] = ctrl_index; current = xw.currentControls()[w]; } diff --git a/opm/autodiff/StandardWells.hpp b/opm/autodiff/StandardWells.hpp index 27d963664..c43ffc0e9 100644 --- a/opm/autodiff/StandardWells.hpp +++ b/opm/autodiff/StandardWells.hpp @@ -115,8 +115,7 @@ namespace Opm { WellState& well_state); template - void updateWellControls(const bool terminal_output, - WellState& xw) const; + void updateWellControls(WellState& xw) const; // TODO: should LinearisedBlackoilResidual also be a template class? template diff --git a/opm/autodiff/StandardWells_impl.hpp b/opm/autodiff/StandardWells_impl.hpp index 611809689..db300c438 100644 --- a/opm/autodiff/StandardWells_impl.hpp +++ b/opm/autodiff/StandardWells_impl.hpp @@ -682,8 +682,7 @@ namespace Opm template void StandardWells:: - updateWellControls(const bool terminal_output, - WellState& xw) const + updateWellControls(WellState& xw) const { if( !localWellsActive() ) return ; @@ -720,14 +719,13 @@ namespace Opm } if (ctrl_index != nwc) { // Constraint number ctrl_index was broken, switch to it. - if (terminal_output) - { - std::ostringstream ss; - ss << "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; - OpmLog::info(ss.str()); - } + // We disregard terminal_ouput here as with it only messages + // for wells on one process will be printed. + std::ostringstream ss; + ss << "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; + OpmLog::info(ss.str()); xw.currentControls()[w] = ctrl_index; current = xw.currentControls()[w]; } diff --git a/opm/polymer/fullyimplicit/BlackoilPolymerModel_impl.hpp b/opm/polymer/fullyimplicit/BlackoilPolymerModel_impl.hpp index 205a29643..2ecdcb547 100644 --- a/opm/polymer/fullyimplicit/BlackoilPolymerModel_impl.hpp +++ b/opm/polymer/fullyimplicit/BlackoilPolymerModel_impl.hpp @@ -499,7 +499,7 @@ namespace Opm { // Possibly switch well controls and updating well state to // get reasonable initial conditions for the wells // updateWellControls(well_state); - wellModel().updateWellControls(terminal_output_, well_state); + wellModel().updateWellControls(well_state); // Create the primary variables. SolutionState state = variableState(reservoir_state, well_state);