From cd749b34524fbe252311d2b780206beeece9b69f Mon Sep 17 00:00:00 2001 From: Tor Harald Sandve Date: Fri, 9 Sep 2016 15:17:34 +0200 Subject: [PATCH] Fix seg-fault for cases without wells --- opm/autodiff/StandardWellsDense.hpp | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/opm/autodiff/StandardWellsDense.hpp b/opm/autodiff/StandardWellsDense.hpp index e223505f1..a14ed55aa 100644 --- a/opm/autodiff/StandardWellsDense.hpp +++ b/opm/autodiff/StandardWellsDense.hpp @@ -114,6 +114,11 @@ namespace Opm { const std::vector& depth_arg, const std::vector& pv_arg) { + + if ( ! localWellsActive() ) { + return; + } + fluid_ = fluid_arg; active_ = active_arg; vfp_properties_ = vfp_properties_arg; @@ -121,7 +126,6 @@ namespace Opm { cell_depths_ = extractPerfData(depth_arg); pv_ = pv_arg; - // setup sparsity pattern for the matrices //[A B^T [x = [ res // C D] x_well] res_well] @@ -221,7 +225,7 @@ namespace Opm { const int cell_idx = wells().well_cells[perf]; const auto& intQuants = *(ebosSimulator.model().cachedIntensiveQuantities(cell_idx, /*timeIdx=*/0)); - std::vector cq_s(np); + std::vector cq_s(np,0.0); computeWellFlux(w, wells().WI[perf], intQuants, wellPerforationPressureDiffs()[perf], cq_s); for (int p1 = 0; p1 < np; ++p1) { @@ -286,6 +290,10 @@ namespace Opm { // substract Binv(D)rw from r; void apply( BVector& r) const { + if ( ! localWellsActive() ) { + return; + } + BVector invDrw(invDuneD_.N()); invDuneD_.mv(resWell_,invDrw); duneB_.mmtv(invDrw, r); @@ -293,6 +301,9 @@ namespace Opm { // subtract B*inv(D)*C * x from A*x void apply(const BVector& x, BVector& Ax) { + if ( ! localWellsActive() ) { + return; + } BVector Cx(duneC_.N()); duneC_.mv(x, Cx); BVector invDCx(invDuneD_.N()); @@ -302,6 +313,9 @@ namespace Opm { // xw = inv(D)*(rw - C*x) void recoverVariable(const BVector& x, BVector& xw) const { + if ( ! localWellsActive() ) { + return; + } BVector resWell = resWell_; duneC_.mmv(x, resWell); invDuneD_.mv(resWell, xw);