Add Special-Purpose Operation to Reset WellState CTFs

This commit adds a new member function

    WellState::resetConnectionTransFactors

which overwrites the transmissibility factor of 'well_perf_data_'
pertaining to a particular well.  This is to keep the values in
sync following a rescaling operation such as WELPI.
This commit is contained in:
Bård Skaflestad 2020-10-19 23:58:54 +02:00
parent aaca907f77
commit c800c5376d
2 changed files with 54 additions and 4 deletions

View File

@ -27,12 +27,13 @@
#include <opm/simulators/wells/PerforationData.hpp> #include <opm/simulators/wells/PerforationData.hpp>
#include <array> #include <array>
#include <map>
#include <memory>
#include <string>
#include <vector>
#include <cassert> #include <cassert>
#include <cstddef> #include <cstddef>
#include <map>
#include <memory>
#include <stdexcept>
#include <string>
#include <vector>
namespace Opm namespace Opm
{ {
@ -96,6 +97,54 @@ namespace Opm
} }
} }
/// Special purpose method to support dynamically rescaling a well's
/// CTFs through WELPI.
///
/// \param[in] well_index Process-local linear index of single well.
/// Must be in the range 0..numWells()-1.
///
/// \param[in] well_perf_data New perforation data. Only
/// PerforationData::connection_transmissibility_factor actually
/// used (overwrites existing internal values).
void resetConnectionTransFactors(const int well_index,
const std::vector<PerforationData>& well_perf_data)
{
if (this->well_perf_data_[well_index].size() != well_perf_data.size()) {
throw std::invalid_argument {
"Size mismatch for perforation data in well "
+ std::to_string(well_index)
};
}
auto connID = std::size_t{0};
auto dst = this->well_perf_data_[well_index].begin();
for (const auto& src : well_perf_data) {
if (dst->cell_index != src.cell_index) {
throw std::invalid_argument {
"Cell index mismatch in connection "
+ std::to_string(connID)
+ " of well "
+ std::to_string(well_index)
};
}
if (dst->satnum_id != src.satnum_id) {
throw std::invalid_argument {
"Saturation function table mismatch in connection "
+ std::to_string(connID)
+ " of well "
+ std::to_string(well_index)
};
}
dst->connection_transmissibility_factor =
src.connection_transmissibility_factor;
++dst;
++connID;
}
}
/// One bhp pressure per well. /// One bhp pressure per well.
std::vector<double>& bhp() { return bhp_; } std::vector<double>& bhp() { return bhp_; }
const std::vector<double>& bhp() const { return bhp_; } const std::vector<double>& bhp() const { return bhp_; }

View File

@ -64,6 +64,7 @@ namespace Opm
using BaseType :: wellMap; using BaseType :: wellMap;
using BaseType :: numWells; using BaseType :: numWells;
using BaseType :: numPhases; using BaseType :: numPhases;
using BaseType :: resetConnectionTransFactors;
/// Allocate and initialize if wells is non-null. Also tries /// Allocate and initialize if wells is non-null. Also tries
/// to give useful initial values to the bhp(), wellRates() /// to give useful initial values to the bhp(), wellRates()