65    static ComponentFluxVector 
flux(
const Problem& problem,
 
   66                                    const Element& element,
 
   67                                    const FVElementGeometry& fvGeometry,
 
   68                                    const ElementVolumeVariables& elemVolVars,
 
   69                                    const SubControlVolumeFace& scvf,
 
   71                                    const ElementFluxVarsCache& elemFluxVarCache)
 
   74        if (!scvf.interiorBoundary())
 
   75            return ParentType::flux(problem, element, fvGeometry, elemVolVars, scvf, phaseIdx, elemFluxVarCache);
 
   78        if ( !Dune::FloatCmp::eq(xi, 1.0, 1e-6) )
 
   79            DUNE_THROW(Dune::NotImplemented, 
"Xi != 1.0 cannot be used with the Box-Facet-Coupling scheme");
 
   82        const auto& fluxVarCache = elemFluxVarCache[scvf];
 
   83        const auto& shapeValues = fluxVarCache.shapeValues();
 
   84        const auto& insideScv = fvGeometry.scv(scvf.insideScvIdx());
 
   85        const auto& insideVolVars = elemVolVars[insideScv];
 
   89        for (
const auto& scv : scvs(fvGeometry))
 
   90            rho += 
massOrMolarDensity(elemVolVars[scv], referenceSystem, phaseIdx)*shapeValues[scv.indexInElement()][0];
 
   93        ComponentFluxVector componentFlux(0.0);
 
   94        const auto bcTypes = problem.interiorBoundaryTypes(element, scvf);
 
   95        if (bcTypes.hasOnlyNeumann())
 
   98            const auto& facetVolVars = problem.couplingManager().getLowDimVolVars(element, scvf);
 
  104            const auto a = facetVolVars.extrusionFactor();
 
  105            auto preGradX = scvf.unitOuterNormal();
 
  106            preGradX *= dim == dimWorld ? 0.5*a : 0.5*sqrt(a);
 
  107            preGradX /= preGradX.two_norm2();
 
  109            for (
int compIdx = 0; compIdx < numComponents; compIdx++)
 
  111                if constexpr (!FluidSystem::isTracerFluidSystem())
 
  112                    if (compIdx == FluidSystem::getMainComponent(phaseIdx))
 
  117                for (
const auto& scv : scvs(fvGeometry))
 
  118                    x += 
massOrMoleFraction(elemVolVars[scv], referenceSystem, phaseIdx, compIdx)*shapeValues[scv.indexInElement()][0];
 
  121                auto gradX = preGradX;
 
  124                componentFlux[compIdx] = -1.0*rho*Extrusion::area(fvGeometry, scvf)
 
  125                                             *insideVolVars.extrusionFactor()
 
  126                                             *
vtmv(scvf.unitOuterNormal(),
 
  127                                                   facetVolVars.effectiveDiffusionCoefficient(phaseIdx, phaseIdx, compIdx),
 
  130                if constexpr (!FluidSystem::isTracerFluidSystem())
 
  131                    if (BalanceEqOpts::mainComponentIsBalanced(phaseIdx))
 
  132                        componentFlux[FluidSystem::getMainComponent(phaseIdx)] -= componentFlux[compIdx];
 
  135            return componentFlux;
 
  139        else if (bcTypes.hasOnlyDirichlet())
 
  141            for (
int compIdx = 0; compIdx < numComponents; compIdx++)
 
  143                if constexpr (!FluidSystem::isTracerFluidSystem())
 
  144                    if (compIdx == FluidSystem::getMainComponent(phaseIdx))
 
  148                std::vector<Scalar> xFractions(element.subEntities(dim));
 
  149                for (
const auto& scv : scvs(fvGeometry))
 
  150                    xFractions[scv.localDofIndex()] = 
massOrMoleFraction(elemVolVars[scv], referenceSystem, phaseIdx, compIdx);
 
  153                for (
const auto& scvfJ : scvfs(fvGeometry))
 
  154                    if (scvfJ.interiorBoundary() && scvfJ.facetIndexInElement() == scvf.facetIndexInElement())
 
  155                        xFractions[ fvGeometry.scv(scvfJ.insideScvIdx()).localDofIndex() ]
 
  156                                 = 
massOrMoleFraction(problem.couplingManager().getLowDimVolVars(element, scvfJ), referenceSystem, phaseIdx, compIdx);
 
  159                Dune::FieldVector<Scalar, dimWorld> gradX(0.0);
 
  160                for (
const auto& scv : scvs(fvGeometry))
 
  161                    gradX.axpy(xFractions[scv.localDofIndex()], fluxVarCache.gradN(scv.indexInElement()));
 
  164                componentFlux[compIdx] = -1.0*rho*Extrusion::area(fvGeometry, scvf)
 
  165                                             *insideVolVars.extrusionFactor()
 
  166                                             *
vtmv(scvf.unitOuterNormal(),
 
  167                                                   insideVolVars.effectiveDiffusionCoefficient(phaseIdx, phaseIdx, compIdx),
 
  170                if constexpr (!FluidSystem::isTracerFluidSystem())
 
  171                    if (BalanceEqOpts::mainComponentIsBalanced(phaseIdx))
 
  172                        componentFlux[FluidSystem::getMainComponent(phaseIdx)] -= componentFlux[compIdx];
 
  175            return componentFlux;
 
  180            DUNE_THROW(Dune::NotImplemented, 
"Mixed boundary types are not supported");