28#ifndef OPM_FLOW_THRESHOLD_PRESSURE_HPP
29#define OPM_FLOW_THRESHOLD_PRESSURE_HPP
31#include <opm/material/densead/Evaluation.hpp>
32#include <opm/material/densead/Math.hpp>
54template <
class TypeTag>
56 GetPropType<TypeTag, Properties::GridView>,
57 GetPropType<TypeTag, Properties::ElementMapper>,
58 GetPropType<TypeTag, Properties::Scalar>>
70 enum { numPhases = FluidSystem::numPhases };
74 :
BaseType(simulator.vanguard().cartesianIndexMapper(),
75 simulator.vanguard().gridView(),
76 simulator.model().elementMapper(),
77 simulator.vanguard().eclState())
78 , simulator_(simulator)
89 this->computeDefaultThresholdPressures_();
91 simulator_.vanguard().gridView().comm().max(&this->
thpres_[0], this->
thpres_.size());
97 void computeDefaultThresholdPressures_()
99 const auto& vanguard = simulator_.vanguard();
100 const auto& gridView = vanguard.gridView();
102 using Toolbox = MathToolbox<Evaluation>;
105 ElementContext elemCtx(simulator_);
106 for (
const auto& elem : elements(gridView, Dune::Partitions::interior)) {
107 elemCtx.updateAll(elem);
108 const auto& stencil = elemCtx.stencil(0);
110 for (
unsigned scvfIdx = 0; scvfIdx < stencil.numInteriorFaces(); ++ scvfIdx) {
111 const auto& face = stencil.interiorFace(scvfIdx);
113 unsigned i = face.interiorIndex();
114 unsigned j = face.exteriorIndex();
116 unsigned insideElemIdx = elemCtx.globalSpaceIndex(i, 0);
117 unsigned outsideElemIdx = elemCtx.globalSpaceIndex(j, 0);
122 if (equilRegionInside == equilRegionOutside)
127 const Evaluation& trans = simulator_.problem().transmissibility(elemCtx, i, j);
128 Scalar faceArea = face.area();
129 if (std::abs(faceArea*getValue(trans)) < 1e-18)
135 const auto& extQuants = elemCtx.extensiveQuantities(scvfIdx, 0);
136 for (
unsigned phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx) {
137 unsigned upIdx = extQuants.upstreamIndex(phaseIdx);
138 const auto& up = elemCtx.intensiveQuantities(upIdx, 0);
140 if (up.mobility(phaseIdx) > 0.0) {
141 Scalar phaseVal = Toolbox::value(extQuants.pressureDifference(phaseIdx));
142 pth = std::max(pth, std::abs(phaseVal));
146 int offset1 = equilRegionInside*this->
numEquilRegions_ + equilRegionOutside;
147 int offset2 = equilRegionOutside*this->
numEquilRegions_ + equilRegionInside;
162 const Simulator& simulator_;
This class calculates the threshold pressure for grid faces according to the Eclipse Reference Manual...
Definition: FlowThresholdPressure.hpp:59
FlowThresholdPressure(const Simulator &simulator)
Definition: FlowThresholdPressure.hpp:73
void finishInit()
Actually compute the threshold pressures over a face as a pre-compute step.
Definition: FlowThresholdPressure.hpp:85
Definition: GenericThresholdPressure.hpp:43
bool enableThresholdPressure_
Definition: GenericThresholdPressure.hpp:119
void logPressures()
Definition: GenericThresholdPressure_impl.hpp:255
void finishInit()
Actually compute the threshold pressures over a face as a pre-compute step.
Definition: GenericThresholdPressure_impl.hpp:103
std::vector< unsigned short > elemEquilRegion_
Definition: GenericThresholdPressure.hpp:113
unsigned numEquilRegions_
Definition: GenericThresholdPressure.hpp:112
std::vector< GetPropType< TypeTag, Properties::Scalar > > thpresDefault_
Definition: GenericThresholdPressure.hpp:110
std::vector< GetPropType< TypeTag, Properties::Scalar > > thpres_
Definition: GenericThresholdPressure.hpp:111
void applyExplicitThresholdPressures_()
Definition: GenericThresholdPressure_impl.hpp:155
Declare the properties used by the infrastructure code of the finite volume discretizations.
Defines the common properties required by the porous medium multi-phase models.
Definition: blackoilboundaryratevector.hh:39
typename Properties::Detail::GetPropImpl< TypeTag, Property >::type::type GetPropType
get the type alias defined in the property (equivalent to old macro GET_PROP_TYPE(....
Definition: propertysystem.hh:233
The Opm property system, traits with inheritance.