mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
Guard access of well variable with asImpl().localWellsActive()
Since PR #541 the arrays cq_s, mob_perfcells, and b_perfcells are empty if there are no wells in the domain of the process. This caused segementation faults at various places where we compute on the wells. With this commit we now guard this places using asImpl().localWellsActive() and only using the array if the call returns true.
This commit is contained in:
parent
cb3ed9aa4f
commit
afc3ad3522
@ -1061,6 +1061,13 @@ namespace detail {
|
|||||||
const SolutionState&,
|
const SolutionState&,
|
||||||
const WellState&)
|
const WellState&)
|
||||||
{
|
{
|
||||||
|
if ( !asImpl().localWellsActive() )
|
||||||
|
{
|
||||||
|
// If there are no wells in the subdomain of the proces then
|
||||||
|
// cq_s has zero size and will cause a segmentation fault below.
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Add well contributions to mass balance equations
|
// Add well contributions to mass balance equations
|
||||||
const int nc = Opm::AutoDiffGrid::numCells(grid_);
|
const int nc = Opm::AutoDiffGrid::numCells(grid_);
|
||||||
const int np = asImpl().numPhases();
|
const int np = asImpl().numPhases();
|
||||||
@ -1258,6 +1265,13 @@ namespace detail {
|
|||||||
const SolutionState& state,
|
const SolutionState& state,
|
||||||
WellState& xw) const
|
WellState& xw) const
|
||||||
{
|
{
|
||||||
|
if ( !asImpl().localWellsActive() )
|
||||||
|
{
|
||||||
|
// If there are no wells in the subdomain of the proces then
|
||||||
|
// cq_s has zero size and will cause a segmentation fault below.
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Update the perforation phase rates (used to calculate the pressure drop in the wellbore).
|
// Update the perforation phase rates (used to calculate the pressure drop in the wellbore).
|
||||||
const int np = wells().number_of_phases;
|
const int np = wells().number_of_phases;
|
||||||
const int nw = wells().number_of_wells;
|
const int nw = wells().number_of_wells;
|
||||||
@ -1282,6 +1296,13 @@ namespace detail {
|
|||||||
void BlackoilModelBase<Grid, Implementation>::addWellFluxEq(const std::vector<ADB>& cq_s,
|
void BlackoilModelBase<Grid, Implementation>::addWellFluxEq(const std::vector<ADB>& cq_s,
|
||||||
const SolutionState& state)
|
const SolutionState& state)
|
||||||
{
|
{
|
||||||
|
if( !asImpl().localWellsActive() )
|
||||||
|
{
|
||||||
|
// If there are no wells in the subdomain of the proces then
|
||||||
|
// cq_s has zero size and will cause a segmentation fault below.
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const int np = wells().number_of_phases;
|
const int np = wells().number_of_phases;
|
||||||
const int nw = wells().number_of_wells;
|
const int nw = wells().number_of_wells;
|
||||||
ADB qs = state.qs;
|
ADB qs = state.qs;
|
||||||
@ -1603,9 +1624,14 @@ namespace detail {
|
|||||||
|
|
||||||
std::vector<ADB> mob_perfcells_const(np, ADB::null());
|
std::vector<ADB> mob_perfcells_const(np, ADB::null());
|
||||||
std::vector<ADB> b_perfcells_const(np, ADB::null());
|
std::vector<ADB> b_perfcells_const(np, ADB::null());
|
||||||
for (int phase = 0; phase < np; ++phase) {
|
|
||||||
mob_perfcells_const[phase] = ADB::constant(mob_perfcells[phase].value());
|
if (asImpl().localWellsActive() ){
|
||||||
b_perfcells_const[phase] = ADB::constant(b_perfcells[phase].value());
|
// If there are non well in the sudomain of the process
|
||||||
|
// thene mob_perfcells_const and b_perfcells_const would be empty
|
||||||
|
for (int phase = 0; phase < np; ++phase) {
|
||||||
|
mob_perfcells_const[phase] = ADB::constant(mob_perfcells[phase].value());
|
||||||
|
b_perfcells_const[phase] = ADB::constant(b_perfcells[phase].value());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int it = 0;
|
int it = 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user