Skip to content

Commit 4e34efb

Browse files
committed
using the converting from scalar to DyanmicEvaluation
1 parent e8473f2 commit 4e34efb

File tree

3 files changed

+27
-26
lines changed

3 files changed

+27
-26
lines changed

opm/simulators/wells/StandardWellEval.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,11 @@ typename StandardWellEval<FluidSystem,Indices>::EvalWell
6060
StandardWellEval<FluidSystem,Indices>::
6161
extendEval(const Eval& in) const
6262
{
63-
EvalWell out(primary_variables_.numWellEq() + Indices::numEq, in.value());
64-
for(int eqIdx = 0; eqIdx < Indices::numEq;++eqIdx) {
65-
out.setDerivative(eqIdx, in.derivative(eqIdx));
63+
EvalWell out(in.value());
64+
// total number of equations/derivatives (well + reservoir)
65+
const int totalNumEq = primary_variables_.numWellEq() + Indices::numEq;
66+
for(int eqIdx = 0; eqIdx < Indices::numEq; ++eqIdx) {
67+
out.setDerivative(eqIdx, in.derivative(eqIdx), totalNumEq);
6668
}
6769
return out;
6870
}

opm/simulators/wells/StandardWellPrimaryVariables.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,11 @@ template<class FluidSystem, class Indices>
9999
void StandardWellPrimaryVariables<FluidSystem,Indices>::
100100
setEvaluationsFromValues()
101101
{
102+
// total number of equations/derivatives (well + reservoir)
103+
const int totalNumEq = numWellEq_ + Indices::numEq;
102104
for (int eqIdx = 0; eqIdx < numWellEq_; ++eqIdx) {
103105
evaluation_[eqIdx] =
104-
EvalWell::createVariable(numWellEq_ + Indices::numEq,
106+
EvalWell::createVariable(totalNumEq,
105107
value_[eqIdx],
106108
Indices::numEq + eqIdx);
107109

@@ -113,7 +115,7 @@ void StandardWellPrimaryVariables<FluidSystem,Indices>::
113115
resize(const int numWellEq)
114116
{
115117
value_.resize(numWellEq, 0.0);
116-
evaluation_.resize(numWellEq, EvalWell{numWellEq + Indices::numEq, 0.0});
118+
evaluation_.resize(numWellEq, {0.0});
117119
numWellEq_ = numWellEq;
118120
}
119121

@@ -468,7 +470,7 @@ StandardWellPrimaryVariables<FluidSystem,Indices>::
468470
volumeFraction(const int compIdx) const
469471
{
470472
if (FluidSystem::numActivePhases() == 1) {
471-
return EvalWell(numWellEq_ + Indices::numEq, 1.0);
473+
return 1.0;
472474
}
473475

474476
if (has_gfrac_variable && compIdx == FluidSystem::canonicalToActiveCompIdx(FluidSystem::gasCompIdx)) {
@@ -486,7 +488,7 @@ volumeFraction(const int compIdx) const
486488
}
487489
// Compute the Oil fraction if oil is present
488490
// or the WATER fraction for a gas-water case
489-
EvalWell well_fraction(numWellEq_ + Indices::numEq, 1.0);
491+
EvalWell well_fraction{1.0};
490492
if (has_wfrac_variable && FluidSystem::phaseIsActive(FluidSystem::oilPhaseIdx)) {
491493
well_fraction -= evaluation_[WFrac];
492494
}
@@ -518,7 +520,7 @@ typename StandardWellPrimaryVariables<FluidSystem,Indices>::EvalWell
518520
StandardWellPrimaryVariables<FluidSystem,Indices>::
519521
surfaceVolumeFraction(const int compIdx) const
520522
{
521-
EvalWell sum_volume_fraction_scaled(numWellEq_ + Indices::numEq, 0.);
523+
EvalWell sum_volume_fraction_scaled{0.};
522524
for (int idx = 0; idx < well_.numConservationQuantities(); ++idx) {
523525
sum_volume_fraction_scaled += this->volumeFractionScaled(idx);
524526
}

opm/simulators/wells/StandardWell_impl.hpp

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -391,9 +391,9 @@ namespace Opm
391391
auto& perf_rates = perf_data.phase_rates;
392392
for (int perf = 0; perf < this->number_of_local_perforations_; ++perf) {
393393
// Calculate perforation quantities.
394-
std::vector<EvalWell> cq_s(this->num_conservation_quantities_, {this->primary_variables_.numWellEq() + Indices::numEq, 0.0});
395-
EvalWell water_flux_s{this->primary_variables_.numWellEq() + Indices::numEq, 0.0};
396-
EvalWell cq_s_zfrac_effective{this->primary_variables_.numWellEq() + Indices::numEq, 0.0};
394+
std::vector<EvalWell> cq_s(this->num_conservation_quantities_, 0.0);
395+
EvalWell water_flux_s{0.0};
396+
EvalWell cq_s_zfrac_effective{0.0};
397397
calculateSinglePerf(simulator, perf, well_state, connectionRates,
398398
cq_s, water_flux_s, cq_s_zfrac_effective, deferred_logger);
399399

@@ -451,7 +451,7 @@ namespace Opm
451451
for (int componentIdx = 0; componentIdx < numWellConservationEq; ++componentIdx) {
452452
// TODO: following the development in MSW, we need to convert the volume of the wellbore to be surface volume
453453
// since all the rates are under surface condition
454-
EvalWell resWell_loc(this->primary_variables_.numWellEq() + Indices::numEq, 0.0);
454+
EvalWell resWell_loc(0.0);
455455
if (FluidSystem::numActivePhases() > 1) {
456456
assert(dt > 0);
457457
resWell_loc += (this->primary_variables_.surfaceVolumeFraction(componentIdx) -
@@ -506,7 +506,7 @@ namespace Opm
506506
const EvalWell& bhp = this->primary_variables_.eval(Bhp);
507507
const int cell_idx = this->well_cells_[perf];
508508
const auto& intQuants = simulator.model().intensiveQuantities(cell_idx, /*timeIdx=*/ 0);
509-
std::vector<EvalWell> mob(this->num_conservation_quantities_, {this->primary_variables_.numWellEq() + Indices::numEq, 0.});
509+
std::vector<EvalWell> mob(this->num_conservation_quantities_, {0.});
510510
getMobility(simulator, perf, mob, deferred_logger);
511511

512512
PerforationRates<Scalar> perf_rates;
@@ -698,7 +698,7 @@ namespace Opm
698698
// as a result, the polymer and water share the same viscosity
699699
if constexpr (!Base::has_polymermw) {
700700
if constexpr (std::is_same_v<Value, Scalar>) {
701-
std::vector<EvalWell> mob_eval(this->num_conservation_quantities_, {this->primary_variables_.numWellEq() + Indices::numEq, 0.});
701+
std::vector<EvalWell> mob_eval(this->num_conservation_quantities_, 0.);
702702
for (std::size_t i = 0; i < mob.size(); ++i) {
703703
mob_eval[i].setValue(mob[i]);
704704
}
@@ -1899,7 +1899,7 @@ namespace Opm
18991899
const bool allow_cf = this->getAllowCrossFlow() || openCrossFlowAvoidSingularity(simulator);
19001900
const EvalWell& bhp = this->primary_variables_.eval(Bhp);
19011901

1902-
std::vector<EvalWell> cq_s(this->num_conservation_quantities_, {this->primary_variables_.numWellEq() + Indices::numEq, 0.});
1902+
std::vector<EvalWell> cq_s(this->num_conservation_quantities_, 0.);
19031903
PerforationRates<Scalar> perf_rates;
19041904
Scalar trans_mult = simulator.problem().template wellTransMultiplier<Scalar>(int_quant, cell_idx);
19051905
const auto& wellstate_nupcol = simulator.problem().wellModel().nupcolWellState().well(this->index_of_well_);
@@ -1974,10 +1974,9 @@ namespace Opm
19741974
deferred_logger);
19751975
}
19761976
const auto& water_table_func = PolymerModule::getSkprwatTable(water_table_id);
1977-
const EvalWell throughput_eval(this->primary_variables_.numWellEq() + Indices::numEq, throughput);
1977+
const EvalWell throughput_eval{throughput};
19781978
// the skin pressure when injecting water, which also means the polymer concentration is zero
1979-
EvalWell pskin_water(this->primary_variables_.numWellEq() + Indices::numEq, 0.0);
1980-
pskin_water = water_table_func.eval(throughput_eval, water_velocity);
1979+
EvalWell pskin_water = water_table_func.eval(throughput_eval, water_velocity);
19811980
return pskin_water;
19821981
} else {
19831982
OPM_DEFLOG_THROW(std::runtime_error,
@@ -2013,10 +2012,9 @@ namespace Opm
20132012
}
20142013
const auto& skprpolytable = PolymerModule::getSkprpolyTable(polymer_table_id);
20152014
const Scalar reference_concentration = skprpolytable.refConcentration;
2016-
const EvalWell throughput_eval(this->primary_variables_.numWellEq() + Indices::numEq, throughput);
2015+
const EvalWell throughput_eval{throughput};
20172016
// the skin pressure when injecting water, which also means the polymer concentration is zero
2018-
EvalWell pskin_poly(this->primary_variables_.numWellEq() + Indices::numEq, 0.0);
2019-
pskin_poly = skprpolytable.table_func.eval(throughput_eval, water_velocity_abs);
2017+
const EvalWell pskin_poly = skprpolytable.table_func.eval(throughput_eval, water_velocity_abs);
20202018
if (poly_inj_conc == reference_concentration) {
20212019
return sign * pskin_poly;
20222020
}
@@ -2046,8 +2044,8 @@ namespace Opm
20462044
if constexpr (Base::has_polymermw) {
20472045
const int table_id = this->polymerInjTable_();
20482046
const auto& table_func = PolymerModule::getPlymwinjTable(table_id);
2049-
const EvalWell throughput_eval(this->primary_variables_.numWellEq() + Indices::numEq, throughput);
2050-
EvalWell molecular_weight(this->primary_variables_.numWellEq() + Indices::numEq, 0.);
2047+
const EvalWell throughput_eval{throughput};
2048+
EvalWell molecular_weight{0.};
20512049
if (this->wpolymer() == 0.) { // not injecting polymer
20522050
return molecular_weight;
20532051
}
@@ -2146,8 +2144,7 @@ namespace Opm
21462144
const Scalar throughput = perf_water_throughput[perf];
21472145
const int pskin_index = Bhp + 1 + this->number_of_local_perforations_ + perf;
21482146

2149-
EvalWell poly_conc(this->primary_variables_.numWellEq() + Indices::numEq, 0.0);
2150-
poly_conc.setValue(this->wpolymer());
2147+
const EvalWell poly_conc(this->wpolymer());
21512148

21522149
// equation for the skin pressure
21532150
const EvalWell eq_pskin = this->primary_variables_.eval(pskin_index)
@@ -2621,7 +2618,7 @@ namespace Opm
26212618
}
26222619

26232620
// convert to reservoir conditions
2624-
EvalWell cq_r_thermal(this->primary_variables_.numWellEq() + Indices::numEq, 0.);
2621+
EvalWell cq_r_thermal{0.};
26252622
const unsigned activeCompIdx = FluidSystem::canonicalToActiveCompIdx(FluidSystem::solventComponentIndex(phaseIdx));
26262623
const bool both_oil_gas = FluidSystem::phaseIsActive(FluidSystem::oilPhaseIdx) && FluidSystem::phaseIsActive(FluidSystem::gasPhaseIdx);
26272624
if (!both_oil_gas || FluidSystem::waterPhaseIdx == phaseIdx) {

0 commit comments

Comments
 (0)