mirror of
https://github.com/OPM/opm-simulators.git
synced 2024-12-02 05:49:09 -06:00
fix case where wells are shut behind our back
This commit is contained in:
parent
b6c4b2e509
commit
31ac5378cf
@ -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) {
|
||||
|
@ -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:
|
||||
|
@ -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;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user