57 static Scalar
flux(
const Problem& problem,
58 const Element& element,
59 const FVElementGeometry& fvGeometry,
60 const ElementVolumeVariables& elemVolVars,
61 const SubControlVolumeFace& scvf,
63 const ElementFluxVarsCache& elemFluxVarCache)
66 if (!scvf.interiorBoundary())
67 return DefaultDarcysLaw::flux(problem, element, fvGeometry, elemVolVars, scvf, phaseIdx, elemFluxVarCache);
69 static const Scalar xi = getParamFromGroup<Scalar>(problem.paramGroup(),
"FacetCoupling.Xi", 1.0);
70 if ( !Dune::FloatCmp::eq(xi, 1.0, 1e-6) )
71 DUNE_THROW(Dune::NotImplemented,
"Xi != 1.0 cannot be used with the Box-Facet-Coupling scheme");
74 const auto& fluxVarCache = elemFluxVarCache[scvf];
75 const auto& shapeValues = fluxVarCache.shapeValues();
76 const auto& insideScv = fvGeometry.scv(scvf.insideScvIdx());
77 const auto& insideVolVars = elemVolVars[insideScv];
80 const auto bcTypes = problem.interiorBoundaryTypes(element, scvf);
82 static const bool enableGravity = getParamFromGroup<bool>(problem.paramGroup(),
"Problem.EnableGravity");
85 if (bcTypes.hasOnlyNeumann())
90 for (
const auto& scv : scvs(fvGeometry))
92 const auto& volVars = elemVolVars[scv];
93 p += volVars.pressure(phaseIdx)*shapeValues[scv.indexInElement()][0];
94 rho += volVars.density(phaseIdx)*shapeValues[scv.indexInElement()][0];
98 const auto& facetVolVars = problem.couplingManager().getLowDimVolVars(element, scvf);
104 const auto a = facetVolVars.extrusionFactor();
105 auto gradP = scvf.unitOuterNormal();
106 gradP *= dim == dimWorld ? 0.5*a : 0.5*sqrt(a);
107 gradP /= gradP.two_norm2();
108 gradP *= (facetVolVars.pressure(phaseIdx) - p);
110 gradP.axpy(-rho, problem.spatialParams().gravity(scvf.center()));
113 return -1.0*Extrusion::area(fvGeometry, scvf)
114 *insideVolVars.extrusionFactor()
115 *
vtmv(scvf.unitOuterNormal(), facetVolVars.permeability(), gradP);
119 else if (bcTypes.hasOnlyDirichlet())
122 std::vector<Scalar> pressures(element.subEntities(dim));
123 for (
const auto& scv : scvs(fvGeometry))
124 pressures[scv.localDofIndex()] = elemVolVars[scv].pressure(phaseIdx);
127 for (
const auto& scvfJ : scvfs(fvGeometry))
128 if (scvfJ.interiorBoundary() && scvfJ.facetIndexInElement() == scvf.facetIndexInElement())
129 pressures[ fvGeometry.scv(scvfJ.insideScvIdx()).localDofIndex() ]
130 = problem.couplingManager().getLowDimVolVars(element, scvfJ).pressure(phaseIdx);
134 Dune::FieldVector<Scalar, dimWorld> gradP(0.0);
135 for (
const auto& scv : scvs(fvGeometry))
137 rho += elemVolVars[scv].density(phaseIdx)*shapeValues[scv.indexInElement()][0];
138 gradP.axpy(pressures[scv.localDofIndex()], fluxVarCache.gradN(scv.indexInElement()));
142 gradP.axpy(-rho, problem.spatialParams().gravity(scvf.center()));
145 return -1.0*Extrusion::area(fvGeometry, scvf)
146 *insideVolVars.extrusionFactor()
147 *
vtmv(scvf.unitOuterNormal(), insideVolVars.permeability(), gradP);
152 DUNE_THROW(Dune::NotImplemented,
"Mixed boundary types are not supported");