68 static Scalar
flux(
const Problem& problem,
69 const Element& element,
70 const FVElementGeometry& fvGeometry,
71 const ElementVolumeVariables& elemVolVars,
72 const SubControlVolumeFace& scvf,
74 const ElementFluxVarsCache& elemFluxVarCache)
77 if (!scvf.interiorBoundary())
81 if ( !Dune::FloatCmp::eq(xi, 1.0, 1e-6) )
82 DUNE_THROW(Dune::NotImplemented,
"Xi != 1.0 cannot be used with the Box-Facet-Coupling scheme");
85 const auto& fluxVarCache = elemFluxVarCache[scvf];
86 const auto& shapeValues = fluxVarCache.shapeValues();
87 const auto& insideScv = fvGeometry.scv(scvf.insideScvIdx());
88 const auto& insideVolVars = elemVolVars[insideScv];
91 const auto bcTypes = problem.interiorBoundaryTypes(element, scvf);
96 if (bcTypes.hasOnlyNeumann())
101 for (
const auto& scv : scvs(fvGeometry))
103 const auto& volVars = elemVolVars[scv];
104 p += volVars.pressure(phaseIdx)*shapeValues[scv.indexInElement()][0];
105 rho += volVars.density(phaseIdx)*shapeValues[scv.indexInElement()][0];
109 const auto& facetVolVars = problem.couplingManager().getLowDimVolVars(element, scvf);
115 const auto a = facetVolVars.extrusionFactor();
116 auto gradP = scvf.unitOuterNormal();
117 gradP *= dim == dimWorld ? 0.5*a : 0.5*sqrt(a);
118 gradP /= gradP.two_norm2();
119 gradP *= (facetVolVars.pressure(phaseIdx) - p);
121 gradP.axpy(-rho, problem.spatialParams().gravity(scvf.center()));
124 return -1.0*scvf.area()
125 *insideVolVars.extrusionFactor()
126 *
vtmv(scvf.unitOuterNormal(), facetVolVars.permeability(), gradP);
130 else if (bcTypes.hasOnlyDirichlet())
133 std::vector<Scalar> pressures(element.subEntities(dim));
134 for (
const auto& scv : scvs(fvGeometry))
135 pressures[scv.localDofIndex()] = elemVolVars[scv].pressure(phaseIdx);
138 for (
const auto& scvfJ : scvfs(fvGeometry))
139 if (scvfJ.interiorBoundary() && scvfJ.facetIndexInElement() == scvf.facetIndexInElement())
140 pressures[ fvGeometry.scv(scvfJ.insideScvIdx()).localDofIndex() ]
141 = problem.couplingManager().getLowDimVolVars(element, scvfJ).pressure(phaseIdx);
145 Dune::FieldVector<Scalar, dimWorld> gradP(0.0);
146 for (
const auto& scv : scvs(fvGeometry))
148 rho += elemVolVars[scv].density(phaseIdx)*shapeValues[scv.indexInElement()][0];
149 gradP.axpy(pressures[scv.localDofIndex()], fluxVarCache.gradN(scv.indexInElement()));
153 gradP.axpy(-rho, problem.spatialParams().gravity(scvf.center()));
156 return -1.0*scvf.area()
157 *insideVolVars.extrusionFactor()
158 *
vtmv(scvf.unitOuterNormal(), insideVolVars.permeability(), gradP);
163 DUNE_THROW(Dune::NotImplemented,
"Mixed boundary types are not supported");