WellFilterCake: make stateful

This commit is contained in:
Arne Morten Kvarving 2023-07-07 12:22:17 +02:00
parent dcf8a444fd
commit 60b92d02eb
7 changed files with 48 additions and 43 deletions

View File

@ -1428,14 +1428,13 @@ void BlackoilWellModelGeneric::updateFiltrationParticleVolume(const double dt,
{
for (auto& well : this->well_container_generic_) {
if (well->isInjector() && well->wellEcl().getFilterConc() > 0.) {
auto &values = this->filtration_particle_volume_[well->name()];
const auto& ws = this->wellState().well(well->indexOfWell());
if (values.empty()) {
values.assign(ws.perf_data.size(), 0.); // initializing to be zero
}
WellFilterCake::
updateFiltrationParticleVolume(*well, dt, water_index,
this->wellState(), values);
auto fc = this->filter_cake_
.emplace(std::piecewise_construct,
std::forward_as_tuple(well->name()),
std::tuple{});
fc.first->second.updateFiltrationParticleVolume(*well, dt, water_index,
this->wellState());
}
}
}
@ -1453,14 +1452,10 @@ void BlackoilWellModelGeneric::updateInjFCMult(DeferredLogger& deferred_logger)
{
for (auto& well : this->well_container_generic_) {
if (well->isInjector()) {
const auto it = this->filtration_particle_volume_.find(well->name());
if (it != this->filtration_particle_volume_.end()) {
const auto& filtration_particle_volume = it->second;
std::vector<double> multipliers(well->numPerfs(), 0.0);
WellFilterCake::
updateInjFCMult(multipliers, *well,
filtration_particle_volume, deferred_logger);
well->updateFilterCakeMultipliers(multipliers);
const auto it = filter_cake_.find(well->name());
if (it != filter_cake_.end()) {
it->second.updateInjFCMult(*well, deferred_logger);
well->updateFilterCakeMultipliers(it->second.multipliers());
}
}
}

View File

@ -31,6 +31,7 @@
#include <opm/simulators/utils/DeferredLoggingErrorHelpers.hpp>
#include <opm/simulators/wells/PerforationData.hpp>
#include <opm/simulators/wells/WellFilterCake.hpp>
#include <opm/simulators/wells/WellProdIndexCalculator.hpp>
#include <opm/simulators/wells/WGState.hpp>
@ -441,8 +442,8 @@ protected:
// previous injection multiplier, it is used in the injection multiplier calculation for WINJMULT keyword
std::unordered_map<std::string, std::vector<double>> prev_inj_multipliers_;
// the volume of the filtration particles during water injection
std::unordered_map<std::string, std::vector<double>> filtration_particle_volume_;
// Handling for filter cake injection multipliers
std::unordered_map<std::string, WellFilterCake> filter_cake_;
/*
The various wellState members should be accessed and modified
@ -461,7 +462,6 @@ protected:
std::map<std::string, std::string> switched_prod_groups_;
std::map<std::pair<std::string, Opm::Phase>, std::string> switched_inj_groups_;
private:
WellInterfaceGeneric* getGenWell(const std::string& well_name);
};

View File

@ -205,7 +205,6 @@ namespace Opm {
// playing it safe by extending the scope a bit.
OPM_BEGIN_PARALLEL_TRY_CATCH();
{
// The well state initialize bhp with the cell pressure in the top cell.
// We must therefore provide it with updated cell pressures
this->initializeWellPerfData();

View File

@ -20,10 +20,12 @@
#include <config.h>
#include <opm/simulators/wells/WellFilterCake.hpp>
#include <opm/input/eclipse/Schedule/Well/Well.hpp>
#include <opm/input/eclipse/Schedule/Well/WellConnections.hpp>
#include <opm/simulators/utils/DeferredLoggingErrorHelpers.hpp>
#include <opm/simulators/wells/PerforationData.hpp>
#include <opm/simulators/wells/WellInterfaceGeneric.hpp>
#include <opm/simulators/wells/WellState.hpp>
@ -37,13 +39,17 @@ void WellFilterCake::
updateFiltrationParticleVolume(const WellInterfaceGeneric& well,
const double dt,
const std::size_t water_index,
const WellState& well_state,
std::vector<double>& filtration_particle_volume)
const WellState& well_state)
{
if (!well.isInjector()) {
return;
}
if (filtration_particle_volume_.empty()) {
const auto& ws = well_state.well(well.indexOfWell());
filtration_particle_volume_.assign(ws.perf_data.size(), 0.); // initializing to be zero
}
const auto injectorType = well.wellEcl().injectorType();
if (injectorType != InjectorType::WATER) {
return;
@ -62,16 +68,18 @@ updateFiltrationParticleVolume(const WellInterfaceGeneric& well,
for (int perf = 0; perf < well.numPerfs(); ++perf) {
// not considering the production water
const double water_rates = std::max(0., connection_rates[perf * np + water_index]);
filtration_particle_volume[perf] += water_rates * conc * dt;
filtration_particle_volume_[perf] += water_rates * conc * dt;
}
}
void WellFilterCake::
updateInjFCMult(std::vector<double>& inj_fc_multiplier,
const WellInterfaceGeneric& well,
const std::vector<double>& filtration_particle_volume,
updateInjFCMult(const WellInterfaceGeneric& well,
DeferredLogger& deferred_logger)
{
if (inj_fc_multiplier_.empty()) {
inj_fc_multiplier_.resize(well.numPerfs(), 1.0);
}
for (int perf = 0; perf < well.numPerfs(); ++perf) {
const auto perf_ecl_index = well.perforationData()[perf].ecl_index;
const auto& connections = well.wellEcl().getConnections();
@ -87,7 +95,7 @@ updateInjFCMult(std::vector<double>& inj_fc_multiplier,
const double K = connection.Kh() / connection.connectionLength();
const double factor = filter_cake.sf_multiplier;
// the thickness of the filtration cake
const double thickness = filtration_particle_volume[perf] / (area * (1. - poro));
const double thickness = filtration_particle_volume_[perf] / (area * (1. - poro));
double skin_factor = 0.;
switch (filter_cake.geometry) {
@ -113,12 +121,11 @@ updateInjFCMult(std::vector<double>& inj_fc_multiplier,
// compute a multiplier for the well connection transmissibility
const auto denom = std::log(cr0 / std::min(crw, cr0)) + cskinfactor;
const auto denom2 = denom + skin_factor;
inj_fc_multiplier[perf] = denom / denom2;
inj_fc_multiplier_[perf] = denom / denom2;
} else {
inj_fc_multiplier[perf] = 1.0;
inj_fc_multiplier_[perf] = 1.0;
}
}
}
} // namespace Opm

View File

@ -34,17 +34,24 @@ class WellFilterCake {
public:
//! \brief Update the water injection volume.
//! \details Used for calculation related to cake filtration due to injection activity.
static void updateFiltrationParticleVolume(const WellInterfaceGeneric& well,
const double dt,
const std::size_t water_index,
const WellState& well_state,
std::vector<double>& filtration_particle_volume);
void updateFiltrationParticleVolume(const WellInterfaceGeneric& well,
const double dt,
const std::size_t water_index,
const WellState& well_state);
//! \brief Update the multiplier for well transmissbility due to cake filtration.
static void updateInjFCMult(std::vector<double>& inj_fc_multiplier,
const WellInterfaceGeneric& well,
const std::vector<double>& filtration_particle_volume,
DeferredLogger& deferred_logger);
void updateInjFCMult(const WellInterfaceGeneric& well,
DeferredLogger& deferred_logger);
//! \brief Returns a const-ref to multipliers.
const std::vector<double>& multipliers() const
{
return inj_fc_multiplier_;
}
private:
std::vector<double> filtration_particle_volume_; //!<// Volume of filtration particles during water injection
std::vector<double> inj_fc_multiplier_; //!< Multiplier due to injection filtration cake
};
}

View File

@ -98,9 +98,6 @@ WellInterfaceGeneric::WellInterfaceGeneric(const Well& well,
saturation_table_number_[perf] = pd.satnum_id;
++perf;
}
if (this->isInjector()) {
inj_fc_multiplier_.resize(number_of_perforations_, 1.0);
}
}
// initialization of the completions mapping

View File

@ -1268,7 +1268,7 @@ namespace Opm
}
}
if (this->isInjector()) {
if (this->isInjector() && !this->inj_fc_multiplier_.empty()) {
const auto perf_ecl_index = this->perforationData()[perf].ecl_index;
const auto& connections = this->well_ecl_.getConnections();
const auto& connection = connections[perf_ecl_index];