55class FlowThresholdPressure :
public GenericThresholdPressure<GetPropType<TypeTag, Properties::Grid>,
56 GetPropType<TypeTag, Properties::GridView>,
57 GetPropType<TypeTag, Properties::ElementMapper>,
58 GetPropType<TypeTag, Properties::Scalar>>
60 using BaseType = GenericThresholdPressure<GetPropType<TypeTag, Properties::Grid>,
70 enum { numPhases = FluidSystem::numPhases };
73 explicit FlowThresholdPressure(
const Simulator& simulator)
74 : BaseType(simulator.vanguard().cartesianIndexMapper(),
75 simulator.vanguard().gridView(),
76 simulator.model().elementMapper(),
77 simulator.vanguard().eclState())
78 , simulator_(simulator)
88 if (this->enableThresholdPressure_ && !this->thpresDefault_.empty() && !this->restart_) {
89 this->computeDefaultThresholdPressures_();
90 this->applyExplicitThresholdPressures_();
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);
119 unsigned equilRegionInside = this->elemEquilRegion_[insideElemIdx];
120 unsigned equilRegionOutside = this->elemEquilRegion_[outsideElemIdx];
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;
149 this->thpresDefault_[offset1] = std::max(this->thpresDefault_[offset1], pth);
150 this->thpresDefault_[offset2] = std::max(this->thpresDefault_[offset2], pth);
156 for (
unsigned i = 0; i < this->thpresDefault_.size(); ++i)
157 this->thpresDefault_[i] = gridView.comm().max(this->thpresDefault_[i]);
159 this->logPressures();
162 const Simulator& simulator_;
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