fix case where wells are shut behind our back

This commit is contained in:
Tor Harald Sandve 2021-08-19 12:15:35 +02:00
parent b6c4b2e509
commit 31ac5378cf
3 changed files with 26 additions and 19 deletions

View File

@ -302,6 +302,11 @@ protected:
if (well.getStatus() == Well::Status::SHUT)
continue;
if (!simulator_.problem().wellModel().hasWell(well.name()))
continue;
const auto& wellPtr = simulator_.problem().wellModel().getWell(well.name());
std::vector<double> wtracer(tr.numTracer());
for (int tIdx =0; tIdx < tr.numTracer(); ++tIdx) {
wtracer[tIdx] = well.getTracerProperties().getConcentration(this->tracerNames_[tr.idx_[tIdx]]);
@ -318,7 +323,7 @@ protected:
cartesianCoordinate[2] = connection.getK();
const size_t cartIdx = simulator_.vanguard().cartesianIndex(cartesianCoordinate);
const int I = this->cartToGlobal_[cartIdx];
Scalar rate = simulator_.problem().wellModel().well(well.name())->volumetricSurfaceRateForConnection(I, tr.phaseIdx_);
Scalar rate = wellPtr->volumetricSurfaceRateForConnection(I, tr.phaseIdx_);
if (rate > 0) {
for (int tIdx =0; tIdx < tr.numTracer(); ++tIdx) {
tr.residual_[tIdx][I][0] -= rate*wtracer[tIdx];
@ -390,6 +395,11 @@ protected:
if (well.getStatus() == Well::Status::SHUT)
continue;
if (!simulator_.problem().wellModel().hasWell(well.name()))
continue;
const auto& wellPtr = simulator_.problem().wellModel().getWell(well.name());
if (!well.isProducer()) //Injection rates already reported during assembly
continue;
@ -406,7 +416,7 @@ protected:
cartesianCoordinate[2] = connection.getK();
const size_t cartIdx = simulator_.vanguard().cartesianIndex(cartesianCoordinate);
const int I = this->cartToGlobal_[cartIdx];
Scalar rate = simulator_.problem().wellModel().well(well.name())->volumetricSurfaceRateForConnection(I, tr.phaseIdx_);
Scalar rate = wellPtr->volumetricSurfaceRateForConnection(I, tr.phaseIdx_);
if (rate < 0) {
rateWellNeg += rate;
for (int tIdx =0; tIdx < tr.numTracer(); ++tIdx) {

View File

@ -210,7 +210,6 @@ namespace Opm {
using WellInterfacePtr = std::shared_ptr<WellInterface<TypeTag> >;
WellInterfacePtr well(const std::string& wellName) const;
using BlackoilWellModelGeneric::initFromRestartFile;
void initFromRestartFile(const RestartValue& restartValues)
@ -279,6 +278,8 @@ namespace Opm {
void initPrimaryVariablesEvaluation() const;
void updateWellControls(DeferredLogger& deferred_logger, const bool checkGroupControls);
WellInterfacePtr getWell(const std::string& well_name) const;
bool hasWell(const std::string& well_name) const;
void initGliftEclWellMap(GLiftEclWells &ecl_well_map);
protected:

View File

@ -511,22 +511,6 @@ namespace Opm {
template<typename TypeTag>
typename BlackoilWellModel<TypeTag>::WellInterfacePtr
BlackoilWellModel<TypeTag>::
well(const std::string& wellName) const
{
for (const auto& well : well_container_) {
if (well->name() == wellName) {
return well;
}
}
OPM_THROW(std::invalid_argument, "The well with name " + wellName + " is not in the well Container");
return nullptr;
}
template<typename TypeTag>
void
BlackoilWellModel<TypeTag>::
@ -1645,6 +1629,18 @@ namespace Opm {
return *well;
}
template<typename TypeTag>
bool
BlackoilWellModel<TypeTag>::
hasWell(const std::string& well_name) const
{
return std::any_of(well_container_.begin(), well_container_.end(),
[&well_name](const WellInterfacePtr& elem) -> bool
{
return elem->name() == well_name;
});
}