Skip to content

Commit b9ab0ab

Browse files
committed
using the converting from scalar to DyanmicEvaluation
1 parent 14294dd commit b9ab0ab

File tree

3 files changed

+21
-24
lines changed

3 files changed

+21
-24
lines changed

opm/simulators/wells/StandardWellEval.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,9 @@ 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());
63+
EvalWell out(in.value());
6464
for(int eqIdx = 0; eqIdx < Indices::numEq;++eqIdx) {
65-
out.setDerivative(eqIdx, in.derivative(eqIdx));
65+
out.setDerivative(eqIdx, in.derivative(eqIdx), primary_variables_.numWellEq() + Indices::numEq);
6666
}
6767
return out;
6868
}

opm/simulators/wells/StandardWellPrimaryVariables.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ void StandardWellPrimaryVariables<FluidSystem,Indices>::
113113
resize(const int numWellEq)
114114
{
115115
value_.resize(numWellEq, 0.0);
116-
evaluation_.resize(numWellEq, EvalWell{numWellEq + Indices::numEq, 0.0});
116+
evaluation_.resize(numWellEq, {0.0});
117117
numWellEq_ = numWellEq;
118118
}
119119

@@ -468,7 +468,7 @@ StandardWellPrimaryVariables<FluidSystem,Indices>::
468468
volumeFraction(const int compIdx) const
469469
{
470470
if (FluidSystem::numActivePhases() == 1) {
471-
return EvalWell(numWellEq_ + Indices::numEq, 1.0);
471+
return 1.0;
472472
}
473473

474474
if (has_gfrac_variable && compIdx == FluidSystem::canonicalToActiveCompIdx(FluidSystem::gasCompIdx)) {
@@ -486,7 +486,7 @@ volumeFraction(const int compIdx) const
486486
}
487487
// Compute the Oil fraction if oil is present
488488
// or the WATER fraction for a gas-water case
489-
EvalWell well_fraction(numWellEq_ + Indices::numEq, 1.0);
489+
EvalWell well_fraction{1.0};
490490
if (has_wfrac_variable && FluidSystem::phaseIsActive(FluidSystem::oilPhaseIdx)) {
491491
well_fraction -= evaluation_[WFrac];
492492
}
@@ -518,7 +518,7 @@ typename StandardWellPrimaryVariables<FluidSystem,Indices>::EvalWell
518518
StandardWellPrimaryVariables<FluidSystem,Indices>::
519519
surfaceVolumeFraction(const int compIdx) const
520520
{
521-
EvalWell sum_volume_fraction_scaled(numWellEq_ + Indices::numEq, 0.);
521+
EvalWell sum_volume_fraction_scaled{0.};
522522
for (int idx = 0; idx < well_.numConservationQuantities(); ++idx) {
523523
sum_volume_fraction_scaled += this->volumeFractionScaled(idx);
524524
}

opm/simulators/wells/StandardWell_impl.hpp

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -388,9 +388,9 @@ namespace Opm
388388
auto& perf_rates = perf_data.phase_rates;
389389
for (int perf = 0; perf < this->number_of_local_perforations_; ++perf) {
390390
// Calculate perforation quantities.
391-
std::vector<EvalWell> cq_s(this->num_conservation_quantities_, {this->primary_variables_.numWellEq() + Indices::numEq, 0.0});
392-
EvalWell water_flux_s{this->primary_variables_.numWellEq() + Indices::numEq, 0.0};
393-
EvalWell cq_s_zfrac_effective{this->primary_variables_.numWellEq() + Indices::numEq, 0.0};
391+
std::vector<EvalWell> cq_s(this->num_conservation_quantities_, 0.0);
392+
EvalWell water_flux_s{0.0};
393+
EvalWell cq_s_zfrac_effective{0.0};
394394
calculateSinglePerf(simulator, perf, well_state, connectionRates,
395395
cq_s, water_flux_s, cq_s_zfrac_effective, deferred_logger);
396396

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

509509
PerforationRates<Scalar> perf_rates;
@@ -694,7 +694,7 @@ namespace Opm
694694
// as a result, the polymer and water share the same viscosity
695695
if constexpr (!Base::has_polymermw) {
696696
if constexpr (std::is_same_v<Value, Scalar>) {
697-
std::vector<EvalWell> mob_eval(this->num_conservation_quantities_, {this->primary_variables_.numWellEq() + Indices::numEq, 0.});
697+
std::vector<EvalWell> mob_eval(this->num_conservation_quantities_, 0.);
698698
for (std::size_t i = 0; i < mob.size(); ++i) {
699699
mob_eval[i].setValue(mob[i]);
700700
}
@@ -1872,7 +1872,7 @@ namespace Opm
18721872
const bool allow_cf = this->getAllowCrossFlow() || openCrossFlowAvoidSingularity(simulator);
18731873
const EvalWell& bhp = this->primary_variables_.eval(Bhp);
18741874

1875-
std::vector<EvalWell> cq_s(this->num_conservation_quantities_, {this->primary_variables_.numWellEq() + Indices::numEq, 0.});
1875+
std::vector<EvalWell> cq_s(this->num_conservation_quantities_, 0.);
18761876
PerforationRates<Scalar> perf_rates;
18771877
Scalar trans_mult = simulator.problem().template wellTransMultiplier<Scalar>(int_quant, cell_idx);
18781878
const auto& wellstate_nupcol = simulator.problem().wellModel().nupcolWellState().well(this->index_of_well_);
@@ -1947,10 +1947,9 @@ namespace Opm
19471947
deferred_logger);
19481948
}
19491949
const auto& water_table_func = PolymerModule::getSkprwatTable(water_table_id);
1950-
const EvalWell throughput_eval(this->primary_variables_.numWellEq() + Indices::numEq, throughput);
1950+
const EvalWell throughput_eval{throughput};
19511951
// the skin pressure when injecting water, which also means the polymer concentration is zero
1952-
EvalWell pskin_water(this->primary_variables_.numWellEq() + Indices::numEq, 0.0);
1953-
pskin_water = water_table_func.eval(throughput_eval, water_velocity);
1952+
EvalWell pskin_water = water_table_func.eval(throughput_eval, water_velocity);
19541953
return pskin_water;
19551954
} else {
19561955
OPM_DEFLOG_THROW(std::runtime_error,
@@ -1986,10 +1985,9 @@ namespace Opm
19861985
}
19871986
const auto& skprpolytable = PolymerModule::getSkprpolyTable(polymer_table_id);
19881987
const Scalar reference_concentration = skprpolytable.refConcentration;
1989-
const EvalWell throughput_eval(this->primary_variables_.numWellEq() + Indices::numEq, throughput);
1988+
const EvalWell throughput_eval{throughput};
19901989
// the skin pressure when injecting water, which also means the polymer concentration is zero
1991-
EvalWell pskin_poly(this->primary_variables_.numWellEq() + Indices::numEq, 0.0);
1992-
pskin_poly = skprpolytable.table_func.eval(throughput_eval, water_velocity_abs);
1990+
const EvalWell pskin_poly = skprpolytable.table_func.eval(throughput_eval, water_velocity_abs);
19931991
if (poly_inj_conc == reference_concentration) {
19941992
return sign * pskin_poly;
19951993
}
@@ -2019,8 +2017,8 @@ namespace Opm
20192017
if constexpr (Base::has_polymermw) {
20202018
const int table_id = this->polymerInjTable_();
20212019
const auto& table_func = PolymerModule::getPlymwinjTable(table_id);
2022-
const EvalWell throughput_eval(this->primary_variables_.numWellEq() + Indices::numEq, throughput);
2023-
EvalWell molecular_weight(this->primary_variables_.numWellEq() + Indices::numEq, 0.);
2020+
const EvalWell throughput_eval{throughput};
2021+
EvalWell molecular_weight{0.};
20242022
if (this->wpolymer() == 0.) { // not injecting polymer
20252023
return molecular_weight;
20262024
}
@@ -2119,8 +2117,7 @@ namespace Opm
21192117
const Scalar throughput = perf_water_throughput[perf];
21202118
const int pskin_index = Bhp + 1 + this->number_of_local_perforations_ + perf;
21212119

2122-
EvalWell poly_conc(this->primary_variables_.numWellEq() + Indices::numEq, 0.0);
2123-
poly_conc.setValue(this->wpolymer());
2120+
const EvalWell poly_conc(this->wpolymer());
21242121

21252122
// equation for the skin pressure
21262123
const EvalWell eq_pskin = this->primary_variables_.eval(pskin_index)
@@ -2582,7 +2579,7 @@ namespace Opm
25822579
}
25832580

25842581
// convert to reservoir conditions
2585-
EvalWell cq_r_thermal(this->primary_variables_.numWellEq() + Indices::numEq, 0.);
2582+
EvalWell cq_r_thermal{0.};
25862583
const unsigned activeCompIdx = FluidSystem::canonicalToActiveCompIdx(FluidSystem::solventComponentIndex(phaseIdx));
25872584
const bool both_oil_gas = FluidSystem::phaseIsActive(FluidSystem::oilPhaseIdx) && FluidSystem::phaseIsActive(FluidSystem::gasPhaseIdx);
25882585
if (!both_oil_gas || FluidSystem::waterPhaseIdx == phaseIdx) {

0 commit comments

Comments
 (0)