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

View File

@ -31,6 +31,7 @@
#include <opm/simulators/utils/DeferredLoggingErrorHelpers.hpp> #include <opm/simulators/utils/DeferredLoggingErrorHelpers.hpp>
#include <opm/simulators/wells/PerforationData.hpp> #include <opm/simulators/wells/PerforationData.hpp>
#include <opm/simulators/wells/WellFilterCake.hpp>
#include <opm/simulators/wells/WellProdIndexCalculator.hpp> #include <opm/simulators/wells/WellProdIndexCalculator.hpp>
#include <opm/simulators/wells/WGState.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 // 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_; std::unordered_map<std::string, std::vector<double>> prev_inj_multipliers_;
// the volume of the filtration particles during water injection // Handling for filter cake injection multipliers
std::unordered_map<std::string, std::vector<double>> filtration_particle_volume_; std::unordered_map<std::string, WellFilterCake> filter_cake_;
/* /*
The various wellState members should be accessed and modified 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::string, std::string> switched_prod_groups_;
std::map<std::pair<std::string, Opm::Phase>, std::string> switched_inj_groups_; std::map<std::pair<std::string, Opm::Phase>, std::string> switched_inj_groups_;
private: private:
WellInterfaceGeneric* getGenWell(const std::string& well_name); WellInterfaceGeneric* getGenWell(const std::string& well_name);
}; };

View File

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

View File

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

View File

@ -34,17 +34,24 @@ class WellFilterCake {
public: public:
//! \brief Update the water injection volume. //! \brief Update the water injection volume.
//! \details Used for calculation related to cake filtration due to injection activity. //! \details Used for calculation related to cake filtration due to injection activity.
static void updateFiltrationParticleVolume(const WellInterfaceGeneric& well, void updateFiltrationParticleVolume(const WellInterfaceGeneric& well,
const double dt, const double dt,
const std::size_t water_index, const std::size_t water_index,
const WellState& well_state, const WellState& well_state);
std::vector<double>& filtration_particle_volume);
//! \brief Update the multiplier for well transmissbility due to cake filtration. //! \brief Update the multiplier for well transmissbility due to cake filtration.
static void updateInjFCMult(std::vector<double>& inj_fc_multiplier, void updateInjFCMult(const WellInterfaceGeneric& well,
const WellInterfaceGeneric& well,
const std::vector<double>& filtration_particle_volume,
DeferredLogger& deferred_logger); 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; saturation_table_number_[perf] = pd.satnum_id;
++perf; ++perf;
} }
if (this->isInjector()) {
inj_fc_multiplier_.resize(number_of_perforations_, 1.0);
}
} }
// initialization of the completions mapping // 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 perf_ecl_index = this->perforationData()[perf].ecl_index;
const auto& connections = this->well_ecl_.getConnections(); const auto& connections = this->well_ecl_.getConnections();
const auto& connection = connections[perf_ecl_index]; const auto& connection = connections[perf_ecl_index];