24#ifndef DUMUX_MIMETICOPERATOR2PADAPTIVE_HH
25#define DUMUX_MIMETICOPERATOR2PADAPTIVE_HH
45template<
class TypeTag>
56 dim=GridView::dimension,
57 dimWorld=GridView::dimensionworld
61 using Element =
typename GridView::template Codim<0>::Entity;
68 using PrimaryVariables =
typename SolutionTypes::PrimaryVariables;
74 pw = Indices::pressureW,
75 pn = Indices::pressureNw,
76 pressureType = getPropValue<TypeTag, Properties::PressureFormulation>(),
77 wPhaseIdx = Indices::wPhaseIdx,
78 nPhaseIdx = Indices::nPhaseIdx,
79 saturationIdx = Indices::saturationIdx,
80 satEqIdx = Indices::satEqIdx
83 using FieldVector = Dune::FieldVector<Scalar, dimWorld>;
91 template<
class Vector>
94 Dune::DynamicVector<Scalar> velocityW(2*dim);
95 Dune::DynamicVector<Scalar> velocityNw(2*dim);
96 Dune::DynamicVector<Scalar> pressTraceW(2*dim);
97 Dune::DynamicVector<Scalar> pressTraceNw(2*dim);
99 const auto firstElement = *problem.gridView().template begin<0>();
100 FluidState fluidState;
101 fluidState.setPressure(wPhaseIdx, problem.referencePressure(firstElement));
102 fluidState.setPressure(nPhaseIdx, problem.referencePressure(firstElement));
103 fluidState.setTemperature(problem.temperature(firstElement));
104 fluidState.setSaturation(wPhaseIdx, 1.);
105 fluidState.setSaturation(nPhaseIdx, 0.);
111 for (
int i = 0; i < problem.gridView().size(0); i++)
113 problem.variables().cellData(i).fluxData().resetVelocity();
117 for (
const auto& element : elements(this->
gridView_))
119 int eIdxGlobal = problem.variables().index(element);
124 velocityW.resize(numFaces);
125 velocityNw.resize(numFaces);
126 pressTraceW.resize(numFaces);
127 pressTraceNw.resize(numFaces);
129 CellData& cellData = problem.variables().cellData(eIdxGlobal);
130 FieldVector globalPos = element.geometry().center();
132 int intersectionIdx = -1;
134 for (
const auto& intersection : intersections(problem.gridView(), element))
140 Scalar pcPotFace = (problem.bBoxMax() - intersection.geometry().center()) * problem.gravity() * densityDiff;
142 switch (pressureType)
146 pressTraceW[intersectionIdx] = u[fIdxGlobal];
147 pressTraceNw[intersectionIdx] = u[fIdxGlobal] + pcPotFace;
152 pressTraceNw[intersectionIdx] = u[fIdxGlobal];
153 pressTraceW[intersectionIdx] = u[fIdxGlobal] - pcPotFace;
160 switch (pressureType)
164 Scalar potW = loc.constructPressure(element, pressTraceW);
165 Scalar gravPot = (problem.bBoxMax() - globalPos) * problem.gravity() * densityDiff;
166 Scalar potNw = potW + gravPot;
168 cellData.setPotential(wPhaseIdx, potW);
169 cellData.setPotential(nPhaseIdx, potNw);
171 gravPot = (problem.bBoxMax() - globalPos) * problem.gravity() *
FluidSystem::density(fluidState, wPhaseIdx);
173 cellData.setPressure(wPhaseIdx, potW - gravPot);
175 gravPot = (problem.bBoxMax() - globalPos) * problem.gravity() *
FluidSystem::density(fluidState, nPhaseIdx);
177 cellData.setPressure(nPhaseIdx, potNw - gravPot);
183 Scalar potNw = loc.constructPressure(element, pressTraceNw);
184 Scalar gravPot = (problem.bBoxMax() - globalPos) * problem.gravity() * densityDiff;
185 Scalar potW = potNw - gravPot;
187 cellData.setPotential(nPhaseIdx, potNw);
188 cellData.setPotential(wPhaseIdx, potW);
190 gravPot = (problem.bBoxMax() - globalPos) * problem.gravity() *
FluidSystem::density(fluidState, wPhaseIdx);
192 cellData.setPressure(wPhaseIdx, potW - gravPot);
194 gravPot = (problem.bBoxMax() - globalPos) * problem.gravity() *
FluidSystem::density(fluidState, nPhaseIdx);
196 cellData.setPressure(nPhaseIdx, potNw - gravPot);
205 loc.constructVelocity(element, velocityW, pressTraceW, cellData.potential(wPhaseIdx));
206 loc.constructVelocity(element, velocityNw, pressTraceNw, cellData.potential(nPhaseIdx));
208 intersectionIdx = -1;
209 for (
const auto& intersection : intersections(problem.gridView(), element))
212 int idxInInside = intersection.indexInInside();
214 cellData.fluxData().addUpwindPotential(wPhaseIdx, idxInInside, velocityW[intersectionIdx]);
215 cellData.fluxData().addUpwindPotential(nPhaseIdx, idxInInside, velocityNw[intersectionIdx]);
217 Scalar mobilityW = 0;
218 Scalar mobilityNw = 0;
220 if (intersection.neighbor())
222 int neighborIdx = problem.variables().index(intersection.outside());
224 CellData& cellDataNeighbor = problem.variables().cellData(neighborIdx);
227 (velocityW[intersectionIdx] >= 0.) ? cellData.mobility(wPhaseIdx) :
228 cellDataNeighbor.mobility(wPhaseIdx);
230 (velocityNw[intersectionIdx] >= 0.) ? cellData.mobility(nPhaseIdx) :
231 cellDataNeighbor.mobility(nPhaseIdx);
233 if (velocityW[intersectionIdx] >= 0.)
235 FieldVector velocity(intersection.centerUnitOuterNormal());
236 velocity *= mobilityW/(mobilityW+mobilityNw) * velocityW[intersectionIdx];
237 cellData.fluxData().addVelocity(wPhaseIdx, idxInInside, velocity);
238 cellDataNeighbor.fluxData().addVelocity(wPhaseIdx, intersection.indexInOutside(), velocity);
240 if (velocityNw[intersectionIdx] >= 0.)
242 FieldVector velocity(intersection.centerUnitOuterNormal());
243 velocity *= mobilityNw/(mobilityW+mobilityNw) * velocityNw[intersectionIdx];
244 cellData.fluxData().addVelocity(nPhaseIdx, idxInInside, velocity);
245 cellDataNeighbor.fluxData().addVelocity(nPhaseIdx, intersection.indexInOutside(), velocity);
248 cellData.fluxData().setVelocityMarker(idxInInside);
252 BoundaryTypes bctype;
253 problem.boundaryTypes(bctype, intersection);
254 if (bctype.isDirichlet(satEqIdx))
256 PrimaryVariables boundValues(0.0);
257 problem.dirichlet(boundValues, intersection);
262 const auto fluidMatrixInteraction = Deprecated::makePcKrSw(Scalar{}, problem.spatialParams(), element);
264 if (velocityW[intersectionIdx] >= 0.)
266 mobilityW = cellData.mobility(wPhaseIdx);
270 mobilityW = fluidMatrixInteraction.krw(boundValues[saturationIdx]) / viscosityW;
273 if (velocityNw[intersectionIdx] >= 0.)
275 mobilityNw = cellData.mobility(nPhaseIdx);
279 mobilityNw = fluidMatrixInteraction.krn(boundValues[saturationIdx]) / viscosityNw;
284 mobilityW = cellData.mobility(wPhaseIdx);
285 mobilityNw = cellData.mobility(nPhaseIdx);
288 FieldVector velocity(intersection.centerUnitOuterNormal());
289 velocity *= mobilityW/(mobilityW+mobilityNw) * velocityW[intersectionIdx];
290 cellData.fluxData().addVelocity(wPhaseIdx, idxInInside, velocity);
293 velocity = intersection.centerUnitOuterNormal();
294 velocity *= mobilityNw/(mobilityW+mobilityNw) * velocityNw[intersectionIdx];
295 cellData.fluxData().addVelocity(nPhaseIdx, idxInInside, velocity);
296 cellData.fluxData().setVelocityMarker(idxInInside);
Defines a class for Crozieux-Raviart piecewise linear finite element functions.
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 density(int phaseIdx) noexcept
I/O name of density for multiphase systems.
Definition: name.hh:65
int subIndex(int elemIdx, int fIdx)
Map interface fIdx'th interface of element index to array index.
Definition: intersectionmapper.hh:236
unsigned int size() const
Definition: intersectionmapper.hh:292
Extends CROperatorBase by a generic methods to assemble global stiffness matrix from local stiffness ...
Definition: croperatoradaptive.hh:69
const GridView gridView_
Definition: croperatoradaptive.hh:163
IntersectionMapper intersectionMapper_
Definition: croperatoradaptive.hh:165
Levelwise assembler.
Definition: operatoradaptive.hh:47
void calculatePressure(LocalStiffness &loc, Vector &u, Problem &problem)
Definition: operatoradaptive.hh:92
MimeticOperatorAssemblerTwoPAdaptive(const GridView &gridView)
Definition: operatoradaptive.hh:86
Specifies the properties for immiscible 2p diffusion/pressure models.
Defines the basic properties required for a mimetic method.