24#ifndef DUMUX_FVMPFAL2DVELOCITY2P_ADAPTIVE_HH
25#define DUMUX_FVMPFAL2DVELOCITY2P_ADAPTIVE_HH
59 dim = GridView::dimension, dimWorld = GridView::dimensionworld
66 using MaterialLaw =
typename SpatialParams::MaterialLaw;
75 using PrimaryVariables =
typename SolutionTypes::PrimaryVariables;
78 using Element =
typename GridView::Traits::template Codim<0>::Entity;
79 using Grid =
typename GridView::Grid;
80 using IndexSet =
typename GridView::IndexSet;
82 using Geometry =
typename Element::Geometry;
83 using JacobianTransposed =
typename Geometry::JacobianTransposed ;
88 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 DimMatrix = Dune::FieldMatrix<Scalar, dim, dim>;
114 using DimVector = Dune::FieldVector<Scalar, dim>;
128 CellData& cellData2, CellData& cellData4,
129 InnerBoundaryVolumeFaces& innerBoundaryVolumeFaces);
148template<
class TypeTag>
150 CellData& cellData1, CellData& cellData2,
152 InnerBoundaryVolumeFaces& innerBoundaryVolumeFaces)
159 Dune::FieldVector < Scalar, 2 * dim > potW(0);
160 Dune::FieldVector < Scalar, 2 * dim > potNw(0);
162 potW[0] = cellData1.potential(wPhaseIdx);
163 potW[1] = cellData2.potential(wPhaseIdx);
164 potW[2] = cellData4.potential(wPhaseIdx);
166 potNw[0] = cellData1.potential(nPhaseIdx);
167 potNw[1] = cellData2.potential(nPhaseIdx);
168 potNw[2] = cellData4.potential(nPhaseIdx);
171 Dune::FieldVector<Scalar, numPhases> lambda1(cellData1.mobility(wPhaseIdx));
172 lambda1[nPhaseIdx] = cellData1.mobility(nPhaseIdx);
175 Scalar lambdaTotal1 = lambda1[wPhaseIdx] + lambda1[nPhaseIdx];
178 Dune::FieldVector<Scalar, numPhases> lambda2(cellData2.mobility(wPhaseIdx));
179 lambda2[nPhaseIdx] = cellData2.mobility(nPhaseIdx);
182 Scalar lambdaTotal2 = lambda2[wPhaseIdx] + lambda2[nPhaseIdx];
185 Dune::FieldVector<Scalar, numPhases> lambda4(cellData4.mobility(wPhaseIdx));
186 lambda4[nPhaseIdx] = cellData4.mobility(nPhaseIdx);
189 Scalar lambdaTotal4 = lambda4[wPhaseIdx] + lambda4[nPhaseIdx];
191 std::vector < DimVector > lambda(4);
193 lambda[0][0] = lambdaTotal1;
194 lambda[0][1] = lambdaTotal1;
195 lambda[1][0] = lambdaTotal2;
196 lambda[1][1] = lambdaTotal2;
197 lambda[3][0] = lambdaTotal4;
198 lambda[3][1] = lambdaTotal4;
200 Scalar potentialDiffW12 = 0;
201 Scalar potentialDiffW14 = 0;
202 Scalar potentialDiffW24 = 0;
204 Scalar potentialDiffNw12 = 0;
205 Scalar potentialDiffNw14 = 0;
206 Scalar potentialDiffNw24 = 0;
209 Dune::FieldVector<Scalar, 3> fluxW(0);
210 Dune::FieldVector<Scalar, 3> fluxNw(0);
212 Dune::FieldMatrix<Scalar, dim, 2 * dim - dim + 1> T(0);
214 Dune::FieldVector<Scalar, 2 * dim - dim + 1> u(0);
216 int transmissibilityType = this->transmissibilityCalculator_.calculateTransmissibility(T, interactionVolume, lambda, 0, 1, 3, 3);
218 if (transmissibilityType == TransmissibilityCalculator::rightTriangle)
227 potentialDiffW12 = Tu[1];
236 potentialDiffNw12 = Tu[1];
238 else if (transmissibilityType == TransmissibilityCalculator::leftTriangle)
247 potentialDiffW12 = Tu[1];
256 potentialDiffNw12 = Tu[1];
259 transmissibilityType = this->transmissibilityCalculator_.calculateLeftHNTransmissibility(T, interactionVolume, lambda, 1, 3, 0);
261 if (transmissibilityType == TransmissibilityCalculator::leftTriangle)
270 potentialDiffW24 = Tu[1];
279 potentialDiffNw24 = Tu[1];
282 transmissibilityType = this->transmissibilityCalculator_.calculateRightHNTransmissibility(T, interactionVolume, lambda, 3, 0, 1);
284 if (transmissibilityType == TransmissibilityCalculator::rightTriangle)
293 potentialDiffW14 = -Tu[1];
302 potentialDiffNw14 = -Tu[1];
306 cellData1.fluxData().addUpwindPotential(wPhaseIdx, interactionVolume.
getIndexOnElement(0, 0), potentialDiffW12);
307 cellData1.fluxData().addUpwindPotential(nPhaseIdx, interactionVolume.
getIndexOnElement(0, 0), potentialDiffNw12);
308 cellData1.fluxData().addUpwindPotential(wPhaseIdx, interactionVolume.
getIndexOnElement(0, 1), potentialDiffW14);
309 cellData1.fluxData().addUpwindPotential(nPhaseIdx, interactionVolume.
getIndexOnElement(0, 1), potentialDiffNw14);
310 cellData2.fluxData().addUpwindPotential(wPhaseIdx, interactionVolume.
getIndexOnElement(1, 0), potentialDiffW24);
311 cellData2.fluxData().addUpwindPotential(nPhaseIdx, interactionVolume.
getIndexOnElement(1, 0), potentialDiffNw24);
312 cellData2.fluxData().addUpwindPotential(wPhaseIdx, interactionVolume.
getIndexOnElement(1, 1), -potentialDiffW12);
313 cellData2.fluxData().addUpwindPotential(nPhaseIdx, interactionVolume.
getIndexOnElement(1, 1), -potentialDiffNw12);
314 cellData4.fluxData().addUpwindPotential(wPhaseIdx, interactionVolume.
getIndexOnElement(3, 0), -potentialDiffW14);
315 cellData4.fluxData().addUpwindPotential(nPhaseIdx, interactionVolume.
getIndexOnElement(3, 0), -potentialDiffNw14);
316 cellData4.fluxData().addUpwindPotential(wPhaseIdx, interactionVolume.
getIndexOnElement(3, 1), -potentialDiffW24);
317 cellData4.fluxData().addUpwindPotential(nPhaseIdx, interactionVolume.
getIndexOnElement(3, 1), -potentialDiffNw24);
320 Dune::FieldVector<Scalar, numPhases> lambda12Upw(0.0);
321 lambda12Upw[wPhaseIdx] = (potentialDiffW12 >= 0) ? lambda1[wPhaseIdx] : lambda2[wPhaseIdx];
322 lambda12Upw[nPhaseIdx] = (potentialDiffNw12 >= 0) ? lambda1[nPhaseIdx] : lambda2[nPhaseIdx];
325 Dune::FieldVector<Scalar, numPhases> lambda14Upw(0.0);
326 lambda14Upw[wPhaseIdx] = (potentialDiffW14 >= 0) ? lambda1[wPhaseIdx] : lambda4[wPhaseIdx];
327 lambda14Upw[nPhaseIdx] = (potentialDiffNw14 >= 0) ? lambda1[nPhaseIdx] : lambda4[nPhaseIdx];
330 Dune::FieldVector<Scalar, numPhases> lambda24Upw(0.0);
331 lambda24Upw[wPhaseIdx] = (potentialDiffW24 >= 0) ? lambda2[wPhaseIdx] : lambda4[wPhaseIdx];
332 lambda24Upw[nPhaseIdx] = (potentialDiffNw24 >= 0) ? lambda2[nPhaseIdx] : lambda4[nPhaseIdx];
334 for (
int i = 0; i < numPhases; i++)
337 DimVector vel12 = interactionVolume.
getNormal(0, 0);
338 DimVector vel14 = interactionVolume.
getNormal(3, 0);
339 DimVector vel24 = interactionVolume.
getNormal(1, 0);
340 DimVector vel21 = interactionVolume.
getNormal(0, 0);
341 DimVector vel41 = interactionVolume.
getNormal(3, 0);
342 DimVector vel42 = interactionVolume.
getNormal(1, 0);
344 Dune::FieldVector<Scalar, 3> flux(0);
359 vel12 *= flux[0] / (2 * interactionVolume.
getFaceArea(0, 0));
360 vel14 *= flux[2] / (2 * interactionVolume.
getFaceArea(3, 0));
361 vel24 *= flux[1] / (2 * interactionVolume.
getFaceArea(1, 0));
362 vel21 *= flux[0] / (2 * interactionVolume.
getFaceArea(0, 0));
363 vel41 *= flux[2] / (4 * interactionVolume.
getFaceArea(3, 0));
364 vel42 *= flux[1] / (4 * interactionVolume.
getFaceArea(1, 0));
366 Scalar lambdaT12 = lambda12Upw[wPhaseIdx] + lambda12Upw[nPhaseIdx];
367 Scalar lambdaT14 = lambda14Upw[wPhaseIdx] + lambda14Upw[nPhaseIdx];
368 Scalar lambdaT24 = lambda24Upw[wPhaseIdx] + lambda24Upw[nPhaseIdx];
369 Scalar fracFlow12 = (lambdaT12 > ParentType::threshold_) ? lambda12Upw[i] / (lambdaT12) : 0.0;
370 Scalar fracFlow14 = (lambdaT14 > ParentType::threshold_) ? lambda14Upw[i] / (lambdaT14) : 0.0;
371 Scalar fracFlow24 = (lambdaT24 > ParentType::threshold_) ? lambda24Upw[i] / (lambdaT24) : 0.0;
380 if (innerBoundaryVolumeFaces[globalIdx1][interactionVolume.
getIndexOnElement(0, 0)])
385 if (innerBoundaryVolumeFaces[globalIdx1][interactionVolume.
getIndexOnElement(0, 1)])
390 if (innerBoundaryVolumeFaces[globalIdx2][interactionVolume.
getIndexOnElement(1, 0)])
398 cellData1.fluxData().addVelocity(i, interactionVolume.
getIndexOnElement(0, 0), vel12);
399 cellData1.fluxData().addVelocity(i, interactionVolume.
getIndexOnElement(0, 1), vel14);
400 cellData2.fluxData().addVelocity(i, interactionVolume.
getIndexOnElement(1, 0), vel24);
401 cellData2.fluxData().addVelocity(i, interactionVolume.
getIndexOnElement(1, 1), vel21);
402 cellData4.fluxData().addVelocity(i, interactionVolume.
getIndexOnElement(3, 0), vel41);
403 cellData4.fluxData().addVelocity(i, interactionVolume.
getIndexOnElement(3, 1), vel42);
406 cellData1.fluxData().setVelocityMarker(interactionVolume.
getIndexOnElement(0, 0));
407 cellData1.fluxData().setVelocityMarker(interactionVolume.
getIndexOnElement(0, 1));
408 cellData2.fluxData().setVelocityMarker(interactionVolume.
getIndexOnElement(1, 0));
409 cellData2.fluxData().setVelocityMarker(interactionVolume.
getIndexOnElement(1, 1));
410 cellData4.fluxData().setVelocityMarker(interactionVolume.
getIndexOnElement(3, 0));
411 cellData4.fluxData().setVelocityMarker(interactionVolume.
getIndexOnElement(3, 1));
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
Provides methods for transmissibility calculation in 2-d.
Definition: 2dtransmissibilitycalculator.hh:44
Class for calculating 2-d velocities from cell-wise constant pressure values.
Definition: lmethod/2dvelocity.hh:58
Class for calculating 2-d velocities from cell-wise constant pressure values.
Definition: 2dvelocityadaptive.hh:54
void calculateHangingNodeInteractionVolumeVelocity(InteractionVolume &interactionVolume, CellData &cellData1, CellData &cellData2, CellData &cellData4, InnerBoundaryVolumeFaces &innerBoundaryVolumeFaces)
Calculatex velocities for flux faces of a hanging node interaction volume.
Definition: 2dvelocityadaptive.hh:149
FvMpfaL2dVelocity2pAdaptive(Problem &problem)
Constructs a FvMpfaL2dVelocity2pAdaptive object.
Definition: 2dvelocityadaptive.hh:122
Class including the information of an interaction volume of a MPFA L-method that does not change with...
Definition: linteractionvolume.hh:41
int getIndexOnElement(int subVolumeIdx, int subVolumeFaceIdx)
Map from local interaction volume numbering to numbering of the Dune reference element.
Definition: linteractionvolume.hh:258
DimVector & getNormal(int subVolumeIdx, int subVolumeFaceIdxInInside)
Get a flux face normal.
Definition: linteractionvolume.hh:364
Element getSubVolumeElement(int subVolumeIdx)
Get an element of the interaction volume.
Definition: linteractionvolume.hh:281
Scalar & getFaceArea(int subVolumeIdx, int subVolumeFaceIdxInInside)
Get a flux face area.
Definition: linteractionvolume.hh:388
Velocity calculation using a 2-d MPFA O-method.