77 static ComponentFluxVector
flux(
const Problem& problem,
78 const Element& element,
79 const FVElementGeometry& fvGeometry,
80 const ElementVolumeVariables& elemVolVars,
81 const SubControlVolumeFace& scvf,
83 const ElementFluxVarsCache& elemFluxVarCache)
86 if (!scvf.interiorBoundary())
87 return ParentType::flux(problem, element, fvGeometry, elemVolVars, scvf, phaseIdx, elemFluxVarCache);
90 if ( !Dune::FloatCmp::eq(xi, 1.0, 1e-6) )
91 DUNE_THROW(Dune::NotImplemented,
"Xi != 1.0 cannot be used with the Box-Facet-Coupling scheme");
94 const auto& fluxVarCache = elemFluxVarCache[scvf];
95 const auto& shapeValues = fluxVarCache.shapeValues();
96 const auto& insideScv = fvGeometry.scv(scvf.insideScvIdx());
97 const auto& insideVolVars = elemVolVars[insideScv];
101 for (
const auto& scv : scvs(fvGeometry))
102 rho +=
massOrMolarDensity(elemVolVars[scv], referenceSystem, phaseIdx)*shapeValues[scv.indexInElement()][0];
105 ComponentFluxVector componentFlux(0.0);
106 const auto bcTypes = problem.interiorBoundaryTypes(element, scvf);
107 if (bcTypes.hasOnlyNeumann())
110 const auto& facetVolVars = problem.couplingManager().getLowDimVolVars(element, scvf);
116 const auto a = facetVolVars.extrusionFactor();
117 auto preGradX = scvf.unitOuterNormal();
118 preGradX *= dim == dimWorld ? 0.5*a : 0.5*sqrt(a);
119 preGradX /= preGradX.two_norm2();
121 for (
int compIdx = 0; compIdx < numComponents; compIdx++)
123 if (compIdx == FluidSystem::getMainComponent(phaseIdx))
128 for (
const auto& scv : scvs(fvGeometry))
129 x +=
massOrMoleFraction(elemVolVars[scv], referenceSystem, phaseIdx, compIdx)*shapeValues[scv.indexInElement()][0];
132 auto gradX = preGradX;
135 componentFlux[compIdx] = -1.0*rho*Extrusion::area(scvf)
136 *insideVolVars.extrusionFactor()
137 *
vtmv(scvf.unitOuterNormal(),
138 facetVolVars.effectiveDiffusionCoefficient(phaseIdx, phaseIdx, compIdx),
141 if (BalanceEqOpts::mainComponentIsBalanced(phaseIdx) && !FluidSystem::isTracerFluidSystem())
142 componentFlux[FluidSystem::getMainComponent(phaseIdx)] -= componentFlux[compIdx];
145 return componentFlux;
149 else if (bcTypes.hasOnlyDirichlet())
151 for (
int compIdx = 0; compIdx < numComponents; compIdx++)
153 if (compIdx == FluidSystem::getMainComponent(phaseIdx))
157 std::vector<Scalar> xFractions(element.subEntities(dim));
158 for (
const auto& scv : scvs(fvGeometry))
159 xFractions[scv.localDofIndex()] =
massOrMoleFraction(elemVolVars[scv], referenceSystem, phaseIdx, compIdx);
162 for (
const auto& scvfJ : scvfs(fvGeometry))
163 if (scvfJ.interiorBoundary() && scvfJ.facetIndexInElement() == scvf.facetIndexInElement())
164 xFractions[ fvGeometry.scv(scvfJ.insideScvIdx()).localDofIndex() ]
165 =
massOrMoleFraction(problem.couplingManager().getLowDimVolVars(element, scvfJ), referenceSystem, phaseIdx, compIdx);
168 Dune::FieldVector<Scalar, dimWorld> gradX(0.0);
169 for (
const auto& scv : scvs(fvGeometry))
170 gradX.axpy(xFractions[scv.localDofIndex()], fluxVarCache.gradN(scv.indexInElement()));
173 componentFlux[compIdx] = -1.0*rho*Extrusion::area(scvf)
174 *insideVolVars.extrusionFactor()
175 *
vtmv(scvf.unitOuterNormal(),
176 insideVolVars.effectiveDiffusionCoefficient(phaseIdx, phaseIdx, compIdx),
179 if (BalanceEqOpts::mainComponentIsBalanced(phaseIdx) && !FluidSystem::isTracerFluidSystem())
180 componentFlux[FluidSystem::getMainComponent(phaseIdx)] -= componentFlux[compIdx];
183 return componentFlux;
188 DUNE_THROW(Dune::NotImplemented,
"Mixed boundary types are not supported");