22#ifndef DUMUX_FVMPFAL2DPRESSURE2P_HH
23#define DUMUX_FVMPFAL2DPRESSURE2P_HH
70template<
class TypeTag>
78 dim = GridView::dimension, dimWorld = GridView::dimensionworld
96 using PrimaryVariables =
typename SolutionTypes::PrimaryVariables;
97 using ScalarSolutionType =
typename SolutionTypes::ScalarSolution;
103 pw = Indices::pressureW,
104 pn = Indices::pressureNw,
105 sw = Indices::saturationW,
106 sn = Indices::saturationNw
110 wPhaseIdx = Indices::wPhaseIdx,
111 nPhaseIdx = Indices::nPhaseIdx,
112 pressureIdx = Indices::pressureIdx,
113 saturationIdx = Indices::saturationIdx,
114 pressEqIdx = Indices::pressureEqIdx,
115 satEqIdx = Indices::satEqIdx,
116 numPhases = getPropValue<TypeTag, Properties::NumPhases>()
123 dirichletDirichlet = 1,
124 dirichletNeumann = 2,
128 using Element =
typename GridView::Traits::template Codim<0>::Entity;
129 using IntersectionIterator =
typename GridView::IntersectionIterator;
130 using Intersection =
typename GridView::Intersection;
132 using LocalPosition = Dune::FieldVector<Scalar, dim>;
133 using GravityVector = Dune::FieldVector<Scalar, dimWorld>;
135 using GlobalPosition =
typename Element::Geometry::GlobalCoordinate;
137 using DimMatrix = Dune::FieldMatrix<Scalar, dim, dim>;
139 using DimVector = Dune::FieldVector<Scalar, dim>;
152 using GlobalInteractionVolumeVector = std::vector<InteractionVolume>;
153 using InnerBoundaryVolumeFaces = std::vector<Dune::FieldVector<bool, 2*dim> >;
156 Intersection getNextIntersection_(
const Element&,
const IntersectionIterator&);
160 void initializeMatrix();
162 void storeInteractionVolumeInfo();
185 storeInteractionVolumeInfo();
195 const auto element = *problem_.gridView().template begin<0>();
196 FluidState fluidState;
197 fluidState.setPressure(wPhaseIdx, problem_.referencePressure(element));
198 fluidState.setPressure(nPhaseIdx, problem_.referencePressure(element));
199 fluidState.setTemperature(problem_.temperature(element));
200 fluidState.setSaturation(wPhaseIdx, 1.);
201 fluidState.setSaturation(nPhaseIdx, 0.);
212 storeInteractionVolumeInfo();
227 for (
const auto& element : elements(problem_.gridView()))
240 int eIdxGlobal = problem_.variables().index(element);
241 CellData& cellData = problem_.variables().cellData(eIdxGlobal);
243 switch (pressureType_)
247 Scalar potW = this->
pressure()[eIdxGlobal];
249 Scalar gravityDiff = (problem_.bBoxMax() - element.geometry().center()) * gravity_;
250 Scalar potPc = cellData.capillaryPressure()
251 + gravityDiff * (density_[nPhaseIdx] - density_[wPhaseIdx]);
253 cellData.setPotential(wPhaseIdx, potW);
254 cellData.setPotential(nPhaseIdx, potW + potPc);
256 Scalar pressW = potW - gravityDiff * density_[wPhaseIdx];
258 cellData.setPressure(wPhaseIdx, pressW);
259 cellData.setPressure(nPhaseIdx, pressW + cellData.capillaryPressure());
265 Scalar potNw = this->
pressure()[eIdxGlobal];
267 Scalar gravityDiff = (problem_.bBoxMax() - element.geometry().center()) * gravity_;
268 Scalar potPc = cellData.capillaryPressure()
269 + gravityDiff * (density_[nPhaseIdx] - density_[wPhaseIdx]);
271 cellData.setPotential(nPhaseIdx, potNw);
272 cellData.setPotential(wPhaseIdx, potNw - potPc);
274 Scalar pressNw = potNw - gravityDiff * density_[nPhaseIdx];
276 cellData.setPressure(wPhaseIdx, pressNw - cellData.capillaryPressure());
277 cellData.setPressure(nPhaseIdx, pressNw);
282 cellData.fluxData().resetVelocity();
292 timeStep_ = problem_.timeManager().timeStepSize();
294 int size = problem_.gridView().size(0);
295 for (
int i = 0; i < size; i++)
299 switch (saturationType_)
302 sat = problem_.variables().cellData(i).saturation(wPhaseIdx);
305 sat = problem_.variables().cellData(i).saturation(nPhaseIdx);
310 maxError_ = max(maxError_, (sat - 1.0) / timeStep_);
314 maxError_ = max(maxError_, (-sat) / timeStep_);
336 template<
class MultiWriter>
339 int size = problem_.gridView().size(0);
340 ScalarSolutionType *potential = writer.allocateManagedBuffer(size);
344 if (pressureType_ == pw)
346 writer.attachCellData(*potential,
"wetting potential");
349 if (pressureType_ == pn)
351 writer.attachCellData(*potential,
"nonwetting potential");
354 if (vtkOutputLevel_ > 0)
356 ScalarSolutionType *
pressure = writer.allocateManagedBuffer(size);
357 ScalarSolutionType *pressureSecond = writer.allocateManagedBuffer(size);
358 ScalarSolutionType *potentialSecond = writer.allocateManagedBuffer(size);
359 ScalarSolutionType *pc = writer.allocateManagedBuffer(size);
361 for (
const auto& element : elements(problem_.gridView()))
363 int idx = problem_.variables().index(element);
364 CellData& cellData = problem_.variables().cellData(idx);
366 (*pc)[idx] = cellData.capillaryPressure();
368 if (pressureType_ == pw)
370 (*pressure)[idx] = cellData.pressure(wPhaseIdx);
371 (*potentialSecond)[idx] = cellData.potential(nPhaseIdx);
372 (*pressureSecond)[idx] = cellData.pressure(nPhaseIdx);
375 if (pressureType_ == pn)
377 (*pressure)[idx] = cellData.pressure(nPhaseIdx);
378 (*potentialSecond)[idx] = cellData.potential(wPhaseIdx);
379 (*pressureSecond)[idx] = cellData.pressure(wPhaseIdx);
383 if (pressureType_ == pw)
385 writer.attachCellData(*
pressure,
"wetting pressure");
386 writer.attachCellData(*pressureSecond,
"nonwetting pressure");
387 writer.attachCellData(*potentialSecond,
"nonwetting potential");
390 if (pressureType_ == pn)
392 writer.attachCellData(*
pressure,
"nonwetting pressure");
393 writer.attachCellData(*pressureSecond,
"wetting pressure");
394 writer.attachCellData(*potentialSecond,
"wetting potential");
397 writer.attachCellData(*pc,
"capillary pressure");
409 ParentType(problem), problem_(problem), transmissibilityCalculator_(problem),
410 gravity_(problem.gravity()),
411 maxError_(0.), timeStep_(1.)
413 if (pressureType_ != pw && pressureType_ != pn)
415 DUNE_THROW(Dune::NotImplemented,
"Pressure type not supported!");
417 if (saturationType_ != sw && saturationType_ != sn)
419 DUNE_THROW(Dune::NotImplemented,
"Saturation type not supported!");
421 if (getPropValue<TypeTag, Properties::EnableCompressibility>())
423 DUNE_THROW(Dune::NotImplemented,
"Compressibility not supported!");
427 DUNE_THROW(Dune::NotImplemented,
"Dimension not supported!");
430 ErrorTermFactor_ = getParam<Scalar>(
"Impet.ErrorTermFactor");
431 ErrorTermLowerBound_ = getParam<Scalar>(
"Impet.ErrorTermLowerBound");
432 ErrorTermUpperBound_ = getParam<Scalar>(
"Impet.ErrorTermUpperBound");
434 density_[wPhaseIdx] = 0.;
435 density_[nPhaseIdx] = 0.;
436 viscosity_[wPhaseIdx] = 0.;
437 viscosity_[nPhaseIdx] = 0.;
439 vtkOutputLevel_ = getParam<int>(
"Vtk.OutputLevel");
452 const GravityVector& gravity_;
456 Scalar ErrorTermFactor_;
457 Scalar ErrorTermLowerBound_;
458 Scalar ErrorTermUpperBound_;
460 Scalar density_[numPhases];
461 Scalar viscosity_[numPhases];
465 static constexpr Scalar threshold_ = 1e-15;
467 static const int pressureType_ = getPropValue<TypeTag, Properties::PressureFormulation>();
469 static const int saturationType_ = getPropValue<TypeTag, Properties::SaturationFormulation>();
471 static const int velocityType_ = getPropValue<TypeTag, Properties::VelocityFormulation>();
492 Scalar evaluateErrorTerm_(CellData& cellData)
497 switch (saturationType_)
500 sat = cellData.saturation(wPhaseIdx);
503 sat = cellData.saturation(nPhaseIdx);
507 Scalar error = (sat > 1.0) ? sat - 1.0 : 0.0;
515 Scalar errorAbs = abs(error);
517 if ((errorAbs * timeStep_ > 1e-6) && (errorAbs > ErrorTermLowerBound_ * maxError_)
518 && (!problem_.timeManager().willBeFinished()))
520 return ErrorTermFactor_ * error;
528template<
class TypeTag>
529typename FvMpfaL2dPressure2p<TypeTag>::Intersection
530 FvMpfaL2dPressure2p<TypeTag>::getNextIntersection_(
const Element& element,
531 const IntersectionIterator& isIt)
533 auto isItBegin = problem_.gridView().ibegin(element);
534 const auto isEndIt = problem_.gridView().iend(element);
536 auto tempIsIt = isIt;
537 auto nextIsIt = ++tempIsIt;
540 switch (getPropValue<TypeTag, Properties::GridImplementation>())
543 case GridTypeIndices::yaspGrid:
545 if (nextIsIt == isEndIt)
547 nextIsIt = isItBegin;
551 nextIsIt = ++tempIsIt;
553 if (nextIsIt == isEndIt)
555 auto tempIsItBegin = isItBegin;
556 nextIsIt = ++tempIsItBegin;
563 case GridTypeIndices::aluGrid:
564 case GridTypeIndices::ugGrid:
566 if (nextIsIt == isEndIt)
567 nextIsIt = isItBegin;
573 DUNE_THROW(Dune::NotImplemented,
"GridType can not be used with MPFAO implementation!");
582template<
class TypeTag>
583void FvMpfaL2dPressure2p<TypeTag>::initializeMatrix()
586 for (
const auto& element : elements(problem_.gridView()))
589 int eIdxGlobalI = problem_.variables().index(element);
595 const auto isEndIt = problem_.gridView().iend(element);
596 for (
auto isIt = problem_.gridView().ibegin(element); isIt != isEndIt; ++isIt)
598 const auto& intersection = *isIt;
599 auto nextIntersection = getNextIntersection_(element, isIt);
601 if (intersection.neighbor())
605 if (intersection.neighbor() && nextIntersection.neighbor())
607 for (
const auto& innerIntersection
608 : intersections(problem_.gridView(), intersection.outside()))
609 for (
const auto& innerNextIntersection
610 : intersections(problem_.gridView(), nextIntersection.outside()))
612 if (innerIntersection.neighbor() && innerNextIntersection.neighbor())
614 if (innerIntersection.outside() == innerNextIntersection.outside()
615 && innerIntersection.outside() != intersection.inside())
625 this->A_.setrowsize(eIdxGlobalI, rowSize);
630 this->A_.endrowsizes();
633 for (
const auto& element : elements(problem_.gridView()))
636 int eIdxGlobalI = problem_.variables().index(element);
639 this->A_.addindex(eIdxGlobalI, eIdxGlobalI);
642 const auto isEndIt = problem_.gridView().iend(element);
643 for (
auto isIt = problem_.gridView().ibegin(element); isIt != isEndIt; ++isIt)
645 const auto& intersection = *isIt;
646 auto nextIntersection = getNextIntersection_(element, isIt);
648 if (intersection.neighbor())
651 int eIdxGlobalJ = problem_.variables().index(intersection.outside());
655 this->A_.addindex(eIdxGlobalI, eIdxGlobalJ);
658 if (intersection.neighbor() && nextIntersection.neighbor())
660 for (
const auto& innerIntersection
661 : intersections(problem_.gridView(), intersection.outside()))
662 for (
const auto& innerNextIntersection
663 : intersections(problem_.gridView(), nextIntersection.outside()))
665 if (innerIntersection.neighbor() && innerNextIntersection.neighbor())
667 auto innerOutside = innerIntersection.outside();
669 if (innerOutside == innerNextIntersection.outside()
670 && innerOutside != intersection.inside())
672 int eIdxGlobalJ = problem_.variables().index(innerOutside);
674 this->A_.addindex(eIdxGlobalI, eIdxGlobalJ);
683 this->A_.endindices();
710template<
class TypeTag>
711void FvMpfaL2dPressure2p<TypeTag>::storeInteractionVolumeInfo()
713 BoundaryTypes bcType;
716 for (
const auto& element : elements(problem_.gridView()))
720 int eIdxGlobal1 = problem_.variables().index(element);
722 const auto isIt12End = problem_.gridView().iend(element);
723 for (
auto isIt12 = problem_.gridView().ibegin(element); isIt12 != isIt12End; ++isIt12)
725 const auto& intersection12 = *isIt12;
726 auto intersection14 = getNextIntersection_(element, isIt12);
728 int indexInInside12 = intersection12.indexInInside();
729 int indexInInside14 = intersection14.indexInInside();
733 const auto refElement = referenceElement(element);
735 GlobalPosition corner1234(0);
737 int globalVertIdx1234 = 0;
740 for (
int i = 0; i < intersection12.geometry().corners(); ++i)
742 bool finished =
false;
744 int localVertIdx12corner = refElement.subEntity(indexInInside12, 1, i, dim);
746 int globalVertIdx12corner = problem_.variables().vertexMapper().subIndex(element, localVertIdx12corner, dim);
748 for (
int j = 0; j < intersection14.geometry().corners(); ++j)
750 int localVertIdx14corner = refElement.subEntity(indexInInside14, 1, j, dim);
752 int globalVertIdx14corner = problem_.variables().vertexMapper().subIndex(element, localVertIdx14corner, dim);
754 if (globalVertIdx12corner == globalVertIdx14corner)
756 corner1234 =
element.geometry().corner(localVertIdx12corner);
758 globalVertIdx1234 = globalVertIdx12corner;
771 if (interactionVolumes_[globalVertIdx1234].isStored())
777 interactionVolumes_[globalVertIdx1234].setStored();
780 interactionVolumes_[globalVertIdx1234].setCenterPosition(corner1234);
783 interactionVolumes_[globalVertIdx1234].setSubVolumeElement(element, 0);
784 interactionVolumes_[globalVertIdx1234].setIndexOnElement(intersection12.indexInInside(), 0, 0);
785 interactionVolumes_[globalVertIdx1234].setIndexOnElement(intersection14.indexInInside(), 0, 1);
788 const GlobalPosition& globalPosFace12 = intersection12.geometry().center();
791 Scalar faceVol12 = intersection12.geometry().volume() / 2.0;
794 DimVector unitOuterNormal12 = intersection12.centerUnitOuterNormal();
797 const GlobalPosition& globalPosFace41 = intersection14.geometry().center();
800 Scalar faceVol41 = intersection14.geometry().volume() / 2.0;
803 DimVector unitOuterNormal14 = intersection14.centerUnitOuterNormal();
805 interactionVolumes_[globalVertIdx1234].setNormal(unitOuterNormal12, 0, 0);
806 interactionVolumes_[globalVertIdx1234].setNormal(unitOuterNormal14, 0, 1);
808 unitOuterNormal14 *= -1;
809 unitOuterNormal12 *= -1;
810 interactionVolumes_[globalVertIdx1234].setFaceArea(faceVol12, 0, 0);
811 interactionVolumes_[globalVertIdx1234].setFaceArea(faceVol41, 0, 1);
812 interactionVolumes_[globalVertIdx1234].setFacePosition(globalPosFace12, 0, 0);
813 interactionVolumes_[globalVertIdx1234].setFacePosition(globalPosFace41, 0, 1);
816 if (intersection12.neighbor())
819 auto element2 = intersection12.outside();
821 int eIdxGlobal2 = problem_.variables().index(element2);
824 interactionVolumes_[globalVertIdx1234].setSubVolumeElement(element2, 1);
825 interactionVolumes_[globalVertIdx1234].setIndexOnElement(intersection12.indexInOutside(), 1, 1);
826 interactionVolumes_[globalVertIdx1234].setNormal(unitOuterNormal12, 1, 1);
827 interactionVolumes_[globalVertIdx1234].setFaceArea(faceVol12, 1, 1);
828 interactionVolumes_[globalVertIdx1234].setFacePosition(globalPosFace12, 1, 1);
831 if (intersection14.neighbor())
835 auto element4 = intersection14.outside();
838 interactionVolumes_[globalVertIdx1234].setSubVolumeElement(element4, 3);
839 interactionVolumes_[globalVertIdx1234].setIndexOnElement(intersection14.indexInOutside(), 3, 0);
841 interactionVolumes_[globalVertIdx1234].setNormal(unitOuterNormal14, 3, 0);
842 interactionVolumes_[globalVertIdx1234].setFaceArea(faceVol41, 3, 0);
843 interactionVolumes_[globalVertIdx1234].setFacePosition(globalPosFace41, 3, 0);
846 GlobalPosition globalPos3(0);
848 GlobalPosition globalPosFace23(0);
849 GlobalPosition globalPosFace34(0);
851 for (
const auto& intersection23
852 : intersections(problem_.gridView(), element2))
854 bool finished =
false;
856 for (
const auto& intersection43
857 : intersections(problem_.gridView(), element4))
859 if (intersection23.neighbor() && intersection43.neighbor())
861 auto element32 = intersection23.outside();
862 auto element34 = intersection43.outside();
865 if (element32 == element34 && element32 != element)
868 interactionVolumes_[globalVertIdx1234].setSubVolumeElement(element32, 2);
870 interactionVolumes_[globalVertIdx1234].setIndexOnElement(intersection23.indexInInside(), 1,
872 interactionVolumes_[globalVertIdx1234].setIndexOnElement(intersection23.indexInOutside(), 2,
874 interactionVolumes_[globalVertIdx1234].setIndexOnElement(intersection43.indexInInside(), 3,
876 interactionVolumes_[globalVertIdx1234].setIndexOnElement(intersection43.indexInOutside(), 2,
880 globalPos3 = element32.geometry().center();
882 globalPosFace23 = intersection23.geometry().center();
883 globalPosFace34 = intersection43.geometry().center();
885 Scalar faceVol23 = intersection23.geometry().volume() / 2.0;
886 Scalar faceVol34 = intersection43.geometry().volume() / 2.0;
889 DimVector unitOuterNormal23 = intersection23.centerUnitOuterNormal();
891 DimVector unitOuterNormal43 = intersection43.centerUnitOuterNormal();
893 interactionVolumes_[globalVertIdx1234].setNormal(unitOuterNormal23, 1, 0);
894 unitOuterNormal23 *= -1;
895 interactionVolumes_[globalVertIdx1234].setNormal(unitOuterNormal23, 2, 1);
896 interactionVolumes_[globalVertIdx1234].setNormal(unitOuterNormal43, 3, 1);
897 unitOuterNormal43 *= -1;
898 interactionVolumes_[globalVertIdx1234].setNormal(unitOuterNormal43, 2, 0);
899 interactionVolumes_[globalVertIdx1234].setFaceArea(faceVol23, 1, 0);
900 interactionVolumes_[globalVertIdx1234].setFaceArea(faceVol23, 2, 1);
901 interactionVolumes_[globalVertIdx1234].setFaceArea(faceVol34, 2, 0);
902 interactionVolumes_[globalVertIdx1234].setFaceArea(faceVol34, 3, 1);
903 interactionVolumes_[globalVertIdx1234].setFacePosition(globalPosFace23, 1, 0);
904 interactionVolumes_[globalVertIdx1234].setFacePosition(globalPosFace23, 2, 1);
905 interactionVolumes_[globalVertIdx1234].setFacePosition(globalPosFace34, 2, 0);
906 interactionVolumes_[globalVertIdx1234].setFacePosition(globalPosFace34, 3, 1);
924 problem_.boundaryTypes(bcType, intersection14);
925 PrimaryVariables boundValues(0.0);
927 interactionVolumes_[globalVertIdx1234].setBoundary(bcType, 3);
928 if (bcType.isNeumann(pressEqIdx))
930 problem_.neumann(boundValues, intersection14);
931 boundValues *= faceVol41;
932 interactionVolumes_[globalVertIdx1234].setNeumannCondition(boundValues, 3);
934 if (bcType.hasDirichlet())
936 problem_.dirichlet(boundValues, intersection14);
937 interactionVolumes_[globalVertIdx1234].setDirichletCondition(boundValues, 3);
944 GlobalPosition globalPosFace23(0);
947 Scalar faceVol23 = 0;
950 DimVector unitOuterNormal23(0);
952 bool finished =
false;
954 for (
const auto& intersection2
955 : intersections(problem_.gridView(), element2))
957 if (intersection2.boundary())
959 for (
int i = 0; i < intersection2.geometry().corners(); ++i)
961 int localVertIdx2corner = refElement.subEntity(intersection2.indexInInside(), dim - 1, i,
964 int globalVertIdx2corner = problem_.variables().index(
965 element2.template subEntity < dim > (localVertIdx2corner));
967 if (globalVertIdx2corner == globalVertIdx1234)
969 interactionVolumes_[globalVertIdx1234].setIndexOnElement(intersection2.indexInInside(), 1,
972 globalPosFace23 = intersection2.geometry().center();
974 faceVol23 = intersection2.geometry().volume() / 2.0;
976 unitOuterNormal23 = intersection2.centerUnitOuterNormal();
978 interactionVolumes_[globalVertIdx1234].setNormal(unitOuterNormal23, 1, 0);
979 interactionVolumes_[globalVertIdx1234].setFaceArea(faceVol23, 1, 0);
980 interactionVolumes_[globalVertIdx1234].setFacePosition(globalPosFace23, 1, 0);
982 problem_.boundaryTypes(bcType, intersection2);
985 interactionVolumes_[globalVertIdx1234].setBoundary(bcType, 1);
986 if (bcType.isNeumann(pressEqIdx))
988 problem_.neumann(boundValues, intersection2);
989 boundValues *= faceVol23;
990 interactionVolumes_[globalVertIdx1234].setNeumannCondition(boundValues, 1);
992 if (bcType.hasDirichlet())
994 problem_.dirichlet(boundValues, intersection2);
995 interactionVolumes_[globalVertIdx1234].setDirichletCondition(boundValues, 1);
998 interactionVolumes_[globalVertIdx1234].setOutsideFace(2);
1000 innerBoundaryVolumeFaces_[eIdxGlobal1][intersection12.indexInInside()] =
true;
1001 innerBoundaryVolumeFaces_[eIdxGlobal2][intersection12.indexInOutside()] =
true;
1017 Dune::NotImplemented,
1018 "fvmpfao2pfaboundpressure2p.hh, l. 997: boundary shape not available as interaction volume shape");
1026 problem_.boundaryTypes(bcType, intersection12);
1027 PrimaryVariables boundValues(0.0);
1029 interactionVolumes_[globalVertIdx1234].setBoundary(bcType, 0);
1030 if (bcType.isNeumann(pressEqIdx))
1032 problem_.neumann(boundValues, intersection12);
1033 boundValues *= faceVol12;
1034 interactionVolumes_[globalVertIdx1234].setNeumannCondition(boundValues, 0);
1036 if (bcType.hasDirichlet())
1038 problem_.dirichlet(boundValues, intersection12);
1039 interactionVolumes_[globalVertIdx1234].setDirichletCondition(boundValues, 0);
1043 if (intersection14.boundary())
1045 problem_.boundaryTypes(bcType, intersection14);
1048 interactionVolumes_[globalVertIdx1234].setBoundary(bcType, 3);
1049 if (bcType.isNeumann(pressEqIdx))
1051 problem_.neumann(boundValues, intersection14);
1052 boundValues *= faceVol41;
1053 interactionVolumes_[globalVertIdx1234].setNeumannCondition(boundValues, 3);
1055 if (bcType.hasDirichlet())
1057 problem_.dirichlet(boundValues, intersection14);
1058 interactionVolumes_[globalVertIdx1234].setDirichletCondition(boundValues, 3);
1061 interactionVolumes_[globalVertIdx1234].setOutsideFace(1);
1062 interactionVolumes_[globalVertIdx1234].setOutsideFace(2);
1070 auto element4 = intersection14.outside();
1071 interactionVolumes_[globalVertIdx1234].setIndexOnElement(intersection14.indexInOutside(), 3, 0);
1074 interactionVolumes_[globalVertIdx1234].setSubVolumeElement(element4, 3);
1076 interactionVolumes_[globalVertIdx1234].setNormal(unitOuterNormal14, 3, 0);
1077 interactionVolumes_[globalVertIdx1234].setFaceArea(faceVol41, 3, 0);
1078 interactionVolumes_[globalVertIdx1234].setFacePosition(globalPosFace41, 3, 0);
1080 int eIdxGlobal4 = problem_.variables().index(element4);
1082 bool finished =
false;
1085 for (
const auto& intersection4
1086 : intersections(problem_.gridView(), element4))
1088 if (intersection4.boundary())
1090 for (
int i = 0; i < intersection4.geometry().corners(); ++i)
1092 int localVertIdx4corner = refElement.subEntity(intersection4.indexInInside(), dim - 1, i,
1095 int globalVertIdx4corner = problem_.variables().index(
1096 (element4).
template subEntity < dim > (localVertIdx4corner));
1098 if (globalVertIdx4corner == globalVertIdx1234)
1100 interactionVolumes_[globalVertIdx1234].setIndexOnElement(intersection4.indexInInside(), 3,
1103 const GlobalPosition& globalPosFace34 = intersection4.geometry().center();
1105 Scalar faceVol34 = intersection4.geometry().volume() / 2.0;
1107 DimVector unitOuterNormal43 = intersection4.centerUnitOuterNormal();
1109 interactionVolumes_[globalVertIdx1234].setNormal(unitOuterNormal43, 3, 1);
1110 interactionVolumes_[globalVertIdx1234].setFaceArea(faceVol34, 3, 1);
1111 interactionVolumes_[globalVertIdx1234].setFacePosition(globalPosFace34, 3, 1);
1113 problem_.boundaryTypes(bcType, intersection4);
1116 interactionVolumes_[globalVertIdx1234].setBoundary(bcType, 2);
1117 if (bcType.isNeumann(pressEqIdx))
1119 problem_.neumann(boundValues, intersection4);
1120 boundValues *= faceVol34;
1121 interactionVolumes_[globalVertIdx1234].setNeumannCondition(boundValues, 2);
1123 if (bcType.hasDirichlet())
1125 problem_.dirichlet(boundValues, intersection4);
1126 interactionVolumes_[globalVertIdx1234].setDirichletCondition(boundValues, 2);
1129 interactionVolumes_[globalVertIdx1234].setOutsideFace(1);
1131 innerBoundaryVolumeFaces_[eIdxGlobal1][intersection14.indexInInside()] =
true;
1132 innerBoundaryVolumeFaces_[eIdxGlobal4][intersection14.indexInOutside()] =
true;
1148 Dune::NotImplemented,
1149 "fvmpfao2pfaboundpressure2p.hh, l. 1164: boundary shape not available as interaction volume shape");
1162template<
class TypeTag>
1163void FvMpfaL2dPressure2p<TypeTag>::assemble()
1170 for (
const auto& vertex : vertices(problem_.gridView()))
1172 int vIdxGlobal = problem_.variables().index(vertex);
1174 InteractionVolume& interactionVolume = interactionVolumes_[vIdxGlobal];
1176 if (interactionVolume.isInnerVolume())
1179 auto element1 = interactionVolume.getSubVolumeElement(0);
1180 auto element2 = interactionVolume.getSubVolumeElement(1);
1181 auto element3 = interactionVolume.getSubVolumeElement(2);
1182 auto element4 = interactionVolume.getSubVolumeElement(3);
1185 const GlobalPosition& globalPos1 = element1.geometry().center();
1186 const GlobalPosition& globalPos2 = element2.geometry().center();
1187 const GlobalPosition& globalPos3 = element3.geometry().center();
1188 const GlobalPosition& globalPos4 = element4.geometry().center();
1191 Scalar volume1 = element1.geometry().volume();
1192 Scalar volume2 = element2.geometry().volume();
1193 Scalar volume3 = element3.geometry().volume();
1194 Scalar volume4 = element4.geometry().volume();
1197 int eIdxGlobal1 = problem_.variables().index(element1);
1198 int eIdxGlobal2 = problem_.variables().index(element2);
1199 int eIdxGlobal3 = problem_.variables().index(element3);
1200 int eIdxGlobal4 = problem_.variables().index(element4);
1203 CellData& cellData1 = problem_.variables().cellData(eIdxGlobal1);
1204 CellData& cellData2 = problem_.variables().cellData(eIdxGlobal2);
1205 CellData& cellData3 = problem_.variables().cellData(eIdxGlobal3);
1206 CellData& cellData4 = problem_.variables().cellData(eIdxGlobal4);
1209 PrimaryVariables source(0.0);
1210 problem_.source(source, element1);
1211 this->f_[eIdxGlobal1] += volume1 / (4.0) * (source[wPhaseIdx] / density_[wPhaseIdx] + source[nPhaseIdx] / density_[nPhaseIdx]);
1212 problem_.source(source, element2);
1213 this->f_[eIdxGlobal2] += volume2 / (4.0) * (source[wPhaseIdx] / density_[wPhaseIdx] + source[nPhaseIdx] / density_[nPhaseIdx]);
1214 problem_.source(source, element3);
1215 this->f_[eIdxGlobal3] += volume3 / (4.0) * (source[wPhaseIdx] / density_[wPhaseIdx] + source[nPhaseIdx] / density_[nPhaseIdx]);
1216 problem_.source(source, element4);
1217 this->f_[eIdxGlobal4] += volume4 / (4.0) * (source[wPhaseIdx] / density_[wPhaseIdx] + source[nPhaseIdx] / density_[nPhaseIdx]);
1219 this->f_[eIdxGlobal1] += evaluateErrorTerm_(cellData1) * volume1 / (4.0);
1220 this->f_[eIdxGlobal2] += evaluateErrorTerm_(cellData2) * volume2 / (4.0);
1221 this->f_[eIdxGlobal3] += evaluateErrorTerm_(cellData3) * volume3 / (4.0);
1222 this->f_[eIdxGlobal4] += evaluateErrorTerm_(cellData4) * volume4 / (4.0);
1225 Dune::FieldVector<Scalar, numPhases> lambda1(cellData1.mobility(wPhaseIdx));
1226 lambda1[nPhaseIdx] = cellData1.mobility(nPhaseIdx);
1229 Scalar lambdaTotal1 = lambda1[wPhaseIdx] + lambda1[nPhaseIdx];
1232 Dune::FieldVector<Scalar, numPhases> lambda2(cellData2.mobility(wPhaseIdx));
1233 lambda2[nPhaseIdx] = cellData2.mobility(nPhaseIdx);
1236 Scalar lambdaTotal2 = lambda2[wPhaseIdx] + lambda2[nPhaseIdx];
1239 Dune::FieldVector<Scalar, numPhases> lambda3(cellData3.mobility(wPhaseIdx));
1240 lambda3[nPhaseIdx] = cellData3.mobility(nPhaseIdx);
1243 Scalar lambdaTotal3 = lambda3[wPhaseIdx] + lambda3[nPhaseIdx];
1246 Dune::FieldVector<Scalar, numPhases> lambda4(cellData4.mobility(wPhaseIdx));
1247 lambda4[nPhaseIdx] = cellData4.mobility(nPhaseIdx);
1250 Scalar lambdaTotal4 = lambda4[wPhaseIdx] + lambda4[nPhaseIdx];
1252 std::vector<DimVector > lambda(2*dim);
1254 lambda[0][0] = lambdaTotal1;
1255 lambda[0][1] = lambdaTotal1;
1256 lambda[1][0] = lambdaTotal2;
1257 lambda[1][1] = lambdaTotal2;
1258 lambda[2][0] = lambdaTotal3;
1259 lambda[2][1] = lambdaTotal3;
1260 lambda[3][0] = lambdaTotal4;
1261 lambda[3][1] = lambdaTotal4;
1265 Dune::FieldVector<Scalar, 2 * dim> pc(0);
1266 pc[0] = cellData1.capillaryPressure();
1267 pc[1] = cellData2.capillaryPressure();
1268 pc[2] = cellData3.capillaryPressure();
1269 pc[3] = cellData4.capillaryPressure();
1271 Dune::FieldVector<Scalar, 2 * dim> gravityDiff(0);
1275 gravityDiff[0] = (problem_.bBoxMax() - globalPos1) * gravity_ * (density_[nPhaseIdx] - density_[wPhaseIdx]);
1276 gravityDiff[1] = (problem_.bBoxMax() - globalPos2) * gravity_ * (density_[nPhaseIdx] - density_[wPhaseIdx]);
1277 gravityDiff[2] = (problem_.bBoxMax() - globalPos3) * gravity_ * (density_[nPhaseIdx] - density_[wPhaseIdx]);
1278 gravityDiff[3] = (problem_.bBoxMax() - globalPos4) * gravity_ * (density_[nPhaseIdx] - density_[wPhaseIdx]);
1282 Dune::FieldVector<Scalar, 2 * dim> pcFlux(0);
1284 Scalar pcPotential12 = 0;
1285 Scalar pcPotential14 = 0;
1286 Scalar pcPotential32 = 0;
1287 Scalar pcPotential34 = 0;
1290 Dune::FieldVector<Scalar, 2 * dim - dim + 1> u(0);
1291 Dune::FieldMatrix<Scalar,dim,2*dim-dim+1> T(0);
1293 int lType = transmissibilityCalculator_.calculateTransmissibility(T, interactionVolume, lambda, 0, 1, 2, 3);
1295 if (lType == TransmissibilityCalculator::rightTriangle)
1297 if (innerBoundaryVolumeFaces_[eIdxGlobal1][interactionVolume.getIndexOnElement(0, 0)])
1301 this->A_[eIdxGlobal1][eIdxGlobal2] += T[1][0];
1302 this->A_[eIdxGlobal1][eIdxGlobal3] += T[1][1];
1303 this->A_[eIdxGlobal1][eIdxGlobal1] += T[1][2];
1305 this->A_[eIdxGlobal2][eIdxGlobal2] -= T[1][0];
1306 this->A_[eIdxGlobal2][eIdxGlobal3] -= T[1][1];
1307 this->A_[eIdxGlobal2][eIdxGlobal1] -= T[1][2];
1316 pcPotential12 = Tu[1];
1320 if (innerBoundaryVolumeFaces_[eIdxGlobal1][interactionVolume.getIndexOnElement(0, 0)])
1324 this->A_[eIdxGlobal1][eIdxGlobal1] += T[1][0];
1325 this->A_[eIdxGlobal1][eIdxGlobal4] += T[1][1];
1326 this->A_[eIdxGlobal1][eIdxGlobal2] += T[1][2];
1328 this->A_[eIdxGlobal2][eIdxGlobal1] -= T[1][0];
1329 this->A_[eIdxGlobal2][eIdxGlobal4] -= T[1][1];
1330 this->A_[eIdxGlobal2][eIdxGlobal2] -= T[1][2];
1339 pcPotential12 = Tu[1];
1342 lType = transmissibilityCalculator_.calculateTransmissibility(T, interactionVolume, lambda, 1, 2, 3, 0);
1344 if (lType == TransmissibilityCalculator::rightTriangle)
1346 if (innerBoundaryVolumeFaces_[eIdxGlobal2][interactionVolume.getIndexOnElement(1, 0)])
1350 this->A_[eIdxGlobal2][eIdxGlobal3] += T[1][0];
1351 this->A_[eIdxGlobal2][eIdxGlobal4] += T[1][1];
1352 this->A_[eIdxGlobal2][eIdxGlobal2] += T[1][2];
1354 this->A_[eIdxGlobal3][eIdxGlobal3] -= T[1][0];
1355 this->A_[eIdxGlobal3][eIdxGlobal4] -= T[1][1];
1356 this->A_[eIdxGlobal3][eIdxGlobal2] -= T[1][2];
1365 pcPotential32 = -Tu[1];
1369 if (innerBoundaryVolumeFaces_[eIdxGlobal2][interactionVolume.getIndexOnElement(1, 0)])
1373 this->A_[eIdxGlobal2][eIdxGlobal2] += T[1][0];
1374 this->A_[eIdxGlobal2][eIdxGlobal1] += T[1][1];
1375 this->A_[eIdxGlobal2][eIdxGlobal3] += T[1][2];
1377 this->A_[eIdxGlobal3][eIdxGlobal2] -= T[1][0];
1378 this->A_[eIdxGlobal3][eIdxGlobal1] -= T[1][1];
1379 this->A_[eIdxGlobal3][eIdxGlobal3] -= T[1][2];
1388 pcPotential32 = -Tu[1];
1391 lType = transmissibilityCalculator_.calculateTransmissibility(T, interactionVolume, lambda, 2, 3, 0, 1);
1393 if (lType == TransmissibilityCalculator::rightTriangle)
1395 if (innerBoundaryVolumeFaces_[eIdxGlobal3][interactionVolume.getIndexOnElement(2, 0)])
1399 this->A_[eIdxGlobal3][eIdxGlobal4] += T[1][0];
1400 this->A_[eIdxGlobal3][eIdxGlobal1] += T[1][1];
1401 this->A_[eIdxGlobal3][eIdxGlobal3] += T[1][2];
1403 this->A_[eIdxGlobal4][eIdxGlobal4] -= T[1][0];
1404 this->A_[eIdxGlobal4][eIdxGlobal1] -= T[1][1];
1405 this->A_[eIdxGlobal4][eIdxGlobal3] -= T[1][2];
1414 pcPotential34 = Tu[1];
1418 if (innerBoundaryVolumeFaces_[eIdxGlobal3][interactionVolume.getIndexOnElement(2, 0)])
1422 this->A_[eIdxGlobal3][eIdxGlobal3] += T[1][0];
1423 this->A_[eIdxGlobal3][eIdxGlobal2] += T[1][1];
1424 this->A_[eIdxGlobal3][eIdxGlobal4] += T[1][2];
1426 this->A_[eIdxGlobal4][eIdxGlobal3] -= T[1][0];
1427 this->A_[eIdxGlobal4][eIdxGlobal2] -= T[1][1];
1428 this->A_[eIdxGlobal4][eIdxGlobal4] -= T[1][2];
1437 pcPotential34 = Tu[1];
1440 lType = transmissibilityCalculator_.calculateTransmissibility(T, interactionVolume, lambda, 3, 0, 1, 2);
1442 if (lType == TransmissibilityCalculator::rightTriangle)
1444 if (innerBoundaryVolumeFaces_[eIdxGlobal4][interactionVolume.getIndexOnElement(3, 0)])
1448 this->A_[eIdxGlobal4][eIdxGlobal1] += T[1][0];
1449 this->A_[eIdxGlobal4][eIdxGlobal2] += T[1][1];
1450 this->A_[eIdxGlobal4][eIdxGlobal4] += T[1][2];
1452 this->A_[eIdxGlobal1][eIdxGlobal1] -= T[1][0];
1453 this->A_[eIdxGlobal1][eIdxGlobal2] -= T[1][1];
1454 this->A_[eIdxGlobal1][eIdxGlobal4] -= T[1][2];
1463 pcPotential14 = -Tu[1];
1467 if (innerBoundaryVolumeFaces_[eIdxGlobal4][interactionVolume.getIndexOnElement(3, 0)])
1471 this->A_[eIdxGlobal4][eIdxGlobal4] += T[1][0];
1472 this->A_[eIdxGlobal4][eIdxGlobal3] += T[1][1];
1473 this->A_[eIdxGlobal4][eIdxGlobal1] += T[1][2];
1475 this->A_[eIdxGlobal1][eIdxGlobal4] -= T[1][0];
1476 this->A_[eIdxGlobal1][eIdxGlobal3] -= T[1][1];
1477 this->A_[eIdxGlobal1][eIdxGlobal1] -= T[1][2];
1486 pcPotential14 = -Tu[1];
1489 if (pc[0] == 0 && pc[1] == 0 && pc[2] == 0 && pc[3] == 0)
1495 Dune::FieldVector<Scalar, numPhases> lambda12Upw(0.0);
1496 lambda12Upw[wPhaseIdx] = (pcPotential12 >= 0) ? lambda1[wPhaseIdx] : lambda2[wPhaseIdx];
1497 lambda12Upw[nPhaseIdx] = (pcPotential12 >= 0) ? lambda1[nPhaseIdx] : lambda2[nPhaseIdx];
1500 Dune::FieldVector<Scalar, numPhases> lambda14Upw(0.0);
1501 lambda14Upw[wPhaseIdx] = (pcPotential14 >= 0) ? lambda1[wPhaseIdx] : lambda4[wPhaseIdx];
1502 lambda14Upw[nPhaseIdx] = (pcPotential14 >= 0) ? lambda1[nPhaseIdx] : lambda4[nPhaseIdx];
1505 Dune::FieldVector<Scalar, numPhases> lambda32Upw(0.0);
1506 lambda32Upw[wPhaseIdx] = (pcPotential32 >= 0) ? lambda3[wPhaseIdx] : lambda2[wPhaseIdx];
1507 lambda32Upw[nPhaseIdx] = (pcPotential32 >= 0) ? lambda3[nPhaseIdx] : lambda2[nPhaseIdx];
1510 Dune::FieldVector<Scalar, numPhases> lambda34Upw(0.0);
1511 lambda34Upw[wPhaseIdx] = (pcPotential34 >= 0) ? lambda3[wPhaseIdx] : lambda4[wPhaseIdx];
1512 lambda34Upw[nPhaseIdx] = (pcPotential34 >= 0) ? lambda3[nPhaseIdx] : lambda4[nPhaseIdx];
1514 for (
int i = 0; i < numPhases; i++)
1516 Scalar lambdaT12 = lambda12Upw[wPhaseIdx] + lambda12Upw[nPhaseIdx];
1517 Scalar lambdaT14 = lambda14Upw[wPhaseIdx] + lambda14Upw[nPhaseIdx];
1518 Scalar lambdaT32 = lambda32Upw[wPhaseIdx] + lambda32Upw[nPhaseIdx];
1519 Scalar lambdaT34 = lambda34Upw[wPhaseIdx] + lambda34Upw[nPhaseIdx];
1520 Scalar fracFlow12 = (lambdaT12 > threshold_) ? lambda12Upw[i] / (lambdaT12) : 0.0;
1521 Scalar fracFlow14 = (lambdaT14 > threshold_) ? lambda14Upw[i] / (lambdaT14) : 0.0;
1522 Scalar fracFlow32 = (lambdaT32 > threshold_) ? lambda32Upw[i] / (lambdaT32) : 0.0;
1523 Scalar fracFlow34 = (lambdaT34 > threshold_) ? lambda34Upw[i] / (lambdaT34) : 0.0;
1525 Dune::FieldVector<Scalar, 2 * dim> pcFluxReal(pcFlux);
1527 pcFluxReal[0] *= fracFlow12;
1528 pcFluxReal[1] *= fracFlow32;
1529 pcFluxReal[2] *= fracFlow34;
1530 pcFluxReal[3] *= fracFlow14;
1535 switch (pressureType_)
1542 this->f_[eIdxGlobal1] -= (pcFluxReal[0] - pcFluxReal[3]);
1543 this->f_[eIdxGlobal2] -= (pcFluxReal[1] - pcFluxReal[0]);
1544 this->f_[eIdxGlobal3] -= (pcFluxReal[2] - pcFluxReal[1]);
1545 this->f_[eIdxGlobal4] -= (pcFluxReal[3] - pcFluxReal[2]);
1555 this->f_[eIdxGlobal1] += (pcFluxReal[0] - pcFluxReal[3]);
1556 this->f_[eIdxGlobal2] += (pcFluxReal[1] - pcFluxReal[0]);
1557 this->f_[eIdxGlobal3] += (pcFluxReal[2] - pcFluxReal[1]);
1558 this->f_[eIdxGlobal4] += (pcFluxReal[3] - pcFluxReal[2]);
1569 for (
int elemIdx = 0; elemIdx < 2 * dim; elemIdx++)
1571 bool isOutside =
false;
1572 for (
int fIdx = 0; fIdx < dim; fIdx++)
1574 int intVolFaceIdx = interactionVolume.getFaceIndexFromSubVolume(elemIdx, fIdx);
1575 if (interactionVolume.isOutsideFace(intVolFaceIdx))
1586 auto element = interactionVolume.getSubVolumeElement(elemIdx);
1589 const GlobalPosition& globalPos =
element.geometry().center();
1595 int eIdxGlobal = problem_.variables().index(element);
1598 CellData& cellData = problem_.variables().cellData(eIdxGlobal);
1601 DimMatrix
permeability(problem_.spatialParams().intrinsicPermeability(element));
1604 PrimaryVariables source(0);
1605 problem_.source(source, element);
1606 this->f_[eIdxGlobal] +=
volume / (4.0) * (source[wPhaseIdx] / density_[wPhaseIdx] + source[nPhaseIdx] / density_[nPhaseIdx]);
1608 this->f_[eIdxGlobal] += evaluateErrorTerm_(cellData) *
volume / (4.0);
1611 Dune::FieldVector<Scalar, numPhases> lambda(cellData.mobility(wPhaseIdx));
1612 lambda[nPhaseIdx] = cellData.mobility(nPhaseIdx);
1614 Scalar pc = cellData.capillaryPressure();
1616 Scalar gravityDiff = (problem_.bBoxMax() - globalPos) * gravity_ * (density_[nPhaseIdx] - density_[wPhaseIdx]);
1620 for (
int fIdx = 0; fIdx < dim; fIdx++)
1622 int intVolFaceIdx = interactionVolume.getFaceIndexFromSubVolume(elemIdx, fIdx);
1624 if (interactionVolume.isBoundaryFace(intVolFaceIdx))
1627 if (interactionVolume.getBoundaryType(intVolFaceIdx).isDirichlet(pressEqIdx))
1629 int boundaryFaceIdx = interactionVolume.getIndexOnElement(elemIdx, fIdx);
1631 const auto refElement = referenceElement(element);
1633 const LocalPosition& localPos = refElement.position(boundaryFaceIdx, 1);
1635 const GlobalPosition& globalPosFace =
element.geometry().global(localPos);
1637 DimVector distVec(globalPosFace - globalPos);
1638 Scalar dist = distVec.two_norm();
1639 DimVector unitDistVec(distVec);
1640 unitDistVec /= dist;
1642 Scalar faceArea = interactionVolume.getFaceArea(elemIdx, fIdx);
1645 Scalar satWBound = cellData.saturation(wPhaseIdx);
1647 if (interactionVolume.getBoundaryType(intVolFaceIdx).isDirichlet(satEqIdx))
1649 Scalar satBound = interactionVolume.getDirichletValues(intVolFaceIdx)[saturationIdx];
1650 switch (saturationType_)
1654 satWBound = satBound;
1659 satWBound = 1 - satBound;
1666 const auto fluidMatrixInteraction = problem_.spatialParams().fluidMatrixInteractionAtPos(
element.geometry().center());
1667 Scalar pcBound = fluidMatrixInteraction.pc(satWBound);
1669 Scalar gravityDiffBound = (problem_.bBoxMax() - globalPosFace) * gravity_
1670 * (density_[nPhaseIdx] - density_[wPhaseIdx]);
1672 pcBound += gravityDiffBound;
1674 Dune::FieldVector<Scalar, numPhases> lambdaBound(fluidMatrixInteraction.krw(satWBound));
1675 lambdaBound[nPhaseIdx] = fluidMatrixInteraction.krn(satWBound);
1676 lambdaBound[wPhaseIdx] /= viscosity_[wPhaseIdx];
1677 lambdaBound[nPhaseIdx] /= viscosity_[nPhaseIdx];
1679 Scalar potentialBound = interactionVolume.getDirichletValues(intVolFaceIdx)[pressureIdx];
1680 Scalar gdeltaZ = (problem_.bBoxMax()-globalPosFace) * gravity_;
1683 Scalar potentialDiffW = 0;
1684 Scalar potentialDiffNw = 0;
1685 switch (pressureType_)
1689 potentialBound += density_[wPhaseIdx]*gdeltaZ;
1690 potentialDiffW = (cellData.potential(wPhaseIdx) - potentialBound) / dist;
1691 potentialDiffNw = (cellData.potential(nPhaseIdx) - potentialBound - pcBound) / dist;
1696 potentialBound += density_[nPhaseIdx]*gdeltaZ;
1697 potentialDiffW = (cellData.potential(wPhaseIdx) - potentialBound + pcBound) / dist;
1698 potentialDiffNw = (cellData.potential(nPhaseIdx) - potentialBound) / dist;
1703 Scalar lambdaTotal = (potentialDiffW >= 0.) ? lambda[wPhaseIdx] : lambdaBound[wPhaseIdx];
1704 lambdaTotal += (potentialDiffNw >= 0.) ? lambda[nPhaseIdx] : lambdaBound[nPhaseIdx];
1706 DimVector permTimesNormal(0);
1710 Scalar entry = lambdaTotal * (unitDistVec * permTimesNormal) / dist * faceArea;
1715 switch (pressureType_)
1720 DimVector pcGradient = unitDistVec;
1721 pcGradient *= (pc - pcBound) / dist;
1724 pcFlux = 0.5 * (lambda[nPhaseIdx] + lambdaBound[nPhaseIdx])
1725 * (permTimesNormal * pcGradient) * faceArea;
1732 DimVector pcGradient = unitDistVec;
1733 pcGradient *= (pc - pcBound) / dist;
1736 pcFlux = 0.5 * (lambda[wPhaseIdx] + lambdaBound[wPhaseIdx])
1737 * (permTimesNormal * pcGradient) * faceArea;
1745 this->A_[eIdxGlobal][eIdxGlobal] += entry;
1746 this->f_[eIdxGlobal] += entry * potentialBound;
1748 if (pc == 0 && pcBound == 0)
1753 for (
int i = 0; i < numPhases; i++)
1755 switch (pressureType_)
1762 this->f_[eIdxGlobal] -= pcFlux;
1771 this->f_[eIdxGlobal] += pcFlux;
1779 else if (interactionVolume.getBoundaryType(intVolFaceIdx).isNeumann(pressEqIdx))
1781 Scalar J = interactionVolume.getNeumannValues(intVolFaceIdx)[wPhaseIdx] / density_[wPhaseIdx];
1782 J += interactionVolume.getNeumannValues(intVolFaceIdx)[nPhaseIdx] / density_[nPhaseIdx];
1784 this->f_[eIdxGlobal] -= J;
1788 std::cout <<
"interactionVolume.getBoundaryType(intVolFaceIdx).isNeumann(pressEqIdx)"
1789 << interactionVolume.getBoundaryType(intVolFaceIdx).isNeumann(pressEqIdx) <<
"\n";
1790 DUNE_THROW(Dune::NotImplemented,
1791 "No valid boundary condition type defined for pressure equation!");
1802 if (problem_.gridView().comm().size() > 1)
1805 for (
const auto& element : elements(problem_.gridView()))
1807 if (
element.partitionType() == Dune::InteriorEntity)
1811 int eIdxGlobalI = problem_.variables().index(element);
1813 this->A_[eIdxGlobalI] = 0.0;
1814 this->A_[eIdxGlobalI][eIdxGlobalI] = 1.0;
1815 this->f_[eIdxGlobalI] = this->
pressure()[eIdxGlobalI];
1827template<
class TypeTag>
1831 for (
const auto& element : elements(problem_.gridView()))
1833 int eIdxGlobal = problem_.variables().index(element);
1835 CellData& cellData = problem_.variables().cellData(eIdxGlobal);
1837 Scalar satW = cellData.saturation(wPhaseIdx);
1839 const auto fluidMatrixInteraction = problem_.spatialParams().fluidMatrixInteractionAtPos(element.geometry().center());
1840 const Scalar pc = fluidMatrixInteraction.pc(satW);
1842 cellData.setCapillaryPressure(pc);
1845 const Scalar mobilityW = fluidMatrixInteraction.krw(satW) / viscosity_[wPhaseIdx];
1846 const Scalar mobilityNw = fluidMatrixInteraction.krn(satW) / viscosity_[nPhaseIdx];
1849 cellData.setMobility(wPhaseIdx, mobilityW);
1850 cellData.setMobility(nPhaseIdx, mobilityNw);
1853 cellData.setFracFlowFunc(wPhaseIdx, mobilityW / (mobilityW + mobilityNw));
1854 cellData.setFracFlowFunc(nPhaseIdx, mobilityNw / (mobilityW + mobilityNw));
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...
typename Properties::Detail::GetPropImpl< TypeTag, Property >::type GetProp
get the type of a property
Definition: propertysystem.hh:141
typename Properties::Detail::GetPropImpl< TypeTag, Property >::type::type GetPropType
get the type alias defined in the property
Definition: propertysystem.hh:150
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
Scalar volume(Shape shape, Scalar inscribedRadius)
Returns the volume of a given geometry based on the inscribed radius.
Definition: poreproperties.hh:73
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:449
void storePressureSolution(const Element &element)
Stores the pressure solution of a cell.
Definition: lmethod/2dpressure.hh:238
void update()
Pressure update.
Definition: lmethod/2dpressure.hh:288
void initialize()
Initializes the pressure model.
Definition: lmethod/2dpressure.hh:191
void updateInteractionVolumeInfo()
Updates interaction volumes.
Definition: lmethod/2dpressure.hh:177
FvMpfaL2dPressure2p(Problem &problem)
Constructs a FvMpfaL2dPressure2p object.
Definition: lmethod/2dpressure.hh:408
GlobalInteractionVolumeVector interactionVolumes_
Global Vector of interaction volumes.
Definition: lmethod/2dpressure.hh:448
void storePressureSolution()
Globally stores the pressure solution.
Definition: lmethod/2dpressure.hh:225
void addOutputVtkFields(MultiWriter &writer)
Adds pressure output to the output file.
Definition: lmethod/2dpressure.hh:337
FvMpfaL2dTransmissibilityCalculator< TypeTag > TransmissibilityCalculator
Definition: lmethod/2dpressure.hh:149
void updateMaterialLaws()
constitutive functions are initialized and stored in the variables object
Definition: lmethod/2dpressure.hh:1828
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:49
void initialize()
Initialize pressure model.
Definition: sequential/cellcentered/pressure.hh:213
PressureSolution & pressure()
Returns the vector containing the pressure solution.
Definition: sequential/cellcentered/pressure.hh:120
void solve()
Solves the global system of equations to get the spatial distribution of the pressure.
Definition: sequential/cellcentered/pressure.hh:527
Specifies the properties for immiscible 2p diffusion/pressure models.
Properties for a MPFA method.
Finite Volume Diffusion Model.