[bugfix] make flow_ebos work when no wells are present.

This commit is contained in:
Robert Kloefkorn 2016-11-22 16:36:23 +01:00
parent 5ebed2f500
commit 1c2a2c417c
2 changed files with 29 additions and 14 deletions

View File

@ -300,7 +300,7 @@ namespace Opm {
// Compute the nonlinear update.
const int nc = AutoDiffGrid::numCells(grid_);
const int nw = wellModel().wells().number_of_wells;
const int nw = numWells();
BVector x(nc);
BVector xw(nw);
@ -447,7 +447,7 @@ namespace Opm {
int sizeNonLinear() const
{
const int nc = Opm::AutoDiffGrid::numCells(grid_);
const int nw = wellModel().wells().number_of_wells;
const int nw = numWells();
return numPhases() * (nc + nw);
}
@ -476,8 +476,11 @@ namespace Opm {
const auto& ebosJac = ebosSimulator_.model().linearizer().matrix();
auto& ebosResid = ebosSimulator_.model().linearizer().residual();
// apply well residual to the residual.
wellModel().apply(ebosResid);
if( xw.size() > 0 )
{
// apply well residual to the residual.
wellModel().apply(ebosResid);
}
// set initial guess
x = 0.0;
@ -497,9 +500,12 @@ namespace Opm {
istlSolver().solve( opA, x, ebosResid );
}
// recover wells.
xw = 0.0;
wellModel().recoverVariable(x, xw);
if( xw.size() > 0 )
{
// recover wells.
xw = 0.0;
wellModel().recoverVariable(x, xw);
}
}
//=====================================================================
@ -1249,6 +1255,8 @@ namespace Opm {
/// return true if wells are available in the reservoir
bool wellsActive() const { return well_model_.wellsActive(); }
int numWells() const { return wellsActive() ? wells().number_of_wells : 0; }
/// return true if wells are available on this process
bool localWellsActive() const { return well_model_.localWellsActive(); }

View File

@ -92,14 +92,17 @@ enum WellVariablePositions {
, fluid_(nullptr)
, active_(nullptr)
, vfp_properties_(nullptr)
, well_perforation_densities_(wells_arg->well_connpos[wells_arg->number_of_wells])
, well_perforation_pressure_diffs_(wells_arg->well_connpos[wells_arg->number_of_wells])
, wellVariables_(wells_arg->number_of_wells * wells_arg->number_of_phases)
, F0_(wells_arg->number_of_wells * wells_arg->number_of_phases)
, well_perforation_densities_( wells_ ? wells_arg->well_connpos[wells_arg->number_of_wells] : 0)
, well_perforation_pressure_diffs_( wells_ ? wells_arg->well_connpos[wells_arg->number_of_wells] : 0)
, wellVariables_( wells_ ? (wells_arg->number_of_wells * wells_arg->number_of_phases) : 0)
, F0_(wells_ ? (wells_arg->number_of_wells * wells_arg->number_of_phases) : 0 )
{
invDuneD_.setBuildMode( Mat::row_wise );
duneC_.setBuildMode( Mat::row_wise );
duneB_.setBuildMode( Mat::row_wise );
if( wells_ )
{
invDuneD_.setBuildMode( Mat::row_wise );
duneC_.setBuildMode( Mat::row_wise );
duneB_.setBuildMode( Mat::row_wise );
}
}
void init(const BlackoilPropsAdInterface* fluid_arg,
@ -709,6 +712,10 @@ enum WellVariablePositions {
std::vector<double> residual() {
if( ! wellsActive() )
{
return std::vector<double>();
}
const int np = numPhases();
const int nw = wells().number_of_wells;