mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
[refactor] Use well_container and PerforationData for tracers
This saves some (expensive?) lookups that already have been done in the well model. We had to make the well_container accessible from the well model for this. Using the perforation data will automatically make sure that the perforations are not shut and reside on this process in a parallel run.
This commit is contained in:
parent
be787b8e14
commit
d4ab9ea4b1
@ -291,38 +291,21 @@ protected:
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Wells terms
|
// Wells terms
|
||||||
const int episodeIdx = simulator_.episodeIndex();
|
const auto& wellPtrs = simulator_.problem().wellModel().localNonshutWells();
|
||||||
const auto& wells = simulator_.vanguard().schedule().getWells(episodeIdx);
|
for (const auto& wellPtr : wellPtrs) {
|
||||||
for (const auto& well : wells) {
|
const auto& well = wellPtr->wellEcl();
|
||||||
|
|
||||||
for (int tIdx =0; tIdx < tr.numTracer(); ++tIdx) {
|
for (int tIdx =0; tIdx < tr.numTracer(); ++tIdx) {
|
||||||
this->wellTracerRate_[std::make_pair(well.name(),this->tracerNames_[tr.idx_[tIdx]])] = 0.0;
|
this->wellTracerRate_[std::make_pair(well.name(),this->tracerNames_[tr.idx_[tIdx]])] = 0.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (well.getStatus() == Well::Status::SHUT)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (!simulator_.problem().wellModel().hasWell(well.name()))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
const auto& wellPtr = simulator_.problem().wellModel().getWell(well.name());
|
|
||||||
|
|
||||||
std::vector<double> wtracer(tr.numTracer());
|
std::vector<double> wtracer(tr.numTracer());
|
||||||
for (int tIdx =0; tIdx < tr.numTracer(); ++tIdx) {
|
for (int tIdx =0; tIdx < tr.numTracer(); ++tIdx) {
|
||||||
wtracer[tIdx] = well.getTracerProperties().getConcentration(this->tracerNames_[tr.idx_[tIdx]]);
|
wtracer[tIdx] = well.getTracerProperties().getConcentration(this->tracerNames_[tr.idx_[tIdx]]);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::array<int, 3> cartesianCoordinate;
|
for (auto& perfData : wellPtr->perforationData()) {
|
||||||
for (auto& connection : well.getConnections()) {
|
auto I = perfData.cell_index;
|
||||||
|
|
||||||
if (connection.state() == Connection::State::SHUT)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
cartesianCoordinate[0] = connection.getI();
|
|
||||||
cartesianCoordinate[1] = connection.getJ();
|
|
||||||
cartesianCoordinate[2] = connection.getK();
|
|
||||||
const size_t cartIdx = simulator_.vanguard().cartesianIndex(cartesianCoordinate);
|
|
||||||
const int I = this->cartToGlobal_[cartIdx];
|
|
||||||
Scalar rate = wellPtr->volumetricSurfaceRateForConnection(I, tr.phaseIdx_);
|
Scalar rate = wellPtr->volumetricSurfaceRateForConnection(I, tr.phaseIdx_);
|
||||||
if (rate > 0) {
|
if (rate > 0) {
|
||||||
for (int tIdx =0; tIdx < tr.numTracer(); ++tIdx) {
|
for (int tIdx =0; tIdx < tr.numTracer(); ++tIdx) {
|
||||||
@ -388,34 +371,17 @@ protected:
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Store _producer_ tracer rate for reporting
|
// Store _producer_ tracer rate for reporting
|
||||||
const int episodeIdx = simulator_.episodeIndex();
|
const auto& wellPtrs = simulator_.problem().wellModel().localNonshutWells();
|
||||||
const auto& wells = simulator_.vanguard().schedule().getWells(episodeIdx);
|
for (const auto& wellPtr : wellPtrs) {
|
||||||
for (const auto& well : wells) {
|
const auto& well = wellPtr->wellEcl();
|
||||||
|
|
||||||
if (well.getStatus() == Well::Status::SHUT)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (!simulator_.problem().wellModel().hasWell(well.name()))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
const auto& wellPtr = simulator_.problem().wellModel().getWell(well.name());
|
|
||||||
|
|
||||||
if (!well.isProducer()) //Injection rates already reported during assembly
|
if (!well.isProducer()) //Injection rates already reported during assembly
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
Scalar rateWellPos = 0.0;
|
Scalar rateWellPos = 0.0;
|
||||||
Scalar rateWellNeg = 0.0;
|
Scalar rateWellNeg = 0.0;
|
||||||
std::array<int, 3> cartesianCoordinate;
|
for (auto& perfData : wellPtr->perforationData()) {
|
||||||
for (auto& connection : well.getConnections()) {
|
const int I = perfData.cell_index;
|
||||||
|
|
||||||
if (connection.state() == Connection::State::SHUT)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
cartesianCoordinate[0] = connection.getI();
|
|
||||||
cartesianCoordinate[1] = connection.getJ();
|
|
||||||
cartesianCoordinate[2] = connection.getK();
|
|
||||||
const size_t cartIdx = simulator_.vanguard().cartesianIndex(cartesianCoordinate);
|
|
||||||
const int I = this->cartToGlobal_[cartIdx];
|
|
||||||
Scalar rate = wellPtr->volumetricSurfaceRateForConnection(I, tr.phaseIdx_);
|
Scalar rate = wellPtr->volumetricSurfaceRateForConnection(I, tr.phaseIdx_);
|
||||||
if (rate < 0) {
|
if (rate < 0) {
|
||||||
rateWellNeg += rate;
|
rateWellNeg += rate;
|
||||||
@ -490,7 +456,7 @@ protected:
|
|||||||
// Since oil or gas tracers appears in dual compositions when VAPOIL respectively DISGAS
|
// Since oil or gas tracers appears in dual compositions when VAPOIL respectively DISGAS
|
||||||
// is active, the template argument is intended to support future extension to these
|
// is active, the template argument is intended to support future extension to these
|
||||||
// scenarios by supplying an extended vector type.
|
// scenarios by supplying an extended vector type.
|
||||||
|
|
||||||
template <typename TV>
|
template <typename TV>
|
||||||
struct TracerBatch {
|
struct TracerBatch {
|
||||||
std::vector<int> idx_;
|
std::vector<int> idx_;
|
||||||
|
@ -292,6 +292,12 @@ namespace Opm {
|
|||||||
|
|
||||||
void initGliftEclWellMap(GLiftEclWells &ecl_well_map);
|
void initGliftEclWellMap(GLiftEclWells &ecl_well_map);
|
||||||
|
|
||||||
|
/// \brief Get list of local nonshut wells
|
||||||
|
const std::vector<WellInterfacePtr>& localNonshutWells()
|
||||||
|
{
|
||||||
|
return well_container_;
|
||||||
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Simulator& ebosSimulator_;
|
Simulator& ebosSimulator_;
|
||||||
|
|
||||||
|
@ -98,6 +98,11 @@ WellInterfaceGeneric::WellInterfaceGeneric(const Well& well,
|
|||||||
wsolvent_ = 0.0;
|
wsolvent_ = 0.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const std::vector<PerforationData>& WellInterfaceGeneric::perforationData() const
|
||||||
|
{
|
||||||
|
return *perf_data_;
|
||||||
|
}
|
||||||
|
|
||||||
const std::string& WellInterfaceGeneric::name() const
|
const std::string& WellInterfaceGeneric::name() const
|
||||||
{
|
{
|
||||||
return well_ecl_.name();
|
return well_ecl_.name();
|
||||||
|
@ -60,6 +60,9 @@ public:
|
|||||||
const int index_of_well,
|
const int index_of_well,
|
||||||
const std::vector<PerforationData>& perf_data);
|
const std::vector<PerforationData>& perf_data);
|
||||||
|
|
||||||
|
/// \brief Get the perforations of the well
|
||||||
|
const std::vector<PerforationData>& perforationData() const;
|
||||||
|
|
||||||
/// Well name.
|
/// Well name.
|
||||||
const std::string& name() const;
|
const std::string& name() const;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user