75 static ComponentFluxVector
flux(
const Problem& problem,
76 const Element& element,
77 const FVElementGeometry& fvGeometry,
78 const ElementVolumeVariables& elemVolVars,
79 const SubControlVolumeFace& scvf,
81 const ElementFluxVarsCache& elemFluxVarCache)
84 if (!scvf.interiorBoundary())
85 return ParentType::flux(problem, element, fvGeometry, elemVolVars, scvf, phaseIdx, elemFluxVarCache);
88 if ( !Dune::FloatCmp::eq(xi, 1.0, 1e-6) )
89 DUNE_THROW(Dune::NotImplemented,
"Xi != 1.0 cannot be used with the Box-Facet-Coupling scheme");
92 const auto& fluxVarCache = elemFluxVarCache[scvf];
93 const auto& shapeValues = fluxVarCache.shapeValues();
94 const auto& insideScv = fvGeometry.scv(scvf.insideScvIdx());
95 const auto& insideVolVars = elemVolVars[insideScv];
99 for (
const auto& scv : scvs(fvGeometry))
100 rho +=
massOrMolarDensity(elemVolVars[scv], referenceSystem, phaseIdx)*shapeValues[scv.indexInElement()][0];
103 ComponentFluxVector componentFlux(0.0);
104 const auto bcTypes = problem.interiorBoundaryTypes(element, scvf);
105 if (bcTypes.hasOnlyNeumann())
108 const auto& facetVolVars = problem.couplingManager().getLowDimVolVars(element, scvf);
114 const auto a = facetVolVars.extrusionFactor();
115 auto preGradX = scvf.unitOuterNormal();
116 preGradX *= dim == dimWorld ? 0.5*a : 0.5*sqrt(a);
117 preGradX /= preGradX.two_norm2();
119 for (
int compIdx = 0; compIdx < numComponents; compIdx++)
121 if (compIdx == FluidSystem::getMainComponent(phaseIdx))
126 for (
const auto& scv : scvs(fvGeometry))
127 x +=
massOrMoleFraction(elemVolVars[scv], referenceSystem, phaseIdx, compIdx)*shapeValues[scv.indexInElement()][0];
130 auto gradX = preGradX;
133 componentFlux[compIdx] = -1.0*rho*scvf.area()
134 *insideVolVars.extrusionFactor()
135 *
vtmv(scvf.unitOuterNormal(),
136 facetVolVars.effectiveDiffusionCoefficient(phaseIdx, phaseIdx, compIdx),
139 if (BalanceEqOpts::mainComponentIsBalanced(phaseIdx) && !FluidSystem::isTracerFluidSystem())
140 componentFlux[FluidSystem::getMainComponent(phaseIdx)] -= componentFlux[compIdx];
143 return componentFlux;
147 else if (bcTypes.hasOnlyDirichlet())
149 for (
int compIdx = 0; compIdx < numComponents; compIdx++)
151 if (compIdx == FluidSystem::getMainComponent(phaseIdx))
155 std::vector<Scalar> xFractions(element.subEntities(dim));
156 for (
const auto& scv : scvs(fvGeometry))
157 xFractions[scv.localDofIndex()] =
massOrMoleFraction(elemVolVars[scv], referenceSystem, phaseIdx, compIdx);
160 for (
const auto& scvfJ : scvfs(fvGeometry))
161 if (scvfJ.interiorBoundary() && scvfJ.facetIndexInElement() == scvf.facetIndexInElement())
162 xFractions[ fvGeometry.scv(scvfJ.insideScvIdx()).localDofIndex() ]
163 =
massOrMoleFraction(problem.couplingManager().getLowDimVolVars(element, scvfJ), referenceSystem, phaseIdx, compIdx);
166 Dune::FieldVector<Scalar, dimWorld> gradX(0.0);
167 for (
const auto& scv : scvs(fvGeometry))
168 gradX.axpy(xFractions[scv.localDofIndex()], fluxVarCache.gradN(scv.indexInElement()));
171 componentFlux[compIdx] = -1.0*rho*scvf.area()
172 *insideVolVars.extrusionFactor()
173 *
vtmv(scvf.unitOuterNormal(),
174 insideVolVars.effectiveDiffusionCoefficient(phaseIdx, phaseIdx, compIdx),
177 if (BalanceEqOpts::mainComponentIsBalanced(phaseIdx) && !FluidSystem::isTracerFluidSystem())
178 componentFlux[FluidSystem::getMainComponent(phaseIdx)] -= componentFlux[compIdx];
181 return componentFlux;
186 DUNE_THROW(Dune::NotImplemented,
"Mixed boundary types are not supported");