Only compute well potential if needed

A boolen user parameter is added to controll the computation of well
potential.

This is a temporary fix to assure that no extra computation time is used
on well potential calculation if it is not needed. The long term fix
will require a more thorough revising of the well group implementation.
This commit is contained in:
Tor Harald Sandve
2016-04-19 16:03:33 +02:00
parent 84972ac21e
commit e9b097cbf4
4 changed files with 89 additions and 79 deletions

View File

@@ -1703,6 +1703,8 @@ namespace detail {
const std::vector<ADB>& b_perfcells,
WellState& well_state)
{
//only compute well potentials if they are needed
if (param_.compute_well_potentials_) {
const int nw = wells().number_of_wells;
const int np = wells().number_of_phases;
const Opm::PhaseUsage pu = fluid_.phaseUsage();
@@ -1790,6 +1792,7 @@ namespace detail {
cq += superset(well_potentials[phase].value(), Span(nperf, np, phase), nperf*np);
}
well_state.wellPotentials().assign(cq.data(), cq.data() + nperf*np);
}
}

View File

@@ -48,6 +48,7 @@ namespace Opm
tolerance_wells_ = param.getDefault("tolerance_wells", tolerance_wells_ );
solve_welleq_initially_ = param.getDefault("solve_welleq_initially",solve_welleq_initially_);
update_equations_scaling_ = param.getDefault("update_equations_scaling", update_equations_scaling_);
compute_well_potentials_ = param.getDefault("compute_well_potentials", compute_well_potentials_);
}
@@ -65,6 +66,7 @@ namespace Opm
tolerance_wells_ = 1.0e-3;
solve_welleq_initially_ = true;
update_equations_scaling_ = false;
compute_well_potentials_ = false;
}

View File

@@ -49,6 +49,10 @@ namespace Opm
/// Update scaling factors for mass balance equations
bool update_equations_scaling_;
/// Compute well potentials, needed to calculate default guide rates for group
/// controlled wells
bool compute_well_potentials_;
/// Construct from user parameters or defaults.
explicit BlackoilModelParameters( const parameter::ParameterGroup& param );

View File

@@ -222,12 +222,13 @@ namespace Opm
// Increment timer, remember well state.
++timer;
prev_well_state = well_state;
// Compute Well potentials (only used to determine default guide rates for group controlled wells)
// TODO: add some logic to avoid unnecessary calulations of well potentials.
// Compute Well potentials if they are needed
// Only used to determine default guide rates for group controlled wells
if ( param_.getDefault("compute_well_potentials", false ) ) {
asImpl().computeWellPotentials(wells, state, well_state, well_potentials);
}
}
// Write final simulation state.
output_writer_.writeTimeStep( timer, state, prev_well_state );