diff --git a/ebos/eclgenericthresholdpressure.hh b/ebos/eclgenericthresholdpressure.hh index f5a64482c..4451ac74e 100644 --- a/ebos/eclgenericthresholdpressure.hh +++ b/ebos/eclgenericthresholdpressure.hh @@ -29,17 +29,23 @@ #define EWOMS_ECL_GENERIC_THRESHOLD_PRESSURE_HH #include +#include + #include namespace Opm { class EclipseState; +template class LookUpData; +template class LookUpCartesianData; template class EclGenericThresholdPressure { public: using CartesianIndexMapper = Dune::CartesianIndexMapper; + using LookUpData = Opm::LookUpData; + using LookUpCartesianData = Opm::LookUpCartesianData; EclGenericThresholdPressure(const CartesianIndexMapper& cartMapper, const GridView& gridView, @@ -93,6 +99,8 @@ protected: const CartesianIndexMapper& cartMapper_; const GridView& gridView_; const ElementMapper& elementMapper_; + const LookUpData lookUpData_; + const LookUpCartesianData lookUpCartesianData_; const EclipseState& eclState_; std::vector thpresDefault_; std::vector thpres_; diff --git a/ebos/eclgenericthresholdpressure_impl.hh b/ebos/eclgenericthresholdpressure_impl.hh index 16afaea1c..33d5d6d6f 100644 --- a/ebos/eclgenericthresholdpressure_impl.hh +++ b/ebos/eclgenericthresholdpressure_impl.hh @@ -55,6 +55,8 @@ EclGenericThresholdPressure(const CartesianIndexMapper& cartMapper, : cartMapper_(cartMapper) , gridView_(gridView) , elementMapper_(elementMapper) + , lookUpData_(gridView) + , lookUpCartesianData_(gridView, cartMapper_) , eclState_(eclState) { } @@ -68,14 +70,10 @@ thresholdPressure(int elem1Idx, int elem2Idx) const // threshold pressure accross faults if (!thpresftValues_.empty()) { - int cartElem1Idx = cartMapper_.cartesianIndex(elem1Idx); - int cartElem2Idx = cartMapper_.cartesianIndex(elem2Idx); - assert(0 <= cartElem1Idx && static_cast(cartElemFaultIdx_.size()) > cartElem1Idx); - assert(0 <= cartElem2Idx && static_cast(cartElemFaultIdx_.size()) > cartElem2Idx); + int fault1Idx = lookUpCartesianData_(elem1Idx, cartElemFaultIdx_); + int fault2Idx = lookUpCartesianData_(elem2Idx, cartElemFaultIdx_); - int fault1Idx = cartElemFaultIdx_[cartElem1Idx]; - int fault2Idx = cartElemFaultIdx_[cartElem2Idx]; if (fault1Idx != -1 && fault1Idx == fault2Idx) // inside a fault there's no threshold pressure, even accross EQUIL // regions. @@ -173,11 +171,9 @@ applyExplicitThresholdPressures_() const auto& inside = intersection.inside(); const auto& outside = intersection.outside(); - unsigned insideElemIdx = elementMapper_.index(inside); - unsigned outsideElemIdx = elementMapper_.index(outside); + auto equilRegionInside = lookUpData_(inside, elemEquilRegion_); + auto equilRegionOutside = lookUpData_(outside, elemEquilRegion_); - auto equilRegionInside = elemEquilRegion_[insideElemIdx]; - auto equilRegionOutside = elemEquilRegion_[outsideElemIdx]; if (thpres.hasRegionBarrier(equilRegionInside + 1, equilRegionOutside + 1)) { Scalar pth = 0.0; if (thpres.hasThresholdPressure(equilRegionInside + 1, equilRegionOutside + 1)) {