22#ifndef DUMUX_FVMPFAL2DPRESSURE2P_HH
23#define DUMUX_FVMPFAL2DPRESSURE2P_HH
70template<
class TypeTag>
78 dim = GridView::dimension, dimWorld = GridView::dimensionworld
84 using ReferenceElements = Dune::ReferenceElements<Scalar, dim>;
86 using SpatialParams =
typename GET_PROP_TYPE(TypeTag, SpatialParams);
87 using MaterialLaw =
typename SpatialParams::MaterialLaw;
89 using Indices =
typename GET_PROP_TYPE(TypeTag, ModelTraits)::Indices;
91 using FluidSystem =
typename GET_PROP_TYPE(TypeTag, FluidSystem);
92 using FluidState =
typename GET_PROP_TYPE(TypeTag, FluidState);
94 using BoundaryTypes =
typename GET_PROP_TYPE(TypeTag, BoundaryTypes);
97 using SolutionTypes =
typename GET_PROP(TypeTag, SolutionTypes);
99 using PrimaryVariables =
typename SolutionTypes::PrimaryVariables;
100 using ScalarSolutionType =
typename SolutionTypes::ScalarSolution;
102 using GridTypeIndices =
typename GET_PROP_TYPE(TypeTag, GridTypeIndices);
106 pw = Indices::pressureW,
107 pn = Indices::pressureNw,
108 sw = Indices::saturationW,
109 sn = Indices::saturationNw
113 wPhaseIdx = Indices::wPhaseIdx,
114 nPhaseIdx = Indices::nPhaseIdx,
115 pressureIdx = Indices::pressureIdx,
116 saturationIdx = Indices::saturationIdx,
117 pressEqIdx = Indices::pressureEqIdx,
118 satEqIdx = Indices::satEqIdx,
126 dirichletDirichlet = 1,
127 dirichletNeumann = 2,
131 using Element =
typename GridView::Traits::template Codim<0>::Entity;
132 using IntersectionIterator =
typename GridView::IntersectionIterator;
133 using Intersection =
typename GridView::Intersection;
135 using LocalPosition = Dune::FieldVector<Scalar, dim>;
136 using GravityVector = Dune::FieldVector<Scalar, dimWorld>;
138 using GlobalPosition =
typename Element::Geometry::GlobalCoordinate;
140 using DimMatrix = Dune::FieldMatrix<Scalar, dim, dim>;
142 using DimVector = Dune::FieldVector<Scalar, dim>;
155 using GlobalInteractionVolumeVector = std::vector<InteractionVolume>;
156 using InnerBoundaryVolumeFaces = std::vector<Dune::FieldVector<bool, 2*dim> >;
159 Intersection getNextIntersection_(
const Element&,
const IntersectionIterator&);
163 void initializeMatrix();
165 void storeInteractionVolumeInfo();
188 storeInteractionVolumeInfo();
198 const auto element = *problem_.gridView().template begin<0>();
199 FluidState fluidState;
200 fluidState.setPressure(wPhaseIdx, problem_.referencePressure(element));
201 fluidState.setPressure(nPhaseIdx, problem_.referencePressure(element));
202 fluidState.setTemperature(problem_.temperature(element));
203 fluidState.setSaturation(wPhaseIdx, 1.);
204 fluidState.setSaturation(nPhaseIdx, 0.);
215 storeInteractionVolumeInfo();
230 for (
const auto& element : elements(problem_.gridView()))
243 int eIdxGlobal = problem_.variables().index(element);
244 CellData& cellData = problem_.variables().cellData(eIdxGlobal);
246 switch (pressureType_)
250 Scalar potW = this->
pressure()[eIdxGlobal];
252 Scalar gravityDiff = (problem_.bBoxMax() - element.geometry().center()) * gravity_;
253 Scalar potPc = cellData.capillaryPressure()
254 + gravityDiff * (density_[nPhaseIdx] - density_[wPhaseIdx]);
256 cellData.setPotential(wPhaseIdx, potW);
257 cellData.setPotential(nPhaseIdx, potW + potPc);
259 Scalar pressW = potW - gravityDiff * density_[wPhaseIdx];
261 cellData.setPressure(wPhaseIdx, pressW);
262 cellData.setPressure(nPhaseIdx, pressW + cellData.capillaryPressure());
268 Scalar potNw = this->
pressure()[eIdxGlobal];
270 Scalar gravityDiff = (problem_.bBoxMax() - element.geometry().center()) * gravity_;
271 Scalar potPc = cellData.capillaryPressure()
272 + gravityDiff * (density_[nPhaseIdx] - density_[wPhaseIdx]);
274 cellData.setPotential(nPhaseIdx, potNw);
275 cellData.setPotential(wPhaseIdx, potNw - potPc);
277 Scalar pressNw = potNw - gravityDiff * density_[nPhaseIdx];
279 cellData.setPressure(wPhaseIdx, pressNw - cellData.capillaryPressure());
280 cellData.setPressure(nPhaseIdx, pressNw);
285 cellData.fluxData().resetVelocity();
295 timeStep_ = problem_.timeManager().timeStepSize();
297 int size = problem_.gridView().size(0);
298 for (
int i = 0; i < size; i++)
302 switch (saturationType_)
305 sat = problem_.variables().cellData(i).saturation(wPhaseIdx);
308 sat = problem_.variables().cellData(i).saturation(nPhaseIdx);
313 maxError_ = max(maxError_, (sat - 1.0) / timeStep_);
317 maxError_ = max(maxError_, (-sat) / timeStep_);
339 template<
class MultiWriter>
342 int size = problem_.gridView().size(0);
343 ScalarSolutionType *potential = writer.allocateManagedBuffer(size);
347 if (pressureType_ == pw)
349 writer.attachCellData(*potential,
"wetting potential");
352 if (pressureType_ == pn)
354 writer.attachCellData(*potential,
"nonwetting potential");
357 if (vtkOutputLevel_ > 0)
359 ScalarSolutionType *
pressure = writer.allocateManagedBuffer(size);
360 ScalarSolutionType *pressureSecond = writer.allocateManagedBuffer(size);
361 ScalarSolutionType *potentialSecond = writer.allocateManagedBuffer(size);
362 ScalarSolutionType *pc = writer.allocateManagedBuffer(size);
364 for (
const auto& element : elements(problem_.gridView()))
366 int idx = problem_.variables().index(element);
367 CellData& cellData = problem_.variables().cellData(idx);
369 (*pc)[idx] = cellData.capillaryPressure();
371 if (pressureType_ == pw)
373 (*pressure)[idx] = cellData.pressure(wPhaseIdx);
374 (*potentialSecond)[idx] = cellData.potential(nPhaseIdx);
375 (*pressureSecond)[idx] = cellData.pressure(nPhaseIdx);
378 if (pressureType_ == pn)
380 (*pressure)[idx] = cellData.pressure(nPhaseIdx);
381 (*potentialSecond)[idx] = cellData.potential(wPhaseIdx);
382 (*pressureSecond)[idx] = cellData.pressure(wPhaseIdx);
386 if (pressureType_ == pw)
388 writer.attachCellData(*
pressure,
"wetting pressure");
389 writer.attachCellData(*pressureSecond,
"nonwetting pressure");
390 writer.attachCellData(*potentialSecond,
"nonwetting potential");
393 if (pressureType_ == pn)
395 writer.attachCellData(*
pressure,
"nonwetting pressure");
396 writer.attachCellData(*pressureSecond,
"wetting pressure");
397 writer.attachCellData(*potentialSecond,
"wetting potential");
400 writer.attachCellData(*pc,
"capillary pressure");
412 ParentType(problem), problem_(problem), transmissibilityCalculator_(problem),
413 gravity_(problem.gravity()),
414 maxError_(0.), timeStep_(1.)
416 if (pressureType_ != pw && pressureType_ != pn)
418 DUNE_THROW(Dune::NotImplemented,
"Pressure type not supported!");
420 if (saturationType_ != sw && saturationType_ != sn)
422 DUNE_THROW(Dune::NotImplemented,
"Saturation type not supported!");
426 DUNE_THROW(Dune::NotImplemented,
"Compressibility not supported!");
430 DUNE_THROW(Dune::NotImplemented,
"Dimension not supported!");
433 ErrorTermFactor_ = getParam<Scalar>(
"Impet.ErrorTermFactor");
434 ErrorTermLowerBound_ = getParam<Scalar>(
"Impet.ErrorTermLowerBound");
435 ErrorTermUpperBound_ = getParam<Scalar>(
"Impet.ErrorTermUpperBound");
437 density_[wPhaseIdx] = 0.;
438 density_[nPhaseIdx] = 0.;
439 viscosity_[wPhaseIdx] = 0.;
440 viscosity_[nPhaseIdx] = 0.;
442 vtkOutputLevel_ = getParam<int>(
"Vtk.OutputLevel");
455 const GravityVector& gravity_;
459 Scalar ErrorTermFactor_;
460 Scalar ErrorTermLowerBound_;
461 Scalar ErrorTermUpperBound_;
463 Scalar density_[numPhases];
464 Scalar viscosity_[numPhases];
468 static constexpr Scalar threshold_ = 1e-15;
470 static const int pressureType_ =
GET_PROP_VALUE(TypeTag, PressureFormulation);
495 Scalar evaluateErrorTerm_(CellData& cellData)
500 switch (saturationType_)
503 sat = cellData.saturation(wPhaseIdx);
506 sat = cellData.saturation(nPhaseIdx);
510 Scalar error = (sat > 1.0) ? sat - 1.0 : 0.0;
518 Scalar errorAbs = abs(error);
520 if ((errorAbs * timeStep_ > 1e-6) && (errorAbs > ErrorTermLowerBound_ * maxError_)
521 && (!problem_.timeManager().willBeFinished()))
523 return ErrorTermFactor_ * error;
531template<
class TypeTag>
532typename FvMpfaL2dPressure2p<TypeTag>::Intersection
533 FvMpfaL2dPressure2p<TypeTag>::getNextIntersection_(
const Element& element,
534 const IntersectionIterator& isIt)
536 auto isItBegin = problem_.gridView().ibegin(element);
537 const auto isEndIt = problem_.gridView().iend(element);
539 auto tempIsIt = isIt;
540 auto nextIsIt = ++tempIsIt;
546 case GridTypeIndices::yaspGrid:
548 if (nextIsIt == isEndIt)
550 nextIsIt = isItBegin;
554 nextIsIt = ++tempIsIt;
556 if (nextIsIt == isEndIt)
558 auto tempIsItBegin = isItBegin;
559 nextIsIt = ++tempIsItBegin;
566 case GridTypeIndices::aluGrid:
567 case GridTypeIndices::ugGrid:
569 if (nextIsIt == isEndIt)
570 nextIsIt = isItBegin;
576 DUNE_THROW(Dune::NotImplemented,
"GridType can not be used with MPFAO implementation!");
585template<
class TypeTag>
586void FvMpfaL2dPressure2p<TypeTag>::initializeMatrix()
589 for (
const auto& element : elements(problem_.gridView()))
592 int eIdxGlobalI = problem_.variables().index(element);
598 const auto isEndIt = problem_.gridView().iend(element);
599 for (
auto isIt = problem_.gridView().ibegin(element); isIt != isEndIt; ++isIt)
601 const auto& intersection = *isIt;
602 auto nextIntersection = getNextIntersection_(element, isIt);
604 if (intersection.neighbor())
608 if (intersection.neighbor() && nextIntersection.neighbor())
610 for (
const auto& innerIntersection
611 :
intersections(problem_.gridView(), intersection.outside()))
612 for (
const auto& innerNextIntersection
613 :
intersections(problem_.gridView(), nextIntersection.outside()))
615 if (innerIntersection.neighbor() && innerNextIntersection.neighbor())
617 if (innerIntersection.outside() == innerNextIntersection.outside()
618 && innerIntersection.outside() != intersection.inside())
628 this->A_.setrowsize(eIdxGlobalI, rowSize);
633 this->A_.endrowsizes();
636 for (
const auto& element : elements(problem_.gridView()))
639 int eIdxGlobalI = problem_.variables().index(element);
642 this->A_.addindex(eIdxGlobalI, eIdxGlobalI);
645 const auto isEndIt = problem_.gridView().iend(element);
646 for (
auto isIt = problem_.gridView().ibegin(element); isIt != isEndIt; ++isIt)
648 const auto& intersection = *isIt;
649 auto nextIntersection = getNextIntersection_(element, isIt);
651 if (intersection.neighbor())
654 int eIdxGlobalJ = problem_.variables().index(intersection.outside());
658 this->A_.addindex(eIdxGlobalI, eIdxGlobalJ);
661 if (intersection.neighbor() && nextIntersection.neighbor())
663 for (
const auto& innerIntersection
664 :
intersections(problem_.gridView(), intersection.outside()))
665 for (
const auto& innerNextIntersection
666 :
intersections(problem_.gridView(), nextIntersection.outside()))
668 if (innerIntersection.neighbor() && innerNextIntersection.neighbor())
670 auto innerOutside = innerIntersection.outside();
672 if (innerOutside == innerNextIntersection.outside()
673 && innerOutside != intersection.inside())
675 int eIdxGlobalJ = problem_.variables().index(innerOutside);
677 this->A_.addindex(eIdxGlobalI, eIdxGlobalJ);
686 this->A_.endindices();
713template<
class TypeTag>
714void FvMpfaL2dPressure2p<TypeTag>::storeInteractionVolumeInfo()
716 BoundaryTypes bcType;
719 for (
const auto& element : elements(problem_.gridView()))
723 int eIdxGlobal1 = problem_.variables().index(element);
725 const auto isIt12End = problem_.gridView().iend(element);
726 for (
auto isIt12 = problem_.gridView().ibegin(element); isIt12 != isIt12End; ++isIt12)
728 const auto& intersection12 = *isIt12;
729 auto intersection14 = getNextIntersection_(element, isIt12);
731 int indexInInside12 = intersection12.indexInInside();
732 int indexInInside14 = intersection14.indexInInside();
736 const auto referenceElement = ReferenceElements::general(element.type());
738 GlobalPosition corner1234(0);
740 int globalVertIdx1234 = 0;
743 for (
int i = 0; i < intersection12.geometry().corners(); ++i)
745 bool finished =
false;
747 int localVertIdx12corner = referenceElement.subEntity(indexInInside12, 1, i, dim);
749 int globalVertIdx12corner = problem_.variables().vertexMapper().subIndex(element, localVertIdx12corner, dim);
751 for (
int j = 0; j < intersection14.geometry().corners(); ++j)
753 int localVertIdx14corner = referenceElement.subEntity(indexInInside14, 1, j, dim);
755 int globalVertIdx14corner = problem_.variables().vertexMapper().subIndex(element, localVertIdx14corner, dim);
757 if (globalVertIdx12corner == globalVertIdx14corner)
759 corner1234 = element.geometry().corner(localVertIdx12corner);
761 globalVertIdx1234 = globalVertIdx12corner;
774 if (interactionVolumes_[globalVertIdx1234].isStored())
780 interactionVolumes_[globalVertIdx1234].setStored();
783 interactionVolumes_[globalVertIdx1234].setCenterPosition(corner1234);
786 interactionVolumes_[globalVertIdx1234].setSubVolumeElement(element, 0);
787 interactionVolumes_[globalVertIdx1234].setIndexOnElement(intersection12.indexInInside(), 0, 0);
788 interactionVolumes_[globalVertIdx1234].setIndexOnElement(intersection14.indexInInside(), 0, 1);
791 const GlobalPosition& globalPosFace12 = intersection12.geometry().center();
794 Scalar faceVol12 = intersection12.geometry().volume() / 2.0;
797 DimVector unitOuterNormal12 = intersection12.centerUnitOuterNormal();
800 const GlobalPosition& globalPosFace41 = intersection14.geometry().center();
803 Scalar faceVol41 = intersection14.geometry().volume() / 2.0;
806 DimVector unitOuterNormal14 = intersection14.centerUnitOuterNormal();
808 interactionVolumes_[globalVertIdx1234].setNormal(unitOuterNormal12, 0, 0);
809 interactionVolumes_[globalVertIdx1234].setNormal(unitOuterNormal14, 0, 1);
811 unitOuterNormal14 *= -1;
812 unitOuterNormal12 *= -1;
813 interactionVolumes_[globalVertIdx1234].setFaceArea(faceVol12, 0, 0);
814 interactionVolumes_[globalVertIdx1234].setFaceArea(faceVol41, 0, 1);
815 interactionVolumes_[globalVertIdx1234].setFacePosition(globalPosFace12, 0, 0);
816 interactionVolumes_[globalVertIdx1234].setFacePosition(globalPosFace41, 0, 1);
819 if (intersection12.neighbor())
822 auto element2 = intersection12.outside();
824 int eIdxGlobal2 = problem_.variables().index(element2);
827 interactionVolumes_[globalVertIdx1234].setSubVolumeElement(element2, 1);
828 interactionVolumes_[globalVertIdx1234].setIndexOnElement(intersection12.indexInOutside(), 1, 1);
829 interactionVolumes_[globalVertIdx1234].setNormal(unitOuterNormal12, 1, 1);
830 interactionVolumes_[globalVertIdx1234].setFaceArea(faceVol12, 1, 1);
831 interactionVolumes_[globalVertIdx1234].setFacePosition(globalPosFace12, 1, 1);
834 if (intersection14.neighbor())
838 auto element4 = intersection14.outside();
841 interactionVolumes_[globalVertIdx1234].setSubVolumeElement(element4, 3);
842 interactionVolumes_[globalVertIdx1234].setIndexOnElement(intersection14.indexInOutside(), 3, 0);
844 interactionVolumes_[globalVertIdx1234].setNormal(unitOuterNormal14, 3, 0);
845 interactionVolumes_[globalVertIdx1234].setFaceArea(faceVol41, 3, 0);
846 interactionVolumes_[globalVertIdx1234].setFacePosition(globalPosFace41, 3, 0);
849 GlobalPosition globalPos3(0);
851 GlobalPosition globalPosFace23(0);
852 GlobalPosition globalPosFace34(0);
854 for (
const auto& intersection23
857 bool finished =
false;
859 for (
const auto& intersection43
862 if (intersection23.neighbor() && intersection43.neighbor())
864 auto element32 = intersection23.outside();
865 auto element34 = intersection43.outside();
868 if (element32 == element34 && element32 != element)
871 interactionVolumes_[globalVertIdx1234].setSubVolumeElement(element32, 2);
873 interactionVolumes_[globalVertIdx1234].setIndexOnElement(intersection23.indexInInside(), 1,
875 interactionVolumes_[globalVertIdx1234].setIndexOnElement(intersection23.indexInOutside(), 2,
877 interactionVolumes_[globalVertIdx1234].setIndexOnElement(intersection43.indexInInside(), 3,
879 interactionVolumes_[globalVertIdx1234].setIndexOnElement(intersection43.indexInOutside(), 2,
883 globalPos3 = element32.geometry().center();
885 globalPosFace23 = intersection23.geometry().center();
886 globalPosFace34 = intersection43.geometry().center();
888 Scalar faceVol23 = intersection23.geometry().volume() / 2.0;
889 Scalar faceVol34 = intersection43.geometry().volume() / 2.0;
892 DimVector unitOuterNormal23 = intersection23.centerUnitOuterNormal();
894 DimVector unitOuterNormal43 = intersection43.centerUnitOuterNormal();
896 interactionVolumes_[globalVertIdx1234].setNormal(unitOuterNormal23, 1, 0);
897 unitOuterNormal23 *= -1;
898 interactionVolumes_[globalVertIdx1234].setNormal(unitOuterNormal23, 2, 1);
899 interactionVolumes_[globalVertIdx1234].setNormal(unitOuterNormal43, 3, 1);
900 unitOuterNormal43 *= -1;
901 interactionVolumes_[globalVertIdx1234].setNormal(unitOuterNormal43, 2, 0);
902 interactionVolumes_[globalVertIdx1234].setFaceArea(faceVol23, 1, 0);
903 interactionVolumes_[globalVertIdx1234].setFaceArea(faceVol23, 2, 1);
904 interactionVolumes_[globalVertIdx1234].setFaceArea(faceVol34, 2, 0);
905 interactionVolumes_[globalVertIdx1234].setFaceArea(faceVol34, 3, 1);
906 interactionVolumes_[globalVertIdx1234].setFacePosition(globalPosFace23, 1, 0);
907 interactionVolumes_[globalVertIdx1234].setFacePosition(globalPosFace23, 2, 1);
908 interactionVolumes_[globalVertIdx1234].setFacePosition(globalPosFace34, 2, 0);
909 interactionVolumes_[globalVertIdx1234].setFacePosition(globalPosFace34, 3, 1);
927 problem_.boundaryTypes(bcType, intersection14);
928 PrimaryVariables boundValues(0.0);
930 interactionVolumes_[globalVertIdx1234].setBoundary(bcType, 3);
931 if (bcType.isNeumann(pressEqIdx))
933 problem_.neumann(boundValues, intersection14);
934 boundValues *= faceVol41;
935 interactionVolumes_[globalVertIdx1234].setNeumannCondition(boundValues, 3);
937 if (bcType.hasDirichlet())
939 problem_.dirichlet(boundValues, intersection14);
940 interactionVolumes_[globalVertIdx1234].setDirichletCondition(boundValues, 3);
947 GlobalPosition globalPosFace23(0);
950 Scalar faceVol23 = 0;
953 DimVector unitOuterNormal23(0);
955 bool finished =
false;
957 for (
const auto& intersection2
960 if (intersection2.boundary())
962 for (
int i = 0; i < intersection2.geometry().corners(); ++i)
964 int localVertIdx2corner = referenceElement.subEntity(intersection2.indexInInside(), dim - 1, i,
967 int globalVertIdx2corner = problem_.variables().index(
968 element2.template subEntity < dim > (localVertIdx2corner));
970 if (globalVertIdx2corner == globalVertIdx1234)
972 interactionVolumes_[globalVertIdx1234].setIndexOnElement(intersection2.indexInInside(), 1,
975 globalPosFace23 = intersection2.geometry().center();
977 faceVol23 = intersection2.geometry().volume() / 2.0;
979 unitOuterNormal23 = intersection2.centerUnitOuterNormal();
981 interactionVolumes_[globalVertIdx1234].setNormal(unitOuterNormal23, 1, 0);
982 interactionVolumes_[globalVertIdx1234].setFaceArea(faceVol23, 1, 0);
983 interactionVolumes_[globalVertIdx1234].setFacePosition(globalPosFace23, 1, 0);
985 problem_.boundaryTypes(bcType, intersection2);
988 interactionVolumes_[globalVertIdx1234].setBoundary(bcType, 1);
989 if (bcType.isNeumann(pressEqIdx))
991 problem_.neumann(boundValues, intersection2);
992 boundValues *= faceVol23;
993 interactionVolumes_[globalVertIdx1234].setNeumannCondition(boundValues, 1);
995 if (bcType.hasDirichlet())
997 problem_.dirichlet(boundValues, intersection2);
998 interactionVolumes_[globalVertIdx1234].setDirichletCondition(boundValues, 1);
1001 interactionVolumes_[globalVertIdx1234].setOutsideFace(2);
1003 innerBoundaryVolumeFaces_[eIdxGlobal1][intersection12.indexInInside()] =
true;
1004 innerBoundaryVolumeFaces_[eIdxGlobal2][intersection12.indexInOutside()] =
true;
1020 Dune::NotImplemented,
1021 "fvmpfao2pfaboundpressure2p.hh, l. 997: boundary shape not available as interaction volume shape");
1029 problem_.boundaryTypes(bcType, intersection12);
1030 PrimaryVariables boundValues(0.0);
1032 interactionVolumes_[globalVertIdx1234].setBoundary(bcType, 0);
1033 if (bcType.isNeumann(pressEqIdx))
1035 problem_.neumann(boundValues, intersection12);
1036 boundValues *= faceVol12;
1037 interactionVolumes_[globalVertIdx1234].setNeumannCondition(boundValues, 0);
1039 if (bcType.hasDirichlet())
1041 problem_.dirichlet(boundValues, intersection12);
1042 interactionVolumes_[globalVertIdx1234].setDirichletCondition(boundValues, 0);
1046 if (intersection14.boundary())
1048 problem_.boundaryTypes(bcType, intersection14);
1051 interactionVolumes_[globalVertIdx1234].setBoundary(bcType, 3);
1052 if (bcType.isNeumann(pressEqIdx))
1054 problem_.neumann(boundValues, intersection14);
1055 boundValues *= faceVol41;
1056 interactionVolumes_[globalVertIdx1234].setNeumannCondition(boundValues, 3);
1058 if (bcType.hasDirichlet())
1060 problem_.dirichlet(boundValues, intersection14);
1061 interactionVolumes_[globalVertIdx1234].setDirichletCondition(boundValues, 3);
1064 interactionVolumes_[globalVertIdx1234].setOutsideFace(1);
1065 interactionVolumes_[globalVertIdx1234].setOutsideFace(2);
1073 auto element4 = intersection14.outside();
1074 interactionVolumes_[globalVertIdx1234].setIndexOnElement(intersection14.indexInOutside(), 3, 0);
1077 interactionVolumes_[globalVertIdx1234].setSubVolumeElement(element4, 3);
1079 interactionVolumes_[globalVertIdx1234].setNormal(unitOuterNormal14, 3, 0);
1080 interactionVolumes_[globalVertIdx1234].setFaceArea(faceVol41, 3, 0);
1081 interactionVolumes_[globalVertIdx1234].setFacePosition(globalPosFace41, 3, 0);
1083 int eIdxGlobal4 = problem_.variables().index(element4);
1085 bool finished =
false;
1088 for (
const auto& intersection4
1091 if (intersection4.boundary())
1093 for (
int i = 0; i < intersection4.geometry().corners(); ++i)
1095 int localVertIdx4corner = referenceElement.subEntity(intersection4.indexInInside(), dim - 1, i,
1098 int globalVertIdx4corner = problem_.variables().index(
1099 (element4).
template subEntity < dim > (localVertIdx4corner));
1101 if (globalVertIdx4corner == globalVertIdx1234)
1103 interactionVolumes_[globalVertIdx1234].setIndexOnElement(intersection4.indexInInside(), 3,
1106 const GlobalPosition& globalPosFace34 = intersection4.geometry().center();
1108 Scalar faceVol34 = intersection4.geometry().volume() / 2.0;
1110 DimVector unitOuterNormal43 = intersection4.centerUnitOuterNormal();
1112 interactionVolumes_[globalVertIdx1234].setNormal(unitOuterNormal43, 3, 1);
1113 interactionVolumes_[globalVertIdx1234].setFaceArea(faceVol34, 3, 1);
1114 interactionVolumes_[globalVertIdx1234].setFacePosition(globalPosFace34, 3, 1);
1116 problem_.boundaryTypes(bcType, intersection4);
1119 interactionVolumes_[globalVertIdx1234].setBoundary(bcType, 2);
1120 if (bcType.isNeumann(pressEqIdx))
1122 problem_.neumann(boundValues, intersection4);
1123 boundValues *= faceVol34;
1124 interactionVolumes_[globalVertIdx1234].setNeumannCondition(boundValues, 2);
1126 if (bcType.hasDirichlet())
1128 problem_.dirichlet(boundValues, intersection4);
1129 interactionVolumes_[globalVertIdx1234].setDirichletCondition(boundValues, 2);
1132 interactionVolumes_[globalVertIdx1234].setOutsideFace(1);
1134 innerBoundaryVolumeFaces_[eIdxGlobal1][intersection14.indexInInside()] =
true;
1135 innerBoundaryVolumeFaces_[eIdxGlobal4][intersection14.indexInOutside()] =
true;
1139 problem_.spatialParams().intrinsicPermeability(element4));
1155 Dune::NotImplemented,
1156 "fvmpfao2pfaboundpressure2p.hh, l. 1164: boundary shape not available as interaction volume shape");
1169template<
class TypeTag>
1170void FvMpfaL2dPressure2p<TypeTag>::assemble()
1177 for (
const auto& vertex : vertices(problem_.gridView()))
1179 int vIdxGlobal = problem_.variables().index(vertex);
1181 InteractionVolume& interactionVolume = interactionVolumes_[vIdxGlobal];
1183 if (interactionVolume.isInnerVolume())
1186 auto element1 = interactionVolume.getSubVolumeElement(0);
1187 auto element2 = interactionVolume.getSubVolumeElement(1);
1188 auto element3 = interactionVolume.getSubVolumeElement(2);
1189 auto element4 = interactionVolume.getSubVolumeElement(3);
1192 const GlobalPosition& globalPos1 = element1.geometry().center();
1193 const GlobalPosition& globalPos2 = element2.geometry().center();
1194 const GlobalPosition& globalPos3 = element3.geometry().center();
1195 const GlobalPosition& globalPos4 = element4.geometry().center();
1198 Scalar volume1 = element1.geometry().volume();
1199 Scalar volume2 = element2.geometry().volume();
1200 Scalar volume3 = element3.geometry().volume();
1201 Scalar volume4 = element4.geometry().volume();
1204 int eIdxGlobal1 = problem_.variables().index(element1);
1205 int eIdxGlobal2 = problem_.variables().index(element2);
1206 int eIdxGlobal3 = problem_.variables().index(element3);
1207 int eIdxGlobal4 = problem_.variables().index(element4);
1210 CellData& cellData1 = problem_.variables().cellData(eIdxGlobal1);
1211 CellData& cellData2 = problem_.variables().cellData(eIdxGlobal2);
1212 CellData& cellData3 = problem_.variables().cellData(eIdxGlobal3);
1213 CellData& cellData4 = problem_.variables().cellData(eIdxGlobal4);
1216 PrimaryVariables source(0.0);
1217 problem_.source(source, element1);
1218 this->f_[eIdxGlobal1] += volume1 / (4.0) * (source[wPhaseIdx] / density_[wPhaseIdx] + source[nPhaseIdx] / density_[nPhaseIdx]);
1219 problem_.source(source, element2);
1220 this->f_[eIdxGlobal2] += volume2 / (4.0) * (source[wPhaseIdx] / density_[wPhaseIdx] + source[nPhaseIdx] / density_[nPhaseIdx]);
1221 problem_.source(source, element3);
1222 this->f_[eIdxGlobal3] += volume3 / (4.0) * (source[wPhaseIdx] / density_[wPhaseIdx] + source[nPhaseIdx] / density_[nPhaseIdx]);
1223 problem_.source(source, element4);
1224 this->f_[eIdxGlobal4] += volume4 / (4.0) * (source[wPhaseIdx] / density_[wPhaseIdx] + source[nPhaseIdx] / density_[nPhaseIdx]);
1226 this->f_[eIdxGlobal1] += evaluateErrorTerm_(cellData1) * volume1 / (4.0);
1227 this->f_[eIdxGlobal2] += evaluateErrorTerm_(cellData2) * volume2 / (4.0);
1228 this->f_[eIdxGlobal3] += evaluateErrorTerm_(cellData3) * volume3 / (4.0);
1229 this->f_[eIdxGlobal4] += evaluateErrorTerm_(cellData4) * volume4 / (4.0);
1232 Dune::FieldVector<Scalar, numPhases> lambda1(cellData1.mobility(wPhaseIdx));
1233 lambda1[nPhaseIdx] = cellData1.mobility(nPhaseIdx);
1236 Scalar lambdaTotal1 = lambda1[wPhaseIdx] + lambda1[nPhaseIdx];
1239 Dune::FieldVector<Scalar, numPhases> lambda2(cellData2.mobility(wPhaseIdx));
1240 lambda2[nPhaseIdx] = cellData2.mobility(nPhaseIdx);
1243 Scalar lambdaTotal2 = lambda2[wPhaseIdx] + lambda2[nPhaseIdx];
1246 Dune::FieldVector<Scalar, numPhases> lambda3(cellData3.mobility(wPhaseIdx));
1247 lambda3[nPhaseIdx] = cellData3.mobility(nPhaseIdx);
1250 Scalar lambdaTotal3 = lambda3[wPhaseIdx] + lambda3[nPhaseIdx];
1253 Dune::FieldVector<Scalar, numPhases> lambda4(cellData4.mobility(wPhaseIdx));
1254 lambda4[nPhaseIdx] = cellData4.mobility(nPhaseIdx);
1257 Scalar lambdaTotal4 = lambda4[wPhaseIdx] + lambda4[nPhaseIdx];
1259 std::vector<DimVector > lambda(2*dim);
1261 lambda[0][0] = lambdaTotal1;
1262 lambda[0][1] = lambdaTotal1;
1263 lambda[1][0] = lambdaTotal2;
1264 lambda[1][1] = lambdaTotal2;
1265 lambda[2][0] = lambdaTotal3;
1266 lambda[2][1] = lambdaTotal3;
1267 lambda[3][0] = lambdaTotal4;
1268 lambda[3][1] = lambdaTotal4;
1272 Dune::FieldVector<Scalar, 2 * dim> pc(0);
1273 pc[0] = cellData1.capillaryPressure();
1274 pc[1] = cellData2.capillaryPressure();
1275 pc[2] = cellData3.capillaryPressure();
1276 pc[3] = cellData4.capillaryPressure();
1278 Dune::FieldVector<Scalar, 2 * dim> gravityDiff(0);
1282 gravityDiff[0] = (problem_.bBoxMax() - globalPos1) * gravity_ * (density_[nPhaseIdx] - density_[wPhaseIdx]);
1283 gravityDiff[1] = (problem_.bBoxMax() - globalPos2) * gravity_ * (density_[nPhaseIdx] - density_[wPhaseIdx]);
1284 gravityDiff[2] = (problem_.bBoxMax() - globalPos3) * gravity_ * (density_[nPhaseIdx] - density_[wPhaseIdx]);
1285 gravityDiff[3] = (problem_.bBoxMax() - globalPos4) * gravity_ * (density_[nPhaseIdx] - density_[wPhaseIdx]);
1289 Dune::FieldVector<Scalar, 2 * dim> pcFlux(0);
1291 Scalar pcPotential12 = 0;
1292 Scalar pcPotential14 = 0;
1293 Scalar pcPotential32 = 0;
1294 Scalar pcPotential34 = 0;
1297 Dune::FieldVector<Scalar, 2 * dim - dim + 1> u(0);
1298 Dune::FieldMatrix<Scalar,dim,2*dim-dim+1> T(0);
1300 int lType = transmissibilityCalculator_.calculateTransmissibility(T, interactionVolume, lambda, 0, 1, 2, 3);
1302 if (lType == TransmissibilityCalculator::rightTriangle)
1304 if (innerBoundaryVolumeFaces_[eIdxGlobal1][interactionVolume.getIndexOnElement(0, 0)])
1308 this->A_[eIdxGlobal1][eIdxGlobal2] += T[1][0];
1309 this->A_[eIdxGlobal1][eIdxGlobal3] += T[1][1];
1310 this->A_[eIdxGlobal1][eIdxGlobal1] += T[1][2];
1312 this->A_[eIdxGlobal2][eIdxGlobal2] -= T[1][0];
1313 this->A_[eIdxGlobal2][eIdxGlobal3] -= T[1][1];
1314 this->A_[eIdxGlobal2][eIdxGlobal1] -= T[1][2];
1323 pcPotential12 = Tu[1];
1327 if (innerBoundaryVolumeFaces_[eIdxGlobal1][interactionVolume.getIndexOnElement(0, 0)])
1331 this->A_[eIdxGlobal1][eIdxGlobal1] += T[1][0];
1332 this->A_[eIdxGlobal1][eIdxGlobal4] += T[1][1];
1333 this->A_[eIdxGlobal1][eIdxGlobal2] += T[1][2];
1335 this->A_[eIdxGlobal2][eIdxGlobal1] -= T[1][0];
1336 this->A_[eIdxGlobal2][eIdxGlobal4] -= T[1][1];
1337 this->A_[eIdxGlobal2][eIdxGlobal2] -= T[1][2];
1346 pcPotential12 = Tu[1];
1349 lType = transmissibilityCalculator_.calculateTransmissibility(T, interactionVolume, lambda, 1, 2, 3, 0);
1351 if (lType == TransmissibilityCalculator::rightTriangle)
1353 if (innerBoundaryVolumeFaces_[eIdxGlobal2][interactionVolume.getIndexOnElement(1, 0)])
1357 this->A_[eIdxGlobal2][eIdxGlobal3] += T[1][0];
1358 this->A_[eIdxGlobal2][eIdxGlobal4] += T[1][1];
1359 this->A_[eIdxGlobal2][eIdxGlobal2] += T[1][2];
1361 this->A_[eIdxGlobal3][eIdxGlobal3] -= T[1][0];
1362 this->A_[eIdxGlobal3][eIdxGlobal4] -= T[1][1];
1363 this->A_[eIdxGlobal3][eIdxGlobal2] -= T[1][2];
1372 pcPotential32 = -Tu[1];
1376 if (innerBoundaryVolumeFaces_[eIdxGlobal2][interactionVolume.getIndexOnElement(1, 0)])
1380 this->A_[eIdxGlobal2][eIdxGlobal2] += T[1][0];
1381 this->A_[eIdxGlobal2][eIdxGlobal1] += T[1][1];
1382 this->A_[eIdxGlobal2][eIdxGlobal3] += T[1][2];
1384 this->A_[eIdxGlobal3][eIdxGlobal2] -= T[1][0];
1385 this->A_[eIdxGlobal3][eIdxGlobal1] -= T[1][1];
1386 this->A_[eIdxGlobal3][eIdxGlobal3] -= T[1][2];
1395 pcPotential32 = -Tu[1];
1398 lType = transmissibilityCalculator_.calculateTransmissibility(T, interactionVolume, lambda, 2, 3, 0, 1);
1400 if (lType == TransmissibilityCalculator::rightTriangle)
1402 if (innerBoundaryVolumeFaces_[eIdxGlobal3][interactionVolume.getIndexOnElement(2, 0)])
1406 this->A_[eIdxGlobal3][eIdxGlobal4] += T[1][0];
1407 this->A_[eIdxGlobal3][eIdxGlobal1] += T[1][1];
1408 this->A_[eIdxGlobal3][eIdxGlobal3] += T[1][2];
1410 this->A_[eIdxGlobal4][eIdxGlobal4] -= T[1][0];
1411 this->A_[eIdxGlobal4][eIdxGlobal1] -= T[1][1];
1412 this->A_[eIdxGlobal4][eIdxGlobal3] -= T[1][2];
1421 pcPotential34 = Tu[1];
1425 if (innerBoundaryVolumeFaces_[eIdxGlobal3][interactionVolume.getIndexOnElement(2, 0)])
1429 this->A_[eIdxGlobal3][eIdxGlobal3] += T[1][0];
1430 this->A_[eIdxGlobal3][eIdxGlobal2] += T[1][1];
1431 this->A_[eIdxGlobal3][eIdxGlobal4] += T[1][2];
1433 this->A_[eIdxGlobal4][eIdxGlobal3] -= T[1][0];
1434 this->A_[eIdxGlobal4][eIdxGlobal2] -= T[1][1];
1435 this->A_[eIdxGlobal4][eIdxGlobal4] -= T[1][2];
1444 pcPotential34 = Tu[1];
1447 lType = transmissibilityCalculator_.calculateTransmissibility(T, interactionVolume, lambda, 3, 0, 1, 2);
1449 if (lType == TransmissibilityCalculator::rightTriangle)
1451 if (innerBoundaryVolumeFaces_[eIdxGlobal4][interactionVolume.getIndexOnElement(3, 0)])
1455 this->A_[eIdxGlobal4][eIdxGlobal1] += T[1][0];
1456 this->A_[eIdxGlobal4][eIdxGlobal2] += T[1][1];
1457 this->A_[eIdxGlobal4][eIdxGlobal4] += T[1][2];
1459 this->A_[eIdxGlobal1][eIdxGlobal1] -= T[1][0];
1460 this->A_[eIdxGlobal1][eIdxGlobal2] -= T[1][1];
1461 this->A_[eIdxGlobal1][eIdxGlobal4] -= T[1][2];
1470 pcPotential14 = -Tu[1];
1474 if (innerBoundaryVolumeFaces_[eIdxGlobal4][interactionVolume.getIndexOnElement(3, 0)])
1478 this->A_[eIdxGlobal4][eIdxGlobal4] += T[1][0];
1479 this->A_[eIdxGlobal4][eIdxGlobal3] += T[1][1];
1480 this->A_[eIdxGlobal4][eIdxGlobal1] += T[1][2];
1482 this->A_[eIdxGlobal1][eIdxGlobal4] -= T[1][0];
1483 this->A_[eIdxGlobal1][eIdxGlobal3] -= T[1][1];
1484 this->A_[eIdxGlobal1][eIdxGlobal1] -= T[1][2];
1493 pcPotential14 = -Tu[1];
1496 if (pc[0] == 0 && pc[1] == 0 && pc[2] == 0 && pc[3] == 0)
1502 Dune::FieldVector<Scalar, numPhases> lambda12Upw(0.0);
1503 lambda12Upw[wPhaseIdx] = (pcPotential12 >= 0) ? lambda1[wPhaseIdx] : lambda2[wPhaseIdx];
1504 lambda12Upw[nPhaseIdx] = (pcPotential12 >= 0) ? lambda1[nPhaseIdx] : lambda2[nPhaseIdx];
1507 Dune::FieldVector<Scalar, numPhases> lambda14Upw(0.0);
1508 lambda14Upw[wPhaseIdx] = (pcPotential14 >= 0) ? lambda1[wPhaseIdx] : lambda4[wPhaseIdx];
1509 lambda14Upw[nPhaseIdx] = (pcPotential14 >= 0) ? lambda1[nPhaseIdx] : lambda4[nPhaseIdx];
1512 Dune::FieldVector<Scalar, numPhases> lambda32Upw(0.0);
1513 lambda32Upw[wPhaseIdx] = (pcPotential32 >= 0) ? lambda3[wPhaseIdx] : lambda2[wPhaseIdx];
1514 lambda32Upw[nPhaseIdx] = (pcPotential32 >= 0) ? lambda3[nPhaseIdx] : lambda2[nPhaseIdx];
1517 Dune::FieldVector<Scalar, numPhases> lambda34Upw(0.0);
1518 lambda34Upw[wPhaseIdx] = (pcPotential34 >= 0) ? lambda3[wPhaseIdx] : lambda4[wPhaseIdx];
1519 lambda34Upw[nPhaseIdx] = (pcPotential34 >= 0) ? lambda3[nPhaseIdx] : lambda4[nPhaseIdx];
1521 for (
int i = 0; i < numPhases; i++)
1523 Scalar lambdaT12 = lambda12Upw[wPhaseIdx] + lambda12Upw[nPhaseIdx];
1524 Scalar lambdaT14 = lambda14Upw[wPhaseIdx] + lambda14Upw[nPhaseIdx];
1525 Scalar lambdaT32 = lambda32Upw[wPhaseIdx] + lambda32Upw[nPhaseIdx];
1526 Scalar lambdaT34 = lambda34Upw[wPhaseIdx] + lambda34Upw[nPhaseIdx];
1527 Scalar fracFlow12 = (lambdaT12 > threshold_) ? lambda12Upw[i] / (lambdaT12) : 0.0;
1528 Scalar fracFlow14 = (lambdaT14 > threshold_) ? lambda14Upw[i] / (lambdaT14) : 0.0;
1529 Scalar fracFlow32 = (lambdaT32 > threshold_) ? lambda32Upw[i] / (lambdaT32) : 0.0;
1530 Scalar fracFlow34 = (lambdaT34 > threshold_) ? lambda34Upw[i] / (lambdaT34) : 0.0;
1532 Dune::FieldVector<Scalar, 2 * dim> pcFluxReal(pcFlux);
1534 pcFluxReal[0] *= fracFlow12;
1535 pcFluxReal[1] *= fracFlow32;
1536 pcFluxReal[2] *= fracFlow34;
1537 pcFluxReal[3] *= fracFlow14;
1542 switch (pressureType_)
1549 this->f_[eIdxGlobal1] -= (pcFluxReal[0] - pcFluxReal[3]);
1550 this->f_[eIdxGlobal2] -= (pcFluxReal[1] - pcFluxReal[0]);
1551 this->f_[eIdxGlobal3] -= (pcFluxReal[2] - pcFluxReal[1]);
1552 this->f_[eIdxGlobal4] -= (pcFluxReal[3] - pcFluxReal[2]);
1562 this->f_[eIdxGlobal1] += (pcFluxReal[0] - pcFluxReal[3]);
1563 this->f_[eIdxGlobal2] += (pcFluxReal[1] - pcFluxReal[0]);
1564 this->f_[eIdxGlobal3] += (pcFluxReal[2] - pcFluxReal[1]);
1565 this->f_[eIdxGlobal4] += (pcFluxReal[3] - pcFluxReal[2]);
1576 for (
int elemIdx = 0; elemIdx < 2 * dim; elemIdx++)
1578 bool isOutside =
false;
1579 for (
int fIdx = 0; fIdx < dim; fIdx++)
1581 int intVolFaceIdx = interactionVolume.getFaceIndexFromSubVolume(elemIdx, fIdx);
1582 if (interactionVolume.isOutsideFace(intVolFaceIdx))
1593 auto element = interactionVolume.getSubVolumeElement(elemIdx);
1596 const GlobalPosition& globalPos = element.geometry().center();
1599 Scalar volume = element.geometry().volume();
1602 int eIdxGlobal = problem_.variables().index(element);
1605 CellData& cellData = problem_.variables().cellData(eIdxGlobal);
1608 DimMatrix
permeability(problem_.spatialParams().intrinsicPermeability(element));
1611 PrimaryVariables source(0);
1612 problem_.source(source, element);
1613 this->f_[eIdxGlobal] += volume / (4.0) * (source[wPhaseIdx] / density_[wPhaseIdx] + source[nPhaseIdx] / density_[nPhaseIdx]);
1615 this->f_[eIdxGlobal] += evaluateErrorTerm_(cellData) * volume / (4.0);
1618 Dune::FieldVector<Scalar, numPhases> lambda(cellData.mobility(wPhaseIdx));
1619 lambda[nPhaseIdx] = cellData.mobility(nPhaseIdx);
1621 Scalar pc = cellData.capillaryPressure();
1623 Scalar gravityDiff = (problem_.bBoxMax() - globalPos) * gravity_ * (density_[nPhaseIdx] - density_[wPhaseIdx]);
1627 for (
int fIdx = 0; fIdx < dim; fIdx++)
1629 int intVolFaceIdx = interactionVolume.getFaceIndexFromSubVolume(elemIdx, fIdx);
1631 if (interactionVolume.isBoundaryFace(intVolFaceIdx))
1634 if (interactionVolume.getBoundaryType(intVolFaceIdx).isDirichlet(pressEqIdx))
1636 int boundaryFaceIdx = interactionVolume.getIndexOnElement(elemIdx, fIdx);
1638 const auto referenceElement = ReferenceElements::general(element.type());
1640 const LocalPosition& localPos = referenceElement.position(boundaryFaceIdx, 1);
1642 const GlobalPosition& globalPosFace = element.geometry().global(localPos);
1644 DimVector distVec(globalPosFace - globalPos);
1645 Scalar dist = distVec.two_norm();
1646 DimVector unitDistVec(distVec);
1647 unitDistVec /= dist;
1649 Scalar faceArea = interactionVolume.getFaceArea(elemIdx, fIdx);
1652 Scalar satWBound = cellData.saturation(wPhaseIdx);
1654 if (interactionVolume.getBoundaryType(intVolFaceIdx).isDirichlet(satEqIdx))
1656 Scalar satBound = interactionVolume.getDirichletValues(intVolFaceIdx)[saturationIdx];
1657 switch (saturationType_)
1661 satWBound = satBound;
1666 satWBound = 1 - satBound;
1673 Scalar pcBound = MaterialLaw::pc(
1674 problem_.spatialParams().materialLawParams(element), satWBound);
1676 Scalar gravityDiffBound = (problem_.bBoxMax() - globalPosFace) * gravity_
1677 * (density_[nPhaseIdx] - density_[wPhaseIdx]);
1679 pcBound += gravityDiffBound;
1681 Dune::FieldVector<Scalar, numPhases> lambdaBound(
1682 MaterialLaw::krw(problem_.spatialParams().materialLawParams(element),
1684 lambdaBound[nPhaseIdx] = MaterialLaw::krn(
1685 problem_.spatialParams().materialLawParams(element), satWBound);
1686 lambdaBound[wPhaseIdx] /= viscosity_[wPhaseIdx];
1687 lambdaBound[nPhaseIdx] /= viscosity_[nPhaseIdx];
1689 Scalar potentialBound = interactionVolume.getDirichletValues(intVolFaceIdx)[pressureIdx];
1690 Scalar gdeltaZ = (problem_.bBoxMax()-globalPosFace) * gravity_;
1693 Scalar potentialDiffW = 0;
1694 Scalar potentialDiffNw = 0;
1695 switch (pressureType_)
1699 potentialBound += density_[wPhaseIdx]*gdeltaZ;
1700 potentialDiffW = (cellData.potential(wPhaseIdx) - potentialBound) / dist;
1701 potentialDiffNw = (cellData.potential(nPhaseIdx) - potentialBound - pcBound) / dist;
1706 potentialBound += density_[nPhaseIdx]*gdeltaZ;
1707 potentialDiffW = (cellData.potential(wPhaseIdx) - potentialBound + pcBound) / dist;
1708 potentialDiffNw = (cellData.potential(nPhaseIdx) - potentialBound) / dist;
1713 Scalar lambdaTotal = (potentialDiffW >= 0.) ? lambda[wPhaseIdx] : lambdaBound[wPhaseIdx];
1714 lambdaTotal += (potentialDiffNw >= 0.) ? lambda[nPhaseIdx] : lambdaBound[nPhaseIdx];
1716 DimVector permTimesNormal(0);
1720 Scalar entry = lambdaTotal * (unitDistVec * permTimesNormal) / dist * faceArea;
1725 switch (pressureType_)
1730 DimVector pcGradient = unitDistVec;
1731 pcGradient *= (pc - pcBound) / dist;
1734 pcFlux = 0.5 * (lambda[nPhaseIdx] + lambdaBound[nPhaseIdx])
1735 * (permTimesNormal * pcGradient) * faceArea;
1742 DimVector pcGradient = unitDistVec;
1743 pcGradient *= (pc - pcBound) / dist;
1746 pcFlux = 0.5 * (lambda[wPhaseIdx] + lambdaBound[wPhaseIdx])
1747 * (permTimesNormal * pcGradient) * faceArea;
1755 this->A_[eIdxGlobal][eIdxGlobal] += entry;
1756 this->f_[eIdxGlobal] += entry * potentialBound;
1758 if (pc == 0 && pcBound == 0)
1763 for (
int i = 0; i < numPhases; i++)
1765 switch (pressureType_)
1772 this->f_[eIdxGlobal] -= pcFlux;
1781 this->f_[eIdxGlobal] += pcFlux;
1789 else if (interactionVolume.getBoundaryType(intVolFaceIdx).isNeumann(pressEqIdx))
1791 Scalar J = interactionVolume.getNeumannValues(intVolFaceIdx)[wPhaseIdx] / density_[wPhaseIdx];
1792 J += interactionVolume.getNeumannValues(intVolFaceIdx)[nPhaseIdx] / density_[nPhaseIdx];
1794 this->f_[eIdxGlobal] -= J;
1798 std::cout <<
"interactionVolume.getBoundaryType(intVolFaceIdx).isNeumann(pressEqIdx)"
1799 << interactionVolume.getBoundaryType(intVolFaceIdx).isNeumann(pressEqIdx) <<
"\n";
1800 DUNE_THROW(Dune::NotImplemented,
1801 "No valid boundary condition type defined for pressure equation!");
1812 if (problem_.gridView().comm().size() > 1)
1815 for (
const auto& element : elements(problem_.gridView()))
1817 if (element.partitionType() == Dune::InteriorEntity)
1821 int eIdxGlobalI = problem_.variables().index(element);
1823 this->A_[eIdxGlobalI] = 0.0;
1824 this->A_[eIdxGlobalI][eIdxGlobalI] = 1.0;
1825 this->f_[eIdxGlobalI] = this->
pressure()[eIdxGlobalI];
1837template<
class TypeTag>
1841 for (
const auto& element : elements(problem_.gridView()))
1843 int eIdxGlobal = problem_.variables().index(element);
1845 CellData& cellData = problem_.variables().cellData(eIdxGlobal);
1847 Scalar satW = cellData.saturation(wPhaseIdx);
1849 Scalar pc = MaterialLaw::pc(problem_.spatialParams().materialLawParams(element), satW);
1851 cellData.setCapillaryPressure(pc);
1854 Scalar mobilityW = MaterialLaw::krw(problem_.spatialParams().materialLawParams(element), satW)
1855 / viscosity_[wPhaseIdx];
1856 Scalar mobilityNw = MaterialLaw::krn(problem_.spatialParams().materialLawParams(element), satW)
1857 / viscosity_[nPhaseIdx];
1860 cellData.setMobility(wPhaseIdx, mobilityW);
1861 cellData.setMobility(nPhaseIdx, mobilityNw);
1864 cellData.setFracFlowFunc(wPhaseIdx, mobilityW / (mobilityW + mobilityNw));
1865 cellData.setFracFlowFunc(nPhaseIdx, mobilityNw / (mobilityW + mobilityNw));
#define GET_PROP_VALUE(TypeTag, PropTagName)
Definition: propertysystemmacros.hh:282
#define GET_PROP(TypeTag, PropTagName)
Definition: propertysystemmacros.hh:281
#define GET_PROP_TYPE(TypeTag, PropTagName)
Definition: propertysystemmacros.hh:283
Provides methods for transmissibility calculation 2-d.
Class including the information of an interaction volume of a MPFA L-method that does not change with...
Dune::IteratorRange< typename MultiDomainGlue< DomainGridView, TargetGridView, DomainMapper, TargetMapper >::Intersections::const_iterator > intersections(const MultiDomainGlue< DomainGridView, TargetGridView, DomainMapper, TargetMapper > &glue)
Range generator to iterate with range-based for loops over all intersections as follows: for (const a...
Definition: glue.hh:62
make the local view function available whenever we use the grid geometry
Definition: adapt.hh:29
Property tag CellData
Defines data object to be stored.
Definition: porousmediumflow/sequential/properties.hh:72
Property tag GridImplementation
Gives kind of grid implementation in form of a GridType.
Definition: porousmediumflow/sequential/cellcentered/mpfa/properties.hh:95
Property tag EnableCompressibility
Returns whether compressibility is allowed.
Definition: porousmediumflow/2p/sequential/properties.hh:55
Property tag SaturationFormulation
The formulation of the saturation model.
Definition: porousmediumflow/2p/sequential/properties.hh:53
Property tag NumPhases
Number of phases in the system.
Definition: porousmediumflow/sequential/properties.hh:69
Property tag VelocityFormulation
The type of velocity reconstructed for the transport model.
Definition: porousmediumflow/2p/sequential/properties.hh:54
std::string viscosity(int phaseIdx) noexcept
I/O name of viscosity for multiphase systems.
Definition: name.hh:74
std::string permeability() noexcept
I/O name of permeability.
Definition: name.hh:143
std::string pressure(int phaseIdx) noexcept
I/O name of pressure for multiphase systems.
Definition: name.hh:34
std::string density(int phaseIdx) noexcept
I/O name of density for multiphase systems.
Definition: name.hh:65
Finite volume MPFA L-method discretization of a two-phase flow pressure equation of the sequential IM...
Definition: lmethod/2dpressure.hh:72
InnerBoundaryVolumeFaces innerBoundaryVolumeFaces_
Vector marking faces which intersect the boundary.
Definition: lmethod/2dpressure.hh:452
void storePressureSolution(const Element &element)
Stores the pressure solution of a cell.
Definition: lmethod/2dpressure.hh:241
void update()
Pressure update.
Definition: lmethod/2dpressure.hh:291
void initialize()
Initializes the pressure model.
Definition: lmethod/2dpressure.hh:194
void updateInteractionVolumeInfo()
Updates interaction volumes.
Definition: lmethod/2dpressure.hh:180
FvMpfaL2dPressure2p(Problem &problem)
Constructs a FvMpfaL2dPressure2p object.
Definition: lmethod/2dpressure.hh:411
GlobalInteractionVolumeVector interactionVolumes_
Global Vector of interaction volumes.
Definition: lmethod/2dpressure.hh:451
void storePressureSolution()
Globally stores the pressure solution.
Definition: lmethod/2dpressure.hh:228
void addOutputVtkFields(MultiWriter &writer)
Adds pressure output to the output file.
Definition: lmethod/2dpressure.hh:340
FvMpfaL2dTransmissibilityCalculator< TypeTag > TransmissibilityCalculator
Definition: lmethod/2dpressure.hh:152
void updateMaterialLaws()
constitutive functions are initialized and stored in the variables object
Definition: lmethod/2dpressure.hh:1838
Provides methods for transmissibility calculation in 2-d.
Definition: 2dtransmissibilitycalculator.hh:44
Class including the information of an interaction volume of a MPFA L-method that does not change with...
Definition: linteractionvolume.hh:41
The finite volume base class for the solution of a pressure equation.
Definition: sequential/cellcentered/pressure.hh:48
void initialize()
Initialize pressure model.
Definition: sequential/cellcentered/pressure.hh:212
PressureSolution & pressure()
Returns the vector containing the pressure solution.
Definition: sequential/cellcentered/pressure.hh:119
void solve()
Solves the global system of equations to get the spatial distribution of the pressure.
Definition: sequential/cellcentered/pressure.hh:526
Specifies the properties for immiscible 2p diffusion/pressure models.
Properties for a MPFA method.
Finite Volume Diffusion Model.