Added BlackoilWellModel::getLocalNonshutWells to reduce code duplication.

This commit is contained in:
Markus Blatt
2020-10-09 15:09:28 +02:00
parent 406feea8e7
commit ba1bc7c23c
2 changed files with 18 additions and 13 deletions

View File

@@ -331,6 +331,12 @@ namespace Opm {
const std::string &msg,
Opm::DeferredLogger& deferred_logger) const;
/// \brief Get the wells of our partition that are not shut.
/// \param timeStepIdx The index of the time step.
/// \param[out] globalNumWells the number of wells globally.
std::vector< Well > getLocalNonshutWells(const int timeStepIdx,
int& globalNumWells) const;
// compute the well fluxes and assemble them in to the reservoir equations as source terms
// and in the well equations.
void assemble(const int iterationIdx,

View File

@@ -214,7 +214,16 @@ namespace Opm {
}
template<typename TypeTag>
std::vector< Well >
BlackoilWellModel<TypeTag>::
getLocalNonshutWells(const int timeStepIdx, int& globalNumWells) const
{
auto w = schedule().getWells(timeStepIdx);
globalNumWells = w.size();
w.erase(std::remove_if(w.begin(), w.end(), is_shut_or_defunct_), w.end());
return w;
}
template<typename TypeTag>
void
@@ -228,12 +237,7 @@ namespace Opm {
const auto& summaryState = ebosSimulator_.vanguard().summaryState();
int globalNumWells = 0;
// Make wells_ecl_ contain only this partition's non-shut wells.
{
auto w = schedule().getWells(timeStepIdx);
globalNumWells = w.size();
w.erase(std::remove_if(w.begin(), w.end(), is_shut_or_defunct_), w.end());
wells_ecl_.swap(w);
}
wells_ecl_ = getLocalNonshutWells(timeStepIdx, globalNumWells);
initializeWellPerfData();
// Wells are active if they are active wells on at least
@@ -552,12 +556,7 @@ namespace Opm {
const auto& summaryState = ebosSimulator_.vanguard().summaryState();
int globalNumWells = 0;
// Make wells_ecl_ contain only this partition's non-shut wells.
{
auto w = schedule().getWells(report_step);
globalNumWells = w.size();
w.erase(std::remove_if(w.begin(), w.end(), is_shut_or_defunct_), w.end());
wells_ecl_.swap(w);
}
wells_ecl_ = getLocalNonshutWells(report_step, globalNumWells);
initializeWellPerfData();