24#ifndef DUMUX_FVMPFAO2DVELOCITY2P_HH
25#define DUMUX_FVMPFAO2DVELOCITY2P_HH
27#include <dune/grid/common/gridenums.hh>
61 dim = GridView::dimension, dimWorld = GridView::dimensionworld
76 using PrimaryVariables =
typename SolutionTypes::PrimaryVariables;
79 using Element =
typename GridView::Traits::template Codim<0>::Entity;
80 using Grid =
typename GridView::Grid;
81 using IndexSet =
typename GridView::IndexSet;
83 using Geometry =
typename Element::Geometry;
84 using JacobianTransposed =
typename Geometry::JacobianTransposed ;
89 using InnerBoundaryVolumeFaces = std::vector<Dune::FieldVector<bool, 2*dim> >;
93 pw = Indices::pressureW,
94 pn = Indices::pressureNw,
95 pGlobal = Indices::pressureGlobal,
96 sw = Indices::saturationW,
97 sn = Indices::saturationNw,
98 vw = Indices::velocityW,
99 vn = Indices::velocityNw,
100 vt = Indices::velocityTotal
104 wPhaseIdx = Indices::wPhaseIdx,
105 nPhaseIdx = Indices::nPhaseIdx,
106 pressureIdx = Indices::pressureIdx,
107 saturationIdx = Indices::saturationIdx,
108 pressureEqIdx = Indices::pressureEqIdx,
109 satEqIdx = Indices::satEqIdx,
110 numPhases = getPropValue<TypeTag, Properties::NumPhases>()
113 using LocalPosition = Dune::FieldVector<Scalar, dim>;
114 using GlobalPosition =
typename Geometry::GlobalCoordinate;
115 using GravityVector = Dune::FieldVector<Scalar, dimWorld>;
116 using DimMatrix = Dune::FieldMatrix<Scalar, dim, dim>;
117 using DimVector = Dune::FieldVector<Scalar, dim>;
126 problem_(problem), gravity_(problem.gravity())
128 density_[wPhaseIdx] = 0.;
129 density_[nPhaseIdx] = 0.;
130 viscosity_[wPhaseIdx] = 0.;
131 viscosity_[nPhaseIdx] = 0.;
133 vtkOutputLevel_ = getParam<int>(
"Vtk.OutputLevel");
138 CellData& cellData2, CellData& cellData3, CellData& cellData4,
139 InnerBoundaryVolumeFaces& innerBoundaryVolumeFaces);
141 CellData& cellData,
int elemIdx);
146 const auto element = *problem_.gridView().template begin<0>();
147 FluidState fluidState;
148 fluidState.setPressure(wPhaseIdx, problem_.referencePressure(element));
149 fluidState.setPressure(nPhaseIdx, problem_.referencePressure(element));
150 fluidState.setTemperature(problem_.temperature(element));
151 fluidState.setSaturation(wPhaseIdx, 1.);
152 fluidState.setSaturation(nPhaseIdx, 0.);
171 template<
class MultiWriter>
174 if (vtkOutputLevel_ > 0)
176 Dune::BlockVector < DimVector > &velocityWetting = *(writer.template allocateManagedBuffer<Scalar,
177 dim>(problem_.gridView().size(0)));
178 Dune::BlockVector < DimVector > &velocityNonwetting = *(writer.template allocateManagedBuffer<Scalar,
179 dim>(problem_.gridView().size(0)));
182 for (
const auto& element : elements(problem_.gridView()))
185 int eIdxGlobal = problem_.variables().index(element);
187 CellData & cellData = problem_.variables().cellData(eIdxGlobal);
189 Dune::FieldVector < Scalar, 2 * dim > fluxW(0);
190 Dune::FieldVector < Scalar, 2 * dim > fluxNw(0);
193 for (
const auto& intersection : intersections(problem_.gridView(), element))
195 int isIndex = intersection.indexInInside();
197 fluxW[isIndex] += intersection.geometry().volume()
198 * (intersection.centerUnitOuterNormal() * cellData.fluxData().velocity(wPhaseIdx, isIndex));
199 fluxNw[isIndex] += intersection.geometry().volume()
200 * (intersection.centerUnitOuterNormal() * cellData.fluxData().velocity(nPhaseIdx, isIndex));
203 DimVector refVelocity(0);
204 refVelocity[0] = 0.5 * (fluxW[1] - fluxW[0]);
205 refVelocity[1] = 0.5 * (fluxW[3] - fluxW[2]);
207 const DimVector& localPos = referenceElement(element).position(0, 0);
210 const JacobianTransposed jacobianT = element.geometry().jacobianTransposed(localPos);
213 DimVector elementVelocity(0);
214 jacobianT.umtv(refVelocity, elementVelocity);
215 elementVelocity /= element.geometry().integrationElement(localPos);
217 velocityWetting[eIdxGlobal] = elementVelocity;
220 refVelocity[0] = 0.5 * (fluxNw[1] - fluxNw[0]);
221 refVelocity[1] = 0.5 * (fluxNw[3] - fluxNw[2]);
225 jacobianT.umtv(refVelocity, elementVelocity);
226 elementVelocity /= element.geometry().integrationElement(localPos);
228 velocityNonwetting[eIdxGlobal] = elementVelocity;
231 writer.attachCellData(velocityWetting,
"wetting-velocity", dim);
232 writer.attachCellData(velocityNonwetting,
"nonwetting-velocity", dim);
240 const GravityVector& gravity_;
242 Scalar density_[numPhases];
243 Scalar viscosity_[numPhases];
247 static constexpr Scalar threshold_ = 1e-15;
249 static const int velocityType_ = getPropValue<TypeTag, Properties::VelocityFormulation>();
251 static const int pressureType_ = getPropValue<TypeTag, Properties::PressureFormulation>();
253 static const int saturationType_ = getPropValue<TypeTag, Properties::SaturationFormulation>();
272template<
class TypeTag>
274 CellData& cellData1, CellData& cellData2,
275 CellData& cellData3, CellData& cellData4,
276 InnerBoundaryVolumeFaces& innerBoundaryVolumeFaces)
285 Dune::FieldVector < Scalar, 2 * dim > potW(0);
286 Dune::FieldVector < Scalar, 2 * dim > potNw(0);
288 potW[0] = cellData1.potential(wPhaseIdx);
289 potW[1] = cellData2.potential(wPhaseIdx);
290 potW[2] = cellData3.potential(wPhaseIdx);
291 potW[3] = cellData4.potential(wPhaseIdx);
293 potNw[0] = cellData1.potential(nPhaseIdx);
294 potNw[1] = cellData2.potential(nPhaseIdx);
295 potNw[2] = cellData3.potential(nPhaseIdx);
296 potNw[3] = cellData4.potential(nPhaseIdx);
299 Dune::FieldVector < Scalar, numPhases > lambda1(cellData1.mobility(wPhaseIdx));
300 lambda1[nPhaseIdx] = cellData1.mobility(nPhaseIdx);
303 Scalar lambdaTotal1 = lambda1[wPhaseIdx] + lambda1[nPhaseIdx];
306 Dune::FieldVector < Scalar, numPhases > lambda2(cellData2.mobility(wPhaseIdx));
307 lambda2[nPhaseIdx] = cellData2.mobility(nPhaseIdx);
310 Scalar lambdaTotal2 = lambda2[wPhaseIdx] + lambda2[nPhaseIdx];
313 Dune::FieldVector < Scalar, numPhases > lambda3(cellData3.mobility(wPhaseIdx));
314 lambda3[nPhaseIdx] = cellData3.mobility(nPhaseIdx);
317 Scalar lambdaTotal3 = lambda3[wPhaseIdx] + lambda3[nPhaseIdx];
320 Dune::FieldVector < Scalar, numPhases > lambda4(cellData4.mobility(wPhaseIdx));
321 lambda4[nPhaseIdx] = cellData4.mobility(nPhaseIdx);
324 Scalar lambdaTotal4 = lambda4[wPhaseIdx] + lambda4[nPhaseIdx];
326 Scalar gn12nu14 = interactionVolume.
getNtkrkNu_df(lambdaTotal1, 0, 0, 1);
327 Scalar gn12nu12 = interactionVolume.
getNtkrkNu_df(lambdaTotal1, 0, 0, 0);
328 Scalar gn14nu14 = interactionVolume.
getNtkrkNu_df(lambdaTotal1, 0, 1, 1);
329 Scalar gn14nu12 = interactionVolume.
getNtkrkNu_df(lambdaTotal1, 0, 1, 0);
330 Scalar gn12nu23 = interactionVolume.
getNtkrkNu_df(lambdaTotal2, 1, 1, 0);
331 Scalar gn12nu21 = interactionVolume.
getNtkrkNu_df(lambdaTotal2, 1, 1, 1);
332 Scalar gn23nu23 = interactionVolume.
getNtkrkNu_df(lambdaTotal2, 1, 0, 0);
333 Scalar gn23nu21 = interactionVolume.
getNtkrkNu_df(lambdaTotal2, 1, 0, 1);
334 Scalar gn43nu32 = interactionVolume.
getNtkrkNu_df(lambdaTotal3, 2, 0, 1);
335 Scalar gn43nu34 = interactionVolume.
getNtkrkNu_df(lambdaTotal3, 2, 0, 0);
336 Scalar gn23nu32 = interactionVolume.
getNtkrkNu_df(lambdaTotal3, 2, 1, 1);
337 Scalar gn23nu34 = interactionVolume.
getNtkrkNu_df(lambdaTotal3, 2, 1, 0);
338 Scalar gn43nu41 = interactionVolume.
getNtkrkNu_df(lambdaTotal4, 3, 1, 0);
339 Scalar gn43nu43 = interactionVolume.
getNtkrkNu_df(lambdaTotal4, 3, 1, 1);
340 Scalar gn14nu41 = interactionVolume.
getNtkrkNu_df(lambdaTotal4, 3, 0, 0);
341 Scalar gn14nu43 = interactionVolume.
getNtkrkNu_df(lambdaTotal4, 3, 0, 1);
344 Dune::FieldMatrix < Scalar, 2 * dim, 2 * dim > C(0), F(0), A(0), B(0);
356 F[0][0] = gn12nu12 + gn12nu14;
357 F[1][1] = -gn23nu21 + gn23nu23;
358 F[2][2] = -gn43nu34 - gn43nu32;
359 F[3][3] = gn14nu43 - gn14nu41;
361 A[0][0] = gn12nu12 + gn12nu21;
365 A[1][1] = gn23nu23 + gn23nu32;
368 A[2][2] = -gn43nu34 - gn43nu43;
372 A[3][3] = -gn14nu41 - gn14nu14;
376 B[0][0] = gn12nu12 + gn12nu14;
377 B[0][1] = gn12nu21 - gn12nu23;
378 B[1][1] = -gn23nu21 + gn23nu23;
379 B[1][2] = gn23nu34 + gn23nu32;
380 B[2][2] = -gn43nu34 - gn43nu32;
381 B[2][3] = -gn43nu43 + gn43nu41;
382 B[3][0] = -gn14nu12 - gn14nu14;
383 B[3][3] = gn14nu43 - gn14nu41;
386 Dune::FieldVector < Scalar, 2 * dim > fluxW(0);
387 Dune::FieldVector < Scalar, 2 * dim > fluxNw(0);
391 F += C.rightmultiply(B.leftmultiply(A));
392 Dune::FieldMatrix < Scalar, 2 * dim, 2 * dim > T(F);
397 Scalar potentialDiffW12 = fluxW[0];
398 Scalar potentialDiffW14 = fluxW[3];
399 Scalar potentialDiffW32 = -fluxW[1];
400 Scalar potentialDiffW34 = -fluxW[2];
402 Scalar potentialDiffNw12 = fluxNw[0];
403 Scalar potentialDiffNw14 = fluxNw[3];
404 Scalar potentialDiffNw32 = -fluxNw[1];
405 Scalar potentialDiffNw34 = -fluxNw[2];
408 cellData1.fluxData().addUpwindPotential(wPhaseIdx, interactionVolume.
getIndexOnElement(0, 0), fluxW[0]);
409 cellData1.fluxData().addUpwindPotential(nPhaseIdx, interactionVolume.
getIndexOnElement(0, 0), fluxNw[0]);
410 cellData1.fluxData().addUpwindPotential(wPhaseIdx, interactionVolume.
getIndexOnElement(0, 1), fluxW[3]);
411 cellData1.fluxData().addUpwindPotential(nPhaseIdx, interactionVolume.
getIndexOnElement(0, 1), fluxNw[3]);
412 cellData2.fluxData().addUpwindPotential(wPhaseIdx, interactionVolume.
getIndexOnElement(1, 0), fluxW[1]);
413 cellData2.fluxData().addUpwindPotential(nPhaseIdx, interactionVolume.
getIndexOnElement(1, 0), fluxNw[1]);
414 cellData2.fluxData().addUpwindPotential(wPhaseIdx, interactionVolume.
getIndexOnElement(1, 1), -fluxW[0]);
415 cellData2.fluxData().addUpwindPotential(nPhaseIdx, interactionVolume.
getIndexOnElement(1, 1), -fluxNw[0]);
416 cellData3.fluxData().addUpwindPotential(wPhaseIdx, interactionVolume.
getIndexOnElement(2, 0), -fluxW[2]);
417 cellData3.fluxData().addUpwindPotential(nPhaseIdx, interactionVolume.
getIndexOnElement(2, 0), -fluxNw[2]);
418 cellData3.fluxData().addUpwindPotential(wPhaseIdx, interactionVolume.
getIndexOnElement(2, 1), -fluxW[1]);
419 cellData3.fluxData().addUpwindPotential(nPhaseIdx, interactionVolume.
getIndexOnElement(2, 1), -fluxNw[1]);
420 cellData4.fluxData().addUpwindPotential(wPhaseIdx, interactionVolume.
getIndexOnElement(3, 0), -fluxW[3]);
421 cellData4.fluxData().addUpwindPotential(nPhaseIdx, interactionVolume.
getIndexOnElement(3, 0), -fluxNw[3]);
422 cellData4.fluxData().addUpwindPotential(wPhaseIdx, interactionVolume.
getIndexOnElement(3, 1), fluxW[2]);
423 cellData4.fluxData().addUpwindPotential(nPhaseIdx, interactionVolume.
getIndexOnElement(3, 1), fluxNw[2]);
426 Dune::FieldVector < Scalar, numPhases > lambda12Upw(0.0);
427 lambda12Upw[wPhaseIdx] = (potentialDiffW12 >= 0) ? lambda1[wPhaseIdx] : lambda2[wPhaseIdx];
428 lambda12Upw[nPhaseIdx] = (potentialDiffNw12 >= 0) ? lambda1[nPhaseIdx] : lambda2[nPhaseIdx];
431 Dune::FieldVector < Scalar, numPhases > lambda14Upw(0.0);
432 lambda14Upw[wPhaseIdx] = (potentialDiffW14 >= 0) ? lambda1[wPhaseIdx] : lambda4[wPhaseIdx];
433 lambda14Upw[nPhaseIdx] = (potentialDiffNw14 >= 0) ? lambda1[nPhaseIdx] : lambda4[nPhaseIdx];
436 Dune::FieldVector < Scalar, numPhases > lambda32Upw(0.0);
437 lambda32Upw[wPhaseIdx] = (potentialDiffW32 >= 0) ? lambda3[wPhaseIdx] : lambda2[wPhaseIdx];
438 lambda32Upw[nPhaseIdx] = (potentialDiffNw32 >= 0) ? lambda3[nPhaseIdx] : lambda2[nPhaseIdx];
441 Dune::FieldVector < Scalar, numPhases > lambda34Upw(0.0);
442 lambda34Upw[wPhaseIdx] = (potentialDiffW34 >= 0) ? lambda3[wPhaseIdx] : lambda4[wPhaseIdx];
443 lambda34Upw[nPhaseIdx] = (potentialDiffNw34 >= 0) ? lambda3[nPhaseIdx] : lambda4[nPhaseIdx];
445 for (
int i = 0; i < numPhases; i++)
448 DimVector vel12 = interactionVolume.
getNormal(0, 0);
449 DimVector vel14 = interactionVolume.
getNormal(0, 1);
450 DimVector vel23 = interactionVolume.
getNormal(1, 0);
451 DimVector vel21 = interactionVolume.
getNormal(1, 1);
452 DimVector vel34 = interactionVolume.
getNormal(2, 0);
453 DimVector vel32 = interactionVolume.
getNormal(2, 1);
454 DimVector vel41 = interactionVolume.
getNormal(3, 0);
455 DimVector vel43 = interactionVolume.
getNormal(3, 1);
457 Dune::FieldVector < Scalar, 2 * dim > flux(0);
472 vel12 *= flux[0] / (2 * interactionVolume.
getFaceArea(0, 0));
473 vel14 *= flux[3] / (2 * interactionVolume.
getFaceArea(0, 1));
474 vel23 *= flux[1] / (2 * interactionVolume.
getFaceArea(1, 0));
475 vel21 *= flux[0] / (2 * interactionVolume.
getFaceArea(1, 1));
476 vel34 *= flux[2] / (2 * interactionVolume.
getFaceArea(2, 0));
477 vel32 *= flux[1] / (2 * interactionVolume.
getFaceArea(2, 1));
478 vel41 *= flux[3] / (2 * interactionVolume.
getFaceArea(3, 0));
479 vel43 *= flux[2] / (2 * interactionVolume.
getFaceArea(3, 1));
481 Scalar lambdaT12 = lambda12Upw[wPhaseIdx] + lambda12Upw[nPhaseIdx];
482 Scalar lambdaT14 = lambda14Upw[wPhaseIdx] + lambda14Upw[nPhaseIdx];
483 Scalar lambdaT32 = lambda32Upw[wPhaseIdx] + lambda32Upw[nPhaseIdx];
484 Scalar lambdaT34 = lambda34Upw[wPhaseIdx] + lambda34Upw[nPhaseIdx];
485 Scalar fracFlow12 = (lambdaT12 > threshold_) ? lambda12Upw[i] / (lambdaT12) : 0.0;
486 Scalar fracFlow14 = (lambdaT14 > threshold_) ? lambda14Upw[i] / (lambdaT14) : 0.0;
487 Scalar fracFlow32 = (lambdaT32 > threshold_) ? lambda32Upw[i] / (lambdaT32) : 0.0;
488 Scalar fracFlow34 = (lambdaT34 > threshold_) ? lambda34Upw[i] / (lambdaT34) : 0.0;
499 if (innerBoundaryVolumeFaces[eIdxGlobal1][interactionVolume.
getIndexOnElement(0, 0)])
503 if (innerBoundaryVolumeFaces[eIdxGlobal1][interactionVolume.
getIndexOnElement(0, 1)])
507 if (innerBoundaryVolumeFaces[eIdxGlobal2][interactionVolume.
getIndexOnElement(1, 0)])
511 if (innerBoundaryVolumeFaces[eIdxGlobal2][interactionVolume.
getIndexOnElement(1, 1)])
515 if (innerBoundaryVolumeFaces[eIdxGlobal3][interactionVolume.
getIndexOnElement(2, 0)])
519 if (innerBoundaryVolumeFaces[eIdxGlobal3][interactionVolume.
getIndexOnElement(2, 1)])
523 if (innerBoundaryVolumeFaces[eIdxGlobal4][interactionVolume.
getIndexOnElement(3, 0)])
527 if (innerBoundaryVolumeFaces[eIdxGlobal4][interactionVolume.
getIndexOnElement(3, 1)])
533 cellData1.fluxData().addVelocity(i, interactionVolume.
getIndexOnElement(0, 0), vel12);
534 cellData1.fluxData().addVelocity(i, interactionVolume.
getIndexOnElement(0, 1), vel14);
535 cellData2.fluxData().addVelocity(i, interactionVolume.
getIndexOnElement(1, 0), vel23);
536 cellData2.fluxData().addVelocity(i, interactionVolume.
getIndexOnElement(1, 1), vel21);
537 cellData3.fluxData().addVelocity(i, interactionVolume.
getIndexOnElement(2, 0), vel34);
538 cellData3.fluxData().addVelocity(i, interactionVolume.
getIndexOnElement(2, 1), vel32);
539 cellData4.fluxData().addVelocity(i, interactionVolume.
getIndexOnElement(3, 0), vel41);
540 cellData4.fluxData().addVelocity(i, interactionVolume.
getIndexOnElement(3, 1), vel43);
543 cellData1.fluxData().setVelocityMarker(interactionVolume.
getIndexOnElement(0, 0));
544 cellData1.fluxData().setVelocityMarker(interactionVolume.
getIndexOnElement(0, 1));
545 cellData2.fluxData().setVelocityMarker(interactionVolume.
getIndexOnElement(1, 0));
546 cellData2.fluxData().setVelocityMarker(interactionVolume.
getIndexOnElement(1, 1));
547 cellData3.fluxData().setVelocityMarker(interactionVolume.
getIndexOnElement(2, 0));
548 cellData3.fluxData().setVelocityMarker(interactionVolume.
getIndexOnElement(2, 1));
549 cellData4.fluxData().setVelocityMarker(interactionVolume.
getIndexOnElement(3, 0));
550 cellData4.fluxData().setVelocityMarker(interactionVolume.
getIndexOnElement(3, 1));
562template<
class TypeTag>
564 CellData& cellData,
int elemIdx)
569 const GlobalPosition& globalPos = element.geometry().center();
572 DimMatrix
permeability(problem_.spatialParams().intrinsicPermeability(element));
575 Dune::FieldVector < Scalar, numPhases > lambda(cellData.mobility(wPhaseIdx));
576 lambda[nPhaseIdx] = cellData.mobility(nPhaseIdx);
578 for (
int fIdx = 0; fIdx < dim; fIdx++)
588 const auto refElement = referenceElement(element);
590 const LocalPosition& localPos = refElement.position(boundaryFaceIdx, 1);
592 const GlobalPosition& globalPosFace = element.geometry().global(localPos);
594 DimVector distVec(globalPosFace - globalPos);
595 Scalar dist = distVec.two_norm();
596 DimVector unitDistVec(distVec);
600 Scalar satWBound = cellData.saturation(wPhaseIdx);
605 switch (saturationType_)
609 satWBound = satBound;
614 satWBound = 1 - satBound;
621 const auto fluidMatrixInteraction = problem_.spatialParams().fluidMatrixInteractionAtPos(element.geometry().center());
622 Scalar pcBound = fluidMatrixInteraction.pc(satWBound);
624 Scalar gravityDiffBound = (problem_.bBoxMax() - globalPosFace) * gravity_
625 * (density_[nPhaseIdx] - density_[wPhaseIdx]);
627 pcBound += gravityDiffBound;
629 Dune::FieldVector < Scalar, numPhases> lambdaBound(fluidMatrixInteraction.krw(satWBound));
630 lambdaBound[nPhaseIdx] = fluidMatrixInteraction.krn(satWBound);
631 lambdaBound[wPhaseIdx] /= viscosity_[wPhaseIdx];
632 lambdaBound[nPhaseIdx] /= viscosity_[nPhaseIdx];
634 Scalar gdeltaZ = (problem_.bBoxMax()-globalPosFace) * gravity_;
635 Scalar potentialBoundW = interactionVolume.
getDirichletValues(intVolFaceIdx)[pressureIdx] + density_[wPhaseIdx]*gdeltaZ;
636 Scalar potentialBoundNw = potentialBoundW;
639 switch (pressureType_)
643 potentialBoundNw += pcBound;
649 potentialBoundW -= pcBound;
654 Scalar potentialDiffW = (cellData.potential(wPhaseIdx) - potentialBoundW) / dist;
655 Scalar potentialDiffNw = (cellData.potential(nPhaseIdx) - potentialBoundNw) / dist;
658 cellData.fluxData().addUpwindPotential(wPhaseIdx, boundaryFaceIdx, potentialDiffW);
659 cellData.fluxData().addUpwindPotential(nPhaseIdx, boundaryFaceIdx, potentialDiffNw);
662 DimVector velocityW(0);
663 DimVector velocityNw(0);
666 DimVector pressGradient = unitDistVec;
667 pressGradient *= (cellData.potential(wPhaseIdx) - potentialBoundW) / dist;
670 pressGradient = unitDistVec;
671 pressGradient *= (cellData.potential(nPhaseIdx) - potentialBoundNw) / dist;
674 velocityW *= (potentialDiffW >= 0.) ? lambda[wPhaseIdx] : lambdaBound[wPhaseIdx];
675 velocityNw *= (potentialDiffNw >= 0.) ? lambda[nPhaseIdx] : lambdaBound[nPhaseIdx];
682 velocityW += cellData.fluxData().velocity(wPhaseIdx, boundaryFaceIdx);
683 velocityNw += cellData.fluxData().velocity(nPhaseIdx, boundaryFaceIdx);
684 cellData.fluxData().setVelocity(wPhaseIdx, boundaryFaceIdx, velocityW);
685 cellData.fluxData().setVelocity(nPhaseIdx, boundaryFaceIdx, velocityNw);
686 cellData.fluxData().setVelocityMarker(boundaryFaceIdx);
692 const auto refElement = referenceElement(element);
694 const LocalPosition& localPos = refElement.position(boundaryFaceIdx, 1);
696 const GlobalPosition& globalPosFace = element.geometry().global(localPos);
698 DimVector distVec(globalPosFace - globalPos);
699 Scalar dist = distVec.two_norm();
700 DimVector unitDistVec(distVec);
704 PrimaryVariables boundValues(interactionVolume.
getNeumannValues(intVolFaceIdx));
706 boundValues[wPhaseIdx] /= density_[wPhaseIdx];
707 boundValues[nPhaseIdx] /= density_[nPhaseIdx];
709 DimVector velocityW(unitDistVec);
710 DimVector velocityNw(unitDistVec);
712 velocityW *= boundValues[wPhaseIdx] / (2 * interactionVolume.
getFaceArea(elemIdx, fIdx));
713 velocityNw *= boundValues[nPhaseIdx]
714 / (2 * interactionVolume.
getFaceArea(elemIdx, fIdx));
717 cellData.fluxData().addUpwindPotential(wPhaseIdx, boundaryFaceIdx, boundValues[wPhaseIdx]);
718 cellData.fluxData().addUpwindPotential(nPhaseIdx, boundaryFaceIdx, boundValues[nPhaseIdx]);
721 velocityW += cellData.fluxData().velocity(wPhaseIdx, boundaryFaceIdx);
722 velocityNw += cellData.fluxData().velocity(nPhaseIdx, boundaryFaceIdx);
723 cellData.fluxData().setVelocity(wPhaseIdx, boundaryFaceIdx, velocityW);
724 cellData.fluxData().setVelocity(nPhaseIdx, boundaryFaceIdx, velocityNw);
725 cellData.fluxData().setVelocityMarker(boundaryFaceIdx);
729 DUNE_THROW(Dune::NotImplemented,
730 "No valid boundary condition type defined for pressure equation!");
Class including the information of an interaction volume of a MPFA O-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 density(int phaseIdx) noexcept
I/O name of density for multiphase systems.
Definition: name.hh:65
bool isNeumann(unsigned eqIdx) const
Returns true if an equation is used to specify a Neumann condition.
Definition: common/boundarytypes.hh:273
bool isDirichlet(unsigned eqIdx) const
Returns true if an equation is used to specify a Dirichlet condition.
Definition: common/boundarytypes.hh:236
Class for calculating velocities from cell-wise constant pressure values.
Definition: omethod/2dvelocity.hh:57
void addOutputVtkFields(MultiWriter &writer)
Adds velocity output to the output file.
Definition: omethod/2dvelocity.hh:172
FvMpfaO2dVelocity2P(Problem &problem)
Definition: omethod/2dvelocity.hh:125
void calculateInnerInteractionVolumeVelocity(InteractionVolume &interactionVolume, CellData &cellData1, CellData &cellData2, CellData &cellData3, CellData &cellData4, InnerBoundaryVolumeFaces &innerBoundaryVolumeFaces)
Calculates velocities for all flux faces of an interaction volume.
Definition: omethod/2dvelocity.hh:273
void initialize()
Initializes the velocity model.
Definition: omethod/2dvelocity.hh:144
void calculateBoundaryInteractionVolumeVelocity(InteractionVolume &interactionVolume, CellData &cellData, int elemIdx)
Calculates the velocity at a boundary flux faces.
Definition: omethod/2dvelocity.hh:563
Class including the information of an interaction volume of a MPFA O-method that does not change with...
Definition: ointeractionvolume.hh:38
BoundaryTypes & getBoundaryType(int subVolumeFaceIdx)
Get boundary condtion types for a flux face.
Definition: ointeractionvolume.hh:267
bool isBoundaryFace(int subVolumeFaceIdx)
Returns true if an interaction volume flux face is a boundary face.
Definition: ointeractionvolume.hh:305
PrimaryVariables & getDirichletValues(int subVolumeFaceIdx)
Get the Dirichlet boundary condtions for a flux face.
Definition: ointeractionvolume.hh:316
Scalar & getFaceArea(int subVolumeIdx, int subVolumeFaceIdxInInside)
Get a flux face area.
Definition: ointeractionvolume.hh:351
Scalar getNtkrkNu_df(Scalar &relPerm, int subVolumeIdx, int subVolumeFaceIdxInInsideN, int subVolumeFaceIdxInInsideNu) const
Definition: ointeractionvolume.hh:434
PrimaryVariables & getNeumannValues(int subVolumeFaceIdx)
Get the Neumann boundary condtions for a flux face.
Definition: ointeractionvolume.hh:327
DimVector & getNormal(int subVolumeIdx, int subVolumeFaceIdxInInside)
Get a flux face normal.
Definition: ointeractionvolume.hh:339
int getFaceIndexFromSubVolume(int subVolumeIdx, int subVolumeFaceIdx)
Map from local interaction volume numbering on element to numbering on interaction volume.
Definition: ointeractionvolume.hh:245
Element getSubVolumeElement(int subVolumeIdx)
Get an element of the interaction volume.
Definition: ointeractionvolume.hh:256
int getIndexOnElement(int subVolumeIdx, int subVolumeFaceIdx)
Map from local interaction volume numbering to numbering of the Dune reference element.
Definition: ointeractionvolume.hh:233
Specifies the properties for immiscible 2p diffusion/pressure models.
Properties for a MPFA method.