Use WellContainer for perf water velocity

This commit is contained in:
Joakim Hove
2021-06-03 13:39:51 +02:00
parent a2009b1189
commit 104036d4b8
3 changed files with 13 additions and 22 deletions

View File

@@ -1304,7 +1304,7 @@ namespace Opm
// other primary variables related to polymer injectivity study
if constexpr (Base::has_polymermw) {
if (this->isInjector()) {
auto * perf_water_velocity = well_state.perfWaterVelocity(this->index_of_well_);
auto& perf_water_velocity = well_state.perfWaterVelocity(this->index_of_well_);
auto& perf_skin_pressure = well_state.perfSkinPressure(this->index_of_well_);
for (int perf = 0; perf < number_of_perforations_; ++perf) {
perf_water_velocity[perf] = primary_variables_[Bhp + 1 + perf];
@@ -2832,7 +2832,7 @@ namespace Opm
// other primary variables related to polymer injection
if constexpr (Base::has_polymermw) {
if (this->isInjector()) {
const auto * water_velocity = well_state.perfWaterVelocity(this->index_of_well_);
const auto& water_velocity = well_state.perfWaterVelocity(this->index_of_well_);
const auto& skin_pressure = well_state.perfSkinPressure(this->index_of_well_);
for (int perf = 0; perf < number_of_perforations_; ++perf) {
primary_variables_[Bhp + 1 + perf] = water_velocity[perf];
@@ -3201,7 +3201,7 @@ namespace Opm
{
if constexpr (Base::has_polymermw) {
if (this->isInjector()) {
auto * perf_water_throughput = well_state.perfThroughput(this->index_of_well_);
auto& perf_water_throughput = well_state.perfThroughput(this->index_of_well_);
for (int perf = 0; perf < number_of_perforations_; ++perf) {
const double perf_water_vel = primary_variables_[Bhp + 1 + perf];
// we do not consider the formation damage due to water flowing from reservoir into wellbore
@@ -3262,7 +3262,7 @@ namespace Opm
const EvalWell eq_wat_vel = primary_variables_evaluation_[wat_vel_index] - water_velocity;
resWell_[0][wat_vel_index] = eq_wat_vel.value();
const auto * perf_water_throughput = well_state.perfThroughput(this->index_of_well_);
const auto& perf_water_throughput = well_state.perfThroughput(this->index_of_well_);
const double throughput = perf_water_throughput[perf];
const int pskin_index = Bhp + 1 + number_of_perforations_ + perf;
@@ -3441,7 +3441,7 @@ namespace Opm
const int wat_vel_index = Bhp + 1 + perf;
const EvalWell water_velocity = primary_variables_evaluation_[wat_vel_index];
if (water_velocity > 0.) { // injecting
const auto * perf_water_throughput = well_state.perfThroughput(this->index_of_well_);
const auto& perf_water_throughput = well_state.perfThroughput(this->index_of_well_);
const double throughput = perf_water_throughput[perf];
const EvalWell molecular_weight = wpolymermw(throughput, water_velocity, deferred_logger);
cq_s_polymw *= molecular_weight;

View File

@@ -43,6 +43,7 @@ void WellState::base_init(const std::vector<double>& cellPressures,
this->perfpress_.clear();
this->perf_skin_pressure_.clear();
this->perf_water_throughput_.clear();
this->perf_water_velocity_.clear();
this->perfrates_.clear();
this->status_.clear();
this->well_perf_data_.clear();
@@ -104,6 +105,7 @@ void WellState::initSingleWell(const std::vector<double>& cellPressures,
this->perfpress_.add(well.name(), std::vector<double>(num_perf_this_well, -1e100));
this->perfrates_.add(well.name(), std::vector<double>(num_perf_this_well, 0));
this->perf_skin_pressure_.add(well.name(), std::vector<double>(num_perf_this_well, 0));
this->perf_water_velocity_.add(well.name(), std::vector<double>(num_perf_this_well, 0));
this->perf_water_throughput_.add(well.name(), std::vector<double>(num_perf_this_well, 0));
this->bhp_.add(well.name(), 0.0);
this->thp_.add(well.name(), 0.0);
@@ -283,10 +285,6 @@ void WellState::init(const std::vector<double>& cellPressures,
perfphaserates_.clear();
perfphaserates_.resize(nperf * this->numPhases(), 0.0);
// these are only used to monitor the injectivity
perf_water_velocity_.clear();
perf_water_velocity_.resize(nperf, 0.0);
first_perf_index_.resize(nw, 0);
first_perf_index_[0] = 0;
for (int w = 0; w < nw; ++w) {
@@ -481,14 +479,7 @@ void WellState::init(const std::vector<double>& cellPressures,
if (pu.has_polymermw) {
if (global_num_perf_same)
{
auto * velocity_target = this->perfWaterVelocity(newIndex);
const auto * velocity_src = prevState->perfWaterVelocity(oldIndex);
for (int perf = 0; perf < num_perf_this_well; ++perf)
{
velocity_target[ perf ] = velocity_src[perf];
}
this->perf_water_velocity_.copy_welldata(prevState->perf_water_velocity_, wname);
this->perf_skin_pressure_.copy_welldata(prevState->perf_skin_pressure_, wname);
this->perf_water_throughput_.copy_welldata(prevState->perf_water_throughput_, wname);
}

View File

@@ -274,12 +274,12 @@ public:
return perf_skin_pressure_[well_index];
}
double * perfWaterVelocity(std::size_t well_index) {
return &perf_water_velocity_[this->first_perf_index_[well_index]];
std::vector<double>& perfWaterVelocity(std::size_t well_index) {
return perf_water_velocity_[well_index];
}
const double * perfWaterVelocity(std::size_t well_index) const {
return &perf_water_velocity_[this->first_perf_index_[well_index]];
const std::vector<double>& perfWaterVelocity(std::size_t well_index) const {
return perf_water_velocity_[well_index];
}
template<class Comm>
@@ -469,7 +469,7 @@ private:
// it will only be used for injectors to check the injectivity
// water velocity of perforation
std::vector<double> perf_water_velocity_;
WellContainer<std::vector<double>> perf_water_velocity_;
// phase rates under reservoir condition for wells
// or voidage phase rates