Added a parallel aware logger for switching wells.

It will collect all the switches. Afterwards they are collect on
the root process and logged there.

This commit includes a small test program.
This commit is contained in:
Markus Blatt
2016-09-23 11:50:11 +02:00
parent 02e8211067
commit 07318edfa1
11 changed files with 431 additions and 17 deletions

View File

@@ -71,7 +71,8 @@ namespace Opm
StandardWells::StandardWells(const Wells* wells_arg)
StandardWells::StandardWells(const Wells* wells_arg,
const Communication& comm)
: wells_active_(wells_arg!=nullptr)
, wells_(wells_arg)
, wops_(wells_arg)
@@ -82,6 +83,7 @@ namespace Opm
, well_perforation_densities_(Vector())
, well_perforation_pressure_diffs_(Vector())
, store_well_perforation_fluxes_(false)
, comm_(comm)
{
}
@@ -706,9 +708,10 @@ namespace Opm
StandardWells::
updateWellControls(WellState& xw) const
{
wellhelpers::WellSwitchingLogger logger(comm_);
if( !localWellsActive() ) return ;
std::string modestring[4] = { "BHP", "THP", "RESERVOIR_RATE", "SURFACE_RATE" };
// Find, for each well, if any constraints are broken. If so,
// switch control to first broken constraint.
const int np = wells().number_of_phases;
@@ -743,11 +746,9 @@ namespace Opm
// Constraint number ctrl_index was broken, switch to it.
// 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());
logger.wellSwitched(wells().name[w],
well_controls_iget_type(wc, current),
well_controls_iget_type(wc, ctrl_index));
xw.currentControls()[w] = ctrl_index;
current = xw.currentControls()[w];
}