Merge pull request #4757 from aritorto/lookupdata-generalgrid

Refactor lookup of cartesian index and element data
This commit is contained in:
Markus Blatt 2023-08-23 22:04:25 +02:00 committed by GitHub
commit eafed43dad
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 10 deletions

View File

@ -29,17 +29,23 @@
#define EWOMS_ECL_GENERIC_THRESHOLD_PRESSURE_HH
#include <opm/grid/common/CartesianIndexMapper.hpp>
#include <opm/grid/LookUpData.hh>
#include <vector>
namespace Opm {
class EclipseState;
template<typename Grid, typename GridView> class LookUpData;
template<typename Grid, typename GridView> class LookUpCartesianData;
template<class Grid, class GridView, class ElementMapper, class Scalar>
class EclGenericThresholdPressure {
public:
using CartesianIndexMapper = Dune::CartesianIndexMapper<Grid>;
using LookUpData = Opm::LookUpData<Grid,GridView>;
using LookUpCartesianData = Opm::LookUpCartesianData<Grid,GridView>;
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<Scalar> thpresDefault_;
std::vector<Scalar> thpres_;

View File

@ -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<int>(cartElemFaultIdx_.size()) > cartElem1Idx);
assert(0 <= cartElem2Idx && static_cast<int>(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)) {