Merge pull request #4663 from akva2/blackoilwellmodel_more_generic

BlackoilWellModel: move some more code to generic class
This commit is contained in:
Bård Skaflestad 2023-06-22 09:09:46 +02:00 committed by GitHub
commit 06e9247887
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 67 additions and 77 deletions

View File

@ -256,7 +256,9 @@ namespace Opm {
return this->wasDynamicallyShutThisTimeStep(well_index);
});
this->assignWellTracerRates(wsrpt);
const auto& tracerRates = ebosSimulator_.problem().tracerModel().getWellTracerRates();
this->assignWellTracerRates(wsrpt, tracerRates);
BlackoilWellModelGuideRates(*this).assignWellGuideRates(wsrpt, this->reportStepIndex());
this->assignShutConnections(wsrpt, this->reportStepIndex());
@ -323,12 +325,8 @@ namespace Opm {
using PressureMatrix = Dune::BCRSMatrix<Opm::MatrixBlock<double, 1, 1>>;
int numLocalWellsEnd() const;
void addWellPressureEquations(PressureMatrix& jacobian, const BVector& weights,const bool use_well_weights) const;
std::vector<std::vector<int>> getMaxWellConnections() const;
void addWellPressureEquationsStruct(PressureMatrix& jacobian) const;
void initGliftEclWellMap(GLiftEclWells &ecl_well_map);
@ -339,8 +337,6 @@ namespace Opm {
return well_container_;
}
int numLocalNonshutWells() const;
// prototype for assemble function for ASPIN solveLocal()
// will try to merge back to assemble() when done prototyping
void assembleDomain(const int iterationIdx,
@ -512,8 +508,6 @@ namespace Opm {
void computeWellTemperature();
void assignWellTracerRates(data::Wells& wsrpt) const;
int compressedIndexForInterior(int cartesian_cell_idx) const override {
return ebosSimulator_.vanguard().compressedIndexForInterior(cartesian_cell_idx);
}

View File

@ -1349,4 +1349,60 @@ BlackoilWellModelGeneric::getWellsForTesting(const int timeStepIdx,
return {};
}
void
BlackoilWellModelGeneric::
assignWellTracerRates(data::Wells& wsrpt,
const WellTracerRates& wellTracerRates) const
{
if (wellTracerRates.empty())
return; // no tracers
for (const auto& wTR : wellTracerRates) {
std::string wellName = wTR.first.first;
auto xwPos = wsrpt.find(wellName);
if (xwPos == wsrpt.end()) { // No well results.
continue;
}
std::string tracerName = wTR.first.second;
double rate = wTR.second;
xwPos->second.rates.set(data::Rates::opt::tracer, rate, tracerName);
}
}
std::vector<std::vector<int>>
BlackoilWellModelGeneric::
getMaxWellConnections() const
{
std::vector<std::vector<int>> wells;
auto schedule_wells = schedule().getWellsatEnd();
schedule_wells.erase(std::remove_if(schedule_wells.begin(), schedule_wells.end(), not_on_process_), schedule_wells.end());
wells.reserve(schedule_wells.size());
// initialize the additional cell connections introduced by wells.
for ( const auto& well : schedule_wells )
{
std::vector<int> compressed_well_perforations = this->getCellsForConnections(well);
// also include wells with no perforations in case
std::sort(compressed_well_perforations.begin(),
compressed_well_perforations.end());
wells.push_back(compressed_well_perforations);
}
return wells;
}
int BlackoilWellModelGeneric::numLocalWellsEnd() const
{
auto w = schedule().getWellsatEnd();
w.erase(std::remove_if(w.begin(), w.end(), not_on_process_), w.end());
return w.size();
}
int BlackoilWellModelGeneric::numLocalNonshutWells() const
{
return well_container_generic_.size();
}
}

View File

@ -86,6 +86,8 @@ public:
virtual ~BlackoilWellModelGeneric() = default;
int numLocalWells() const;
int numLocalWellsEnd() const;
int numLocalNonshutWells() const;
int numPhases() const;
/// return true if wells are available in the reservoir
@ -382,10 +384,15 @@ protected:
virtual int compressedIndexForInterior(int cartesian_cell_idx) const = 0;
std::vector<int> getCellsForConnections(const Well& well) const;
std::vector<std::vector<int>> getMaxWellConnections() const;
std::vector<std::string> getWellsForTesting(const int timeStepIdx,
const double simulationTime);
using WellTracerRates = std::map<std::pair<std::string, std::string>, double>;
void assignWellTracerRates(data::Wells& wsrpt,
const WellTracerRates& wellTracerRates) const;
Schedule& schedule_;
const SummaryState& summaryState_;
const EclipseState& eclState_;

View File

@ -1330,7 +1330,7 @@ namespace Opm {
template<typename TypeTag>
void
BlackoilWellModel<TypeTag>::
apply( BVector& r) const
apply(BVector& r) const
{
for (auto& well : well_container_) {
well->apply(r);
@ -1462,41 +1462,6 @@ namespace Opm {
}
template<typename TypeTag>
int
BlackoilWellModel<TypeTag>::
numLocalWellsEnd() const
{
auto w = schedule().getWellsatEnd();
w.erase(std::remove_if(w.begin(), w.end(), not_on_process_), w.end());
return w.size();
}
template<typename TypeTag>
std::vector<std::vector<int>>
BlackoilWellModel<TypeTag>::
getMaxWellConnections() const
{
std::vector<std::vector<int>> wells;
auto schedule_wells = schedule().getWellsatEnd();
schedule_wells.erase(std::remove_if(schedule_wells.begin(), schedule_wells.end(), not_on_process_), schedule_wells.end());
wells.reserve(schedule_wells.size());
// initialize the additional cell connections introduced by wells.
for ( const auto& well : schedule_wells )
{
std::vector<int> compressed_well_perforations = this->getCellsForConnections(well);
// also include wells with no perforations in case
std::sort(compressed_well_perforations.begin(),
compressed_well_perforations.end());
wells.push_back(compressed_well_perforations);
}
return wells;
}
template<typename TypeTag>
void
BlackoilWellModel<TypeTag>::
@ -1520,15 +1485,6 @@ namespace Opm {
}
template<typename TypeTag>
int
BlackoilWellModel<TypeTag>::
numLocalNonshutWells() const
{
return well_container_.size();
}
template<typename TypeTag>
void
BlackoilWellModel<TypeTag>::
@ -2311,29 +2267,6 @@ namespace Opm {
template <typename TypeTag>
void
BlackoilWellModel<TypeTag>::
assignWellTracerRates(data::Wells& wsrpt) const
{
const auto & wellTracerRates = ebosSimulator_.problem().tracerModel().getWellTracerRates();
if (wellTracerRates.empty())
return; // no tracers
for (const auto& wTR : wellTracerRates) {
std::string wellName = wTR.first.first;
auto xwPos = wsrpt.find(wellName);
if (xwPos == wsrpt.end()) { // No well results.
continue;
}
std::string tracerName = wTR.first.second;
double rate = wTR.second;
xwPos->second.rates.set(data::Rates::opt::tracer, rate, tracerName);
}
}
template <typename TypeTag>
void
BlackoilWellModel<TypeTag>::