addressing review comments

This commit is contained in:
Kai Bao
2019-04-04 15:36:35 +02:00
committed by Bård Skaflestad
parent ca69e2334a
commit b62dc0b5f2
2 changed files with 14 additions and 19 deletions

View File

@@ -428,7 +428,8 @@ namespace Opm {
const int report_step, const int report_step,
WellStateFullyImplicitBlackoil& state ) const; WellStateFullyImplicitBlackoil& state ) const;
bool anyMSWellOpen(const Wells* wells, const int report_step) const; // whether there exists any multisegment well open on this process
bool anyMSWellOpenLocal(const Wells* wells, const int report_step) const;
const Well* getWellEcl(const std::string& well_name) const; const Well* getWellEcl(const std::string& well_name) const;
}; };

View File

@@ -259,7 +259,7 @@ namespace Opm {
well_state_.init(wells(), cellPressures, schedule(), wells_ecl_, timeStepIdx, &previous_well_state_, phase_usage_); well_state_.init(wells(), cellPressures, schedule(), wells_ecl_, timeStepIdx, &previous_well_state_, phase_usage_);
// handling MS well related // handling MS well related
if (param_.use_multisegment_well_&& anyMSWellOpen(wells(), timeStepIdx)) { // if we use MultisegmentWell model if (param_.use_multisegment_well_&& anyMSWellOpenLocal(wells(), timeStepIdx)) { // if we use MultisegmentWell model
well_state_.initWellStateMSWell(wells(), wells_ecl_, timeStepIdx, phase_usage_, &previous_well_state_); well_state_.initWellStateMSWell(wells(), wells_ecl_, timeStepIdx, phase_usage_, &previous_well_state_);
} }
@@ -497,7 +497,7 @@ namespace Opm {
if (nw > 0) { if (nw > 0) {
const auto phaseUsage = phaseUsageFromDeck(eclState()); const auto phaseUsage = phaseUsageFromDeck(eclState());
const size_t numCells = Opm::UgGridHelpers::numCells(grid()); const size_t numCells = Opm::UgGridHelpers::numCells(grid());
const bool handle_ms_well = (param_.use_multisegment_well_ && anyMSWellOpen(wells, report_step)); const bool handle_ms_well = (param_.use_multisegment_well_ && anyMSWellOpenLocal(wells, report_step));
well_state_.resize(wells, wells_ecl_, schedule(), handle_ms_well, report_step, numCells, phaseUsage); // Resize for restart step well_state_.resize(wells, wells_ecl_, schedule(), handle_ms_well, report_step, numCells, phaseUsage); // Resize for restart step
wellsToState(restartValues.wells, phaseUsage, handle_ms_well, report_step, well_state_); wellsToState(restartValues.wells, phaseUsage, handle_ms_well, report_step, well_state_);
previous_well_state_ = well_state_; previous_well_state_ = well_state_;
@@ -1760,7 +1760,7 @@ namespace Opm {
template<typename TypeTag> template<typename TypeTag>
bool bool
BlackoilWellModel<TypeTag>:: BlackoilWellModel<TypeTag>::
anyMSWellOpen(const Wells* wells, const int report_step) const anyMSWellOpenLocal(const Wells* wells, const int report_step) const
{ {
bool any_ms_well_open = false; bool any_ms_well_open = false;
@@ -1770,8 +1770,6 @@ namespace Opm {
const Well* well_ecl = getWellEcl(well_name); const Well* well_ecl = getWellEcl(well_name);
assert(well_ecl);
if (well_ecl->isMultiSegment(report_step) ) { if (well_ecl->isMultiSegment(report_step) ) {
any_ms_well_open = true; any_ms_well_open = true;
break; break;
@@ -1789,20 +1787,16 @@ namespace Opm {
BlackoilWellModel<TypeTag>:: BlackoilWellModel<TypeTag>::
getWellEcl(const std::string& well_name) const getWellEcl(const std::string& well_name) const
{ {
// finding the location of the well in wells_ecl // finding the iterator of the well in wells_ecl
const int nw_wells_ecl = wells_ecl_.size(); auto well_ecl = std::find_if(wells_ecl_.begin(),
int index_well = 0; wells_ecl_.end(),
for (; index_well < nw_wells_ecl; ++index_well) { [&well_name](const Well* elem)->bool {
if (well_name == wells_ecl_[index_well]->name()) { return elem->name() == well_name;
break; });
}
}
if (index_well < nw_wells_ecl) { assert(well_ecl != wells_ecl_.end());
return wells_ecl_[index_well];
} else { return *well_ecl;
return nullptr;
}
} }
} // namespace Opm } // namespace Opm