diff --git a/opm/autodiff/StandardWell.hpp b/opm/autodiff/StandardWell.hpp index 981344c0b..1aeb36344 100644 --- a/opm/autodiff/StandardWell.hpp +++ b/opm/autodiff/StandardWell.hpp @@ -107,7 +107,7 @@ namespace Opm WellState& well_state, bool only_wells); - bool crossFlowAllowed(const Simulator& ebosSimulator) const; + virtual bool crossFlowAllowed(const Simulator& ebosSimulator) const; void getMobility(const Simulator& ebosSimulator, const int perf, @@ -145,7 +145,6 @@ namespace Opm using WellInterface::indexOfWell; using WellInterface::name; using WellInterface::wellType; - using WellInterface::allowCrossFlow; using WellInterface::wellControls; using WellInterface::compFrac; using WellInterface::numberOfPhases; @@ -172,6 +171,7 @@ namespace Opm using WellInterface::first_perf_; using WellInterface::ref_depth_; using WellInterface::perf_depth_; + using WellInterface::allow_cf_; // densities of the fluid in each perforation std::vector perf_densities_; diff --git a/opm/autodiff/StandardWell_impl.hpp b/opm/autodiff/StandardWell_impl.hpp index ed453fe27..9ed6fce5a 100644 --- a/opm/autodiff/StandardWell_impl.hpp +++ b/opm/autodiff/StandardWell_impl.hpp @@ -723,7 +723,7 @@ namespace Opm StandardWell:: crossFlowAllowed(const Simulator& ebosSimulator) const { - if (allowCrossFlow()) { + if (allow_cf_) { return true; } diff --git a/opm/autodiff/StandardWellsDense.hpp b/opm/autodiff/StandardWellsDense.hpp index e42d0ff2c..f55805fb1 100644 --- a/opm/autodiff/StandardWellsDense.hpp +++ b/opm/autodiff/StandardWellsDense.hpp @@ -162,8 +162,6 @@ enum WellVariablePositions { const int cell_idx, std::vector& mob) const; - bool allow_cross_flow(const int w, const Simulator& ebosSimulator) const; - void localInvert(Mat& istlA) const; void print(Mat& istlA) const; diff --git a/opm/autodiff/StandardWellsDense_impl.hpp b/opm/autodiff/StandardWellsDense_impl.hpp index 913ca8452..fae2427ab 100644 --- a/opm/autodiff/StandardWellsDense_impl.hpp +++ b/opm/autodiff/StandardWellsDense_impl.hpp @@ -328,7 +328,7 @@ namespace Opm { if (PolymerModule::hasPlyshlog()) { // compute the well water velocity with out shear effects. const int numComp = numComponents(); - bool allow_cf = allow_cross_flow(w, ebosSimulator); + const bool allow_cf = well_container_[w]->crossFlowAllowed(ebosSimulator); const EvalWell& bhp = getBhp(w); std::vector cq_s(numComp,0.0); computeWellFlux(w, wells().WI[perf], intQuants, mob, bhp, wellPerforationPressureDiffs()[perf], allow_cf, cq_s); @@ -364,42 +364,6 @@ namespace Opm { - template - bool - StandardWellsDense:: - allow_cross_flow(const int w, const Simulator& ebosSimulator) const - { - if (wells().allow_cf[w]) { - return true; - } - - // check for special case where all perforations have cross flow - // then the wells must allow for cross flow - for (int perf = wells().well_connpos[w] ; perf < wells().well_connpos[w+1]; ++perf) { - const int cell_idx = wells().well_cells[perf]; - const auto& intQuants = *(ebosSimulator.model().cachedIntensiveQuantities(cell_idx, /*timeIdx=*/0)); - const auto& fs = intQuants.fluidState(); - EvalWell pressure = extendEval(fs.pressure(FluidSystem::oilPhaseIdx)); - EvalWell bhp = getBhp(w); - - // Pressure drawdown (also used to determine direction of flow) - EvalWell well_pressure = bhp + wellPerforationPressureDiffs()[perf]; - EvalWell drawdown = pressure - well_pressure; - - if (drawdown.value() < 0 && wells().type[w] == INJECTOR) { - return false; - } - - if (drawdown.value() > 0 && wells().type[w] == PRODUCER) { - return false; - } - } - return true; - } - - - - template void @@ -2254,7 +2218,7 @@ namespace Opm { const int numComp = numComponents(); well_flux.resize(np, 0.0); - const bool allow_cf = allow_cross_flow(well_index, ebosSimulator); + const bool allow_cf = well_container_[well_index]->crossFlowAllowed(ebosSimulator); for (int perf = wells().well_connpos[well_index]; perf < wells().well_connpos[well_index + 1]; ++perf) { const int cell_index = wells().well_cells[perf]; const auto& intQuants = *(ebosSimulator.model().cachedIntensiveQuantities(cell_index, /*timeIdx=*/ 0)); diff --git a/opm/autodiff/WellInterface.hpp b/opm/autodiff/WellInterface.hpp index 29b141348..6feb3d959 100644 --- a/opm/autodiff/WellInterface.hpp +++ b/opm/autodiff/WellInterface.hpp @@ -135,8 +135,12 @@ namespace Opm int numComponents() const; + // simply returning allow_cf_ + // TODO: to check whether needed, it causes name problem with the crossFlowAllowed bool allowCrossFlow() const; + virtual bool crossFlowAllowed(const Simulator& ebosSimulator) const = 0; + // TODO: for this kind of function, maybe can make a function with parameter perf const std::vector& saturationTableNumber() const;