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>;
87 using MaterialLaw =
typename SpatialParams::MaterialLaw;
99 using PrimaryVariables =
typename SolutionTypes::PrimaryVariables;
100 using ScalarSolutionType =
typename SolutionTypes::ScalarSolution;
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,
119 numPhases = getPropValue<TypeTag, Properties::NumPhases>()
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!");
424 if (getPropValue<TypeTag, Properties::EnableCompressibility>())
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_ = getPropValue<TypeTag, Properties::PressureFormulation>();
472 static const int saturationType_ = getPropValue<TypeTag, Properties::SaturationFormulation>();
474 static const int velocityType_ = getPropValue<TypeTag, Properties::VelocityFormulation>();
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;
543 switch (getPropValue<TypeTag, Properties::GridImplementation>())
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
855 : intersections(problem_.gridView(), element2))
857 bool finished =
false;
859 for (
const auto& intersection43
860 : intersections(problem_.gridView(), element4))
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
958 : intersections(problem_.gridView(), element2))
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
1089 : intersections(problem_.gridView(), element4))
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;
1151 Dune::NotImplemented,
1152 "fvmpfao2pfaboundpressure2p.hh, l. 1164: boundary shape not available as interaction volume shape");
1165template<
class TypeTag>
1166void FvMpfaL2dPressure2p<TypeTag>::assemble()
1173 for (
const auto& vertex : vertices(problem_.gridView()))
1175 int vIdxGlobal = problem_.variables().index(vertex);
1177 InteractionVolume& interactionVolume = interactionVolumes_[vIdxGlobal];
1179 if (interactionVolume.isInnerVolume())
1182 auto element1 = interactionVolume.getSubVolumeElement(0);
1183 auto element2 = interactionVolume.getSubVolumeElement(1);
1184 auto element3 = interactionVolume.getSubVolumeElement(2);
1185 auto element4 = interactionVolume.getSubVolumeElement(3);
1188 const GlobalPosition& globalPos1 = element1.geometry().center();
1189 const GlobalPosition& globalPos2 = element2.geometry().center();
1190 const GlobalPosition& globalPos3 = element3.geometry().center();
1191 const GlobalPosition& globalPos4 = element4.geometry().center();
1194 Scalar volume1 = element1.geometry().volume();
1195 Scalar volume2 = element2.geometry().volume();
1196 Scalar volume3 = element3.geometry().volume();
1197 Scalar volume4 = element4.geometry().volume();
1200 int eIdxGlobal1 = problem_.variables().index(element1);
1201 int eIdxGlobal2 = problem_.variables().index(element2);
1202 int eIdxGlobal3 = problem_.variables().index(element3);
1203 int eIdxGlobal4 = problem_.variables().index(element4);
1206 CellData& cellData1 = problem_.variables().cellData(eIdxGlobal1);
1207 CellData& cellData2 = problem_.variables().cellData(eIdxGlobal2);
1208 CellData& cellData3 = problem_.variables().cellData(eIdxGlobal3);
1209 CellData& cellData4 = problem_.variables().cellData(eIdxGlobal4);
1212 PrimaryVariables source(0.0);
1213 problem_.source(source, element1);
1214 this->f_[eIdxGlobal1] += volume1 / (4.0) * (source[wPhaseIdx] / density_[wPhaseIdx] + source[nPhaseIdx] / density_[nPhaseIdx]);
1215 problem_.source(source, element2);
1216 this->f_[eIdxGlobal2] += volume2 / (4.0) * (source[wPhaseIdx] / density_[wPhaseIdx] + source[nPhaseIdx] / density_[nPhaseIdx]);
1217 problem_.source(source, element3);
1218 this->f_[eIdxGlobal3] += volume3 / (4.0) * (source[wPhaseIdx] / density_[wPhaseIdx] + source[nPhaseIdx] / density_[nPhaseIdx]);
1219 problem_.source(source, element4);
1220 this->f_[eIdxGlobal4] += volume4 / (4.0) * (source[wPhaseIdx] / density_[wPhaseIdx] + source[nPhaseIdx] / density_[nPhaseIdx]);
1222 this->f_[eIdxGlobal1] += evaluateErrorTerm_(cellData1) * volume1 / (4.0);
1223 this->f_[eIdxGlobal2] += evaluateErrorTerm_(cellData2) * volume2 / (4.0);
1224 this->f_[eIdxGlobal3] += evaluateErrorTerm_(cellData3) * volume3 / (4.0);
1225 this->f_[eIdxGlobal4] += evaluateErrorTerm_(cellData4) * volume4 / (4.0);
1228 Dune::FieldVector<Scalar, numPhases> lambda1(cellData1.mobility(wPhaseIdx));
1229 lambda1[nPhaseIdx] = cellData1.mobility(nPhaseIdx);
1232 Scalar lambdaTotal1 = lambda1[wPhaseIdx] + lambda1[nPhaseIdx];
1235 Dune::FieldVector<Scalar, numPhases> lambda2(cellData2.mobility(wPhaseIdx));
1236 lambda2[nPhaseIdx] = cellData2.mobility(nPhaseIdx);
1239 Scalar lambdaTotal2 = lambda2[wPhaseIdx] + lambda2[nPhaseIdx];
1242 Dune::FieldVector<Scalar, numPhases> lambda3(cellData3.mobility(wPhaseIdx));
1243 lambda3[nPhaseIdx] = cellData3.mobility(nPhaseIdx);
1246 Scalar lambdaTotal3 = lambda3[wPhaseIdx] + lambda3[nPhaseIdx];
1249 Dune::FieldVector<Scalar, numPhases> lambda4(cellData4.mobility(wPhaseIdx));
1250 lambda4[nPhaseIdx] = cellData4.mobility(nPhaseIdx);
1253 Scalar lambdaTotal4 = lambda4[wPhaseIdx] + lambda4[nPhaseIdx];
1255 std::vector<DimVector > lambda(2*dim);
1257 lambda[0][0] = lambdaTotal1;
1258 lambda[0][1] = lambdaTotal1;
1259 lambda[1][0] = lambdaTotal2;
1260 lambda[1][1] = lambdaTotal2;
1261 lambda[2][0] = lambdaTotal3;
1262 lambda[2][1] = lambdaTotal3;
1263 lambda[3][0] = lambdaTotal4;
1264 lambda[3][1] = lambdaTotal4;
1268 Dune::FieldVector<Scalar, 2 * dim> pc(0);
1269 pc[0] = cellData1.capillaryPressure();
1270 pc[1] = cellData2.capillaryPressure();
1271 pc[2] = cellData3.capillaryPressure();
1272 pc[3] = cellData4.capillaryPressure();
1274 Dune::FieldVector<Scalar, 2 * dim> gravityDiff(0);
1278 gravityDiff[0] = (problem_.bBoxMax() - globalPos1) * gravity_ * (density_[nPhaseIdx] - density_[wPhaseIdx]);
1279 gravityDiff[1] = (problem_.bBoxMax() - globalPos2) * gravity_ * (density_[nPhaseIdx] - density_[wPhaseIdx]);
1280 gravityDiff[2] = (problem_.bBoxMax() - globalPos3) * gravity_ * (density_[nPhaseIdx] - density_[wPhaseIdx]);
1281 gravityDiff[3] = (problem_.bBoxMax() - globalPos4) * gravity_ * (density_[nPhaseIdx] - density_[wPhaseIdx]);
1285 Dune::FieldVector<Scalar, 2 * dim> pcFlux(0);
1287 Scalar pcPotential12 = 0;
1288 Scalar pcPotential14 = 0;
1289 Scalar pcPotential32 = 0;
1290 Scalar pcPotential34 = 0;
1293 Dune::FieldVector<Scalar, 2 * dim - dim + 1> u(0);
1294 Dune::FieldMatrix<Scalar,dim,2*dim-dim+1> T(0);
1296 int lType = transmissibilityCalculator_.calculateTransmissibility(T, interactionVolume, lambda, 0, 1, 2, 3);
1298 if (lType == TransmissibilityCalculator::rightTriangle)
1300 if (innerBoundaryVolumeFaces_[eIdxGlobal1][interactionVolume.getIndexOnElement(0, 0)])
1304 this->A_[eIdxGlobal1][eIdxGlobal2] += T[1][0];
1305 this->A_[eIdxGlobal1][eIdxGlobal3] += T[1][1];
1306 this->A_[eIdxGlobal1][eIdxGlobal1] += T[1][2];
1308 this->A_[eIdxGlobal2][eIdxGlobal2] -= T[1][0];
1309 this->A_[eIdxGlobal2][eIdxGlobal3] -= T[1][1];
1310 this->A_[eIdxGlobal2][eIdxGlobal1] -= T[1][2];
1319 pcPotential12 = Tu[1];
1323 if (innerBoundaryVolumeFaces_[eIdxGlobal1][interactionVolume.getIndexOnElement(0, 0)])
1327 this->A_[eIdxGlobal1][eIdxGlobal1] += T[1][0];
1328 this->A_[eIdxGlobal1][eIdxGlobal4] += T[1][1];
1329 this->A_[eIdxGlobal1][eIdxGlobal2] += T[1][2];
1331 this->A_[eIdxGlobal2][eIdxGlobal1] -= T[1][0];
1332 this->A_[eIdxGlobal2][eIdxGlobal4] -= T[1][1];
1333 this->A_[eIdxGlobal2][eIdxGlobal2] -= T[1][2];
1342 pcPotential12 = Tu[1];
1345 lType = transmissibilityCalculator_.calculateTransmissibility(T, interactionVolume, lambda, 1, 2, 3, 0);
1347 if (lType == TransmissibilityCalculator::rightTriangle)
1349 if (innerBoundaryVolumeFaces_[eIdxGlobal2][interactionVolume.getIndexOnElement(1, 0)])
1353 this->A_[eIdxGlobal2][eIdxGlobal3] += T[1][0];
1354 this->A_[eIdxGlobal2][eIdxGlobal4] += T[1][1];
1355 this->A_[eIdxGlobal2][eIdxGlobal2] += T[1][2];
1357 this->A_[eIdxGlobal3][eIdxGlobal3] -= T[1][0];
1358 this->A_[eIdxGlobal3][eIdxGlobal4] -= T[1][1];
1359 this->A_[eIdxGlobal3][eIdxGlobal2] -= T[1][2];
1368 pcPotential32 = -Tu[1];
1372 if (innerBoundaryVolumeFaces_[eIdxGlobal2][interactionVolume.getIndexOnElement(1, 0)])
1376 this->A_[eIdxGlobal2][eIdxGlobal2] += T[1][0];
1377 this->A_[eIdxGlobal2][eIdxGlobal1] += T[1][1];
1378 this->A_[eIdxGlobal2][eIdxGlobal3] += T[1][2];
1380 this->A_[eIdxGlobal3][eIdxGlobal2] -= T[1][0];
1381 this->A_[eIdxGlobal3][eIdxGlobal1] -= T[1][1];
1382 this->A_[eIdxGlobal3][eIdxGlobal3] -= T[1][2];
1391 pcPotential32 = -Tu[1];
1394 lType = transmissibilityCalculator_.calculateTransmissibility(T, interactionVolume, lambda, 2, 3, 0, 1);
1396 if (lType == TransmissibilityCalculator::rightTriangle)
1398 if (innerBoundaryVolumeFaces_[eIdxGlobal3][interactionVolume.getIndexOnElement(2, 0)])
1402 this->A_[eIdxGlobal3][eIdxGlobal4] += T[1][0];
1403 this->A_[eIdxGlobal3][eIdxGlobal1] += T[1][1];
1404 this->A_[eIdxGlobal3][eIdxGlobal3] += T[1][2];
1406 this->A_[eIdxGlobal4][eIdxGlobal4] -= T[1][0];
1407 this->A_[eIdxGlobal4][eIdxGlobal1] -= T[1][1];
1408 this->A_[eIdxGlobal4][eIdxGlobal3] -= T[1][2];
1417 pcPotential34 = Tu[1];
1421 if (innerBoundaryVolumeFaces_[eIdxGlobal3][interactionVolume.getIndexOnElement(2, 0)])
1425 this->A_[eIdxGlobal3][eIdxGlobal3] += T[1][0];
1426 this->A_[eIdxGlobal3][eIdxGlobal2] += T[1][1];
1427 this->A_[eIdxGlobal3][eIdxGlobal4] += T[1][2];
1429 this->A_[eIdxGlobal4][eIdxGlobal3] -= T[1][0];
1430 this->A_[eIdxGlobal4][eIdxGlobal2] -= T[1][1];
1431 this->A_[eIdxGlobal4][eIdxGlobal4] -= T[1][2];
1440 pcPotential34 = Tu[1];
1443 lType = transmissibilityCalculator_.calculateTransmissibility(T, interactionVolume, lambda, 3, 0, 1, 2);
1445 if (lType == TransmissibilityCalculator::rightTriangle)
1447 if (innerBoundaryVolumeFaces_[eIdxGlobal4][interactionVolume.getIndexOnElement(3, 0)])
1451 this->A_[eIdxGlobal4][eIdxGlobal1] += T[1][0];
1452 this->A_[eIdxGlobal4][eIdxGlobal2] += T[1][1];
1453 this->A_[eIdxGlobal4][eIdxGlobal4] += T[1][2];
1455 this->A_[eIdxGlobal1][eIdxGlobal1] -= T[1][0];
1456 this->A_[eIdxGlobal1][eIdxGlobal2] -= T[1][1];
1457 this->A_[eIdxGlobal1][eIdxGlobal4] -= T[1][2];
1466 pcPotential14 = -Tu[1];
1470 if (innerBoundaryVolumeFaces_[eIdxGlobal4][interactionVolume.getIndexOnElement(3, 0)])
1474 this->A_[eIdxGlobal4][eIdxGlobal4] += T[1][0];
1475 this->A_[eIdxGlobal4][eIdxGlobal3] += T[1][1];
1476 this->A_[eIdxGlobal4][eIdxGlobal1] += T[1][2];
1478 this->A_[eIdxGlobal1][eIdxGlobal4] -= T[1][0];
1479 this->A_[eIdxGlobal1][eIdxGlobal3] -= T[1][1];
1480 this->A_[eIdxGlobal1][eIdxGlobal1] -= T[1][2];
1489 pcPotential14 = -Tu[1];
1492 if (pc[0] == 0 && pc[1] == 0 && pc[2] == 0 && pc[3] == 0)
1498 Dune::FieldVector<Scalar, numPhases> lambda12Upw(0.0);
1499 lambda12Upw[wPhaseIdx] = (pcPotential12 >= 0) ? lambda1[wPhaseIdx] : lambda2[wPhaseIdx];
1500 lambda12Upw[nPhaseIdx] = (pcPotential12 >= 0) ? lambda1[nPhaseIdx] : lambda2[nPhaseIdx];
1503 Dune::FieldVector<Scalar, numPhases> lambda14Upw(0.0);
1504 lambda14Upw[wPhaseIdx] = (pcPotential14 >= 0) ? lambda1[wPhaseIdx] : lambda4[wPhaseIdx];
1505 lambda14Upw[nPhaseIdx] = (pcPotential14 >= 0) ? lambda1[nPhaseIdx] : lambda4[nPhaseIdx];
1508 Dune::FieldVector<Scalar, numPhases> lambda32Upw(0.0);
1509 lambda32Upw[wPhaseIdx] = (pcPotential32 >= 0) ? lambda3[wPhaseIdx] : lambda2[wPhaseIdx];
1510 lambda32Upw[nPhaseIdx] = (pcPotential32 >= 0) ? lambda3[nPhaseIdx] : lambda2[nPhaseIdx];
1513 Dune::FieldVector<Scalar, numPhases> lambda34Upw(0.0);
1514 lambda34Upw[wPhaseIdx] = (pcPotential34 >= 0) ? lambda3[wPhaseIdx] : lambda4[wPhaseIdx];
1515 lambda34Upw[nPhaseIdx] = (pcPotential34 >= 0) ? lambda3[nPhaseIdx] : lambda4[nPhaseIdx];
1517 for (
int i = 0; i < numPhases; i++)
1519 Scalar lambdaT12 = lambda12Upw[wPhaseIdx] + lambda12Upw[nPhaseIdx];
1520 Scalar lambdaT14 = lambda14Upw[wPhaseIdx] + lambda14Upw[nPhaseIdx];
1521 Scalar lambdaT32 = lambda32Upw[wPhaseIdx] + lambda32Upw[nPhaseIdx];
1522 Scalar lambdaT34 = lambda34Upw[wPhaseIdx] + lambda34Upw[nPhaseIdx];
1523 Scalar fracFlow12 = (lambdaT12 > threshold_) ? lambda12Upw[i] / (lambdaT12) : 0.0;
1524 Scalar fracFlow14 = (lambdaT14 > threshold_) ? lambda14Upw[i] / (lambdaT14) : 0.0;
1525 Scalar fracFlow32 = (lambdaT32 > threshold_) ? lambda32Upw[i] / (lambdaT32) : 0.0;
1526 Scalar fracFlow34 = (lambdaT34 > threshold_) ? lambda34Upw[i] / (lambdaT34) : 0.0;
1528 Dune::FieldVector<Scalar, 2 * dim> pcFluxReal(pcFlux);
1530 pcFluxReal[0] *= fracFlow12;
1531 pcFluxReal[1] *= fracFlow32;
1532 pcFluxReal[2] *= fracFlow34;
1533 pcFluxReal[3] *= fracFlow14;
1538 switch (pressureType_)
1545 this->f_[eIdxGlobal1] -= (pcFluxReal[0] - pcFluxReal[3]);
1546 this->f_[eIdxGlobal2] -= (pcFluxReal[1] - pcFluxReal[0]);
1547 this->f_[eIdxGlobal3] -= (pcFluxReal[2] - pcFluxReal[1]);
1548 this->f_[eIdxGlobal4] -= (pcFluxReal[3] - pcFluxReal[2]);
1558 this->f_[eIdxGlobal1] += (pcFluxReal[0] - pcFluxReal[3]);
1559 this->f_[eIdxGlobal2] += (pcFluxReal[1] - pcFluxReal[0]);
1560 this->f_[eIdxGlobal3] += (pcFluxReal[2] - pcFluxReal[1]);
1561 this->f_[eIdxGlobal4] += (pcFluxReal[3] - pcFluxReal[2]);
1572 for (
int elemIdx = 0; elemIdx < 2 * dim; elemIdx++)
1574 bool isOutside =
false;
1575 for (
int fIdx = 0; fIdx < dim; fIdx++)
1577 int intVolFaceIdx = interactionVolume.getFaceIndexFromSubVolume(elemIdx, fIdx);
1578 if (interactionVolume.isOutsideFace(intVolFaceIdx))
1589 auto element = interactionVolume.getSubVolumeElement(elemIdx);
1592 const GlobalPosition& globalPos = element.geometry().center();
1595 Scalar volume = element.geometry().volume();
1598 int eIdxGlobal = problem_.variables().index(element);
1601 CellData& cellData = problem_.variables().cellData(eIdxGlobal);
1604 DimMatrix
permeability(problem_.spatialParams().intrinsicPermeability(element));
1607 PrimaryVariables source(0);
1608 problem_.source(source, element);
1609 this->f_[eIdxGlobal] += volume / (4.0) * (source[wPhaseIdx] / density_[wPhaseIdx] + source[nPhaseIdx] / density_[nPhaseIdx]);
1611 this->f_[eIdxGlobal] += evaluateErrorTerm_(cellData) * volume / (4.0);
1614 Dune::FieldVector<Scalar, numPhases> lambda(cellData.mobility(wPhaseIdx));
1615 lambda[nPhaseIdx] = cellData.mobility(nPhaseIdx);
1617 Scalar pc = cellData.capillaryPressure();
1619 Scalar gravityDiff = (problem_.bBoxMax() - globalPos) * gravity_ * (density_[nPhaseIdx] - density_[wPhaseIdx]);
1623 for (
int fIdx = 0; fIdx < dim; fIdx++)
1625 int intVolFaceIdx = interactionVolume.getFaceIndexFromSubVolume(elemIdx, fIdx);
1627 if (interactionVolume.isBoundaryFace(intVolFaceIdx))
1630 if (interactionVolume.getBoundaryType(intVolFaceIdx).isDirichlet(pressEqIdx))
1632 int boundaryFaceIdx = interactionVolume.getIndexOnElement(elemIdx, fIdx);
1634 const auto referenceElement = ReferenceElements::general(element.type());
1636 const LocalPosition& localPos = referenceElement.position(boundaryFaceIdx, 1);
1638 const GlobalPosition& globalPosFace = element.geometry().global(localPos);
1640 DimVector distVec(globalPosFace - globalPos);
1641 Scalar dist = distVec.two_norm();
1642 DimVector unitDistVec(distVec);
1643 unitDistVec /= dist;
1645 Scalar faceArea = interactionVolume.getFaceArea(elemIdx, fIdx);
1648 Scalar satWBound = cellData.saturation(wPhaseIdx);
1650 if (interactionVolume.getBoundaryType(intVolFaceIdx).isDirichlet(satEqIdx))
1652 Scalar satBound = interactionVolume.getDirichletValues(intVolFaceIdx)[saturationIdx];
1653 switch (saturationType_)
1657 satWBound = satBound;
1662 satWBound = 1 - satBound;
1669 Scalar pcBound = MaterialLaw::pc(
1670 problem_.spatialParams().materialLawParams(element), satWBound);
1672 Scalar gravityDiffBound = (problem_.bBoxMax() - globalPosFace) * gravity_
1673 * (density_[nPhaseIdx] - density_[wPhaseIdx]);
1675 pcBound += gravityDiffBound;
1677 Dune::FieldVector<Scalar, numPhases> lambdaBound(
1678 MaterialLaw::krw(problem_.spatialParams().materialLawParams(element),
1680 lambdaBound[nPhaseIdx] = MaterialLaw::krn(
1681 problem_.spatialParams().materialLawParams(element), satWBound);
1682 lambdaBound[wPhaseIdx] /= viscosity_[wPhaseIdx];
1683 lambdaBound[nPhaseIdx] /= viscosity_[nPhaseIdx];
1685 Scalar potentialBound = interactionVolume.getDirichletValues(intVolFaceIdx)[pressureIdx];
1686 Scalar gdeltaZ = (problem_.bBoxMax()-globalPosFace) * gravity_;
1689 Scalar potentialDiffW = 0;
1690 Scalar potentialDiffNw = 0;
1691 switch (pressureType_)
1695 potentialBound += density_[wPhaseIdx]*gdeltaZ;
1696 potentialDiffW = (cellData.potential(wPhaseIdx) - potentialBound) / dist;
1697 potentialDiffNw = (cellData.potential(nPhaseIdx) - potentialBound - pcBound) / dist;
1702 potentialBound += density_[nPhaseIdx]*gdeltaZ;
1703 potentialDiffW = (cellData.potential(wPhaseIdx) - potentialBound + pcBound) / dist;
1704 potentialDiffNw = (cellData.potential(nPhaseIdx) - potentialBound) / dist;
1709 Scalar lambdaTotal = (potentialDiffW >= 0.) ? lambda[wPhaseIdx] : lambdaBound[wPhaseIdx];
1710 lambdaTotal += (potentialDiffNw >= 0.) ? lambda[nPhaseIdx] : lambdaBound[nPhaseIdx];
1712 DimVector permTimesNormal(0);
1716 Scalar entry = lambdaTotal * (unitDistVec * permTimesNormal) / dist * faceArea;
1721 switch (pressureType_)
1726 DimVector pcGradient = unitDistVec;
1727 pcGradient *= (pc - pcBound) / dist;
1730 pcFlux = 0.5 * (lambda[nPhaseIdx] + lambdaBound[nPhaseIdx])
1731 * (permTimesNormal * pcGradient) * faceArea;
1738 DimVector pcGradient = unitDistVec;
1739 pcGradient *= (pc - pcBound) / dist;
1742 pcFlux = 0.5 * (lambda[wPhaseIdx] + lambdaBound[wPhaseIdx])
1743 * (permTimesNormal * pcGradient) * faceArea;
1751 this->A_[eIdxGlobal][eIdxGlobal] += entry;
1752 this->f_[eIdxGlobal] += entry * potentialBound;
1754 if (pc == 0 && pcBound == 0)
1759 for (
int i = 0; i < numPhases; i++)
1761 switch (pressureType_)
1768 this->f_[eIdxGlobal] -= pcFlux;
1777 this->f_[eIdxGlobal] += pcFlux;
1785 else if (interactionVolume.getBoundaryType(intVolFaceIdx).isNeumann(pressEqIdx))
1787 Scalar J = interactionVolume.getNeumannValues(intVolFaceIdx)[wPhaseIdx] / density_[wPhaseIdx];
1788 J += interactionVolume.getNeumannValues(intVolFaceIdx)[nPhaseIdx] / density_[nPhaseIdx];
1790 this->f_[eIdxGlobal] -= J;
1794 std::cout <<
"interactionVolume.getBoundaryType(intVolFaceIdx).isNeumann(pressEqIdx)"
1795 << interactionVolume.getBoundaryType(intVolFaceIdx).isNeumann(pressEqIdx) <<
"\n";
1796 DUNE_THROW(Dune::NotImplemented,
1797 "No valid boundary condition type defined for pressure equation!");
1808 if (problem_.gridView().comm().size() > 1)
1811 for (
const auto& element : elements(problem_.gridView()))
1813 if (element.partitionType() == Dune::InteriorEntity)
1817 int eIdxGlobalI = problem_.variables().index(element);
1819 this->A_[eIdxGlobalI] = 0.0;
1820 this->A_[eIdxGlobalI][eIdxGlobalI] = 1.0;
1821 this->f_[eIdxGlobalI] = this->
pressure()[eIdxGlobalI];
1833template<
class TypeTag>
1837 for (
const auto& element : elements(problem_.gridView()))
1839 int eIdxGlobal = problem_.variables().index(element);
1841 CellData& cellData = problem_.variables().cellData(eIdxGlobal);
1843 Scalar satW = cellData.saturation(wPhaseIdx);
1845 Scalar pc = MaterialLaw::pc(problem_.spatialParams().materialLawParams(element), satW);
1847 cellData.setCapillaryPressure(pc);
1850 Scalar mobilityW = MaterialLaw::krw(problem_.spatialParams().materialLawParams(element), satW)
1851 / viscosity_[wPhaseIdx];
1852 Scalar mobilityNw = MaterialLaw::krn(problem_.spatialParams().materialLawParams(element), satW)
1853 / viscosity_[nPhaseIdx];
1856 cellData.setMobility(wPhaseIdx, mobilityW);
1857 cellData.setMobility(nPhaseIdx, mobilityNw);
1860 cellData.setFracFlowFunc(wPhaseIdx, mobilityW / (mobilityW + mobilityNw));
1861 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 (equivalent to old macro GET_PROP(...))
Definition: propertysystem.hh:140
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:149
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:1834
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.