diff --git a/applications/ebos/eclpeacemanwell.hh b/applications/ebos/eclpeacemanwell.hh index 2d0a324a7..4ca59a9ef 100644 --- a/applications/ebos/eclpeacemanwell.hh +++ b/applications/ebos/eclpeacemanwell.hh @@ -684,6 +684,13 @@ public: { const auto& comm = simulator_.gridView().comm(); + if (dofVariables_.size() == 0) { + std::cout << "Well " << name() << " does not penetrate any active cell." + << " Assuming it to be shut!\n"; + setWellStatus(WellStatus::Shut); + return; + } + // determine the maximum depth of the well over all processes refDepth_ = comm.min(refDepth_); diff --git a/applications/ebos/eclwellmanager.hh b/applications/ebos/eclwellmanager.hh index b82e15eed..d5ad83399 100644 --- a/applications/ebos/eclwellmanager.hh +++ b/applications/ebos/eclwellmanager.hh @@ -107,10 +107,8 @@ public: // the well primarily serves as a placeholder.) The big rest of the well is // specified by the updateWellCompletions_() method auto well = std::make_shared(simulator_); - well->beginSpec(); well->setName(wellName); well->setWellStatus(Well::Shut); - well->endSpec(); wells_.push_back(well); wellNameToIndex_[well->name()] = wells_.size() - 1; @@ -615,8 +613,10 @@ protected: model.clearAuxiliaryModules(); auto wellIt = wells_.begin(); const auto& wellEndIt = wells_.end(); - for (; wellIt != wellEndIt; ++wellIt) + for (; wellIt != wellEndIt; ++wellIt) { (*wellIt)->clear(); + (*wellIt)->beginSpec(); + } ////// // tell the active wells which DOFs they contain @@ -655,10 +655,11 @@ protected: } // register all wells at the model as auxiliary equations - auto wellIt2 = wells.begin(); - const auto& wellEndIt2 = wells.end(); - for (; wellIt2 != wellEndIt2; ++wellIt2) - model.addAuxiliaryModule(*wellIt2); + wellIt = wells_.begin(); + for (; wellIt != wellEndIt; ++wellIt) { + (*wellIt)->endSpec(); + model.addAuxiliaryModule(*wellIt); + } } void computeWellCompletionsMap_(unsigned reportStepIdx, WellCompletionsMap& cartesianIdxToCompletionMap)