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);
77 static const Scalar xi = getParamFromGroup<Scalar>(problem.paramGroup(),
"FacetCoupling.Xi", 1.0);
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 (compIdx == FluidSystem::getMainComponent(phaseIdx))
116 for (
const auto& scv : scvs(fvGeometry))
117 x +=
massOrMoleFraction(elemVolVars[scv], referenceSystem, phaseIdx, compIdx)*shapeValues[scv.indexInElement()][0];
120 auto gradX = preGradX;
123 componentFlux[compIdx] = -1.0*rho*Extrusion::area(fvGeometry, scvf)
124 *insideVolVars.extrusionFactor()
125 *
vtmv(scvf.unitOuterNormal(),
126 facetVolVars.effectiveDiffusionCoefficient(phaseIdx, phaseIdx, compIdx),
129 if (BalanceEqOpts::mainComponentIsBalanced(phaseIdx) && !FluidSystem::isTracerFluidSystem())
130 componentFlux[FluidSystem::getMainComponent(phaseIdx)] -= componentFlux[compIdx];
133 return componentFlux;
137 else if (bcTypes.hasOnlyDirichlet())
139 for (
int compIdx = 0; compIdx < numComponents; compIdx++)
141 if (compIdx == FluidSystem::getMainComponent(phaseIdx))
145 std::vector<Scalar> xFractions(element.subEntities(dim));
146 for (
const auto& scv : scvs(fvGeometry))
147 xFractions[scv.localDofIndex()] =
massOrMoleFraction(elemVolVars[scv], referenceSystem, phaseIdx, compIdx);
150 for (
const auto& scvfJ : scvfs(fvGeometry))
151 if (scvfJ.interiorBoundary() && scvfJ.facetIndexInElement() == scvf.facetIndexInElement())
152 xFractions[ fvGeometry.scv(scvfJ.insideScvIdx()).localDofIndex() ]
153 =
massOrMoleFraction(problem.couplingManager().getLowDimVolVars(element, scvfJ), referenceSystem, phaseIdx, compIdx);
156 Dune::FieldVector<Scalar, dimWorld> gradX(0.0);
157 for (
const auto& scv : scvs(fvGeometry))
158 gradX.axpy(xFractions[scv.localDofIndex()], fluxVarCache.gradN(scv.indexInElement()));
161 componentFlux[compIdx] = -1.0*rho*Extrusion::area(fvGeometry, scvf)
162 *insideVolVars.extrusionFactor()
163 *
vtmv(scvf.unitOuterNormal(),
164 insideVolVars.effectiveDiffusionCoefficient(phaseIdx, phaseIdx, compIdx),
167 if (BalanceEqOpts::mainComponentIsBalanced(phaseIdx) && !FluidSystem::isTracerFluidSystem())
168 componentFlux[FluidSystem::getMainComponent(phaseIdx)] -= componentFlux[compIdx];
171 return componentFlux;
176 DUNE_THROW(Dune::NotImplemented,
"Mixed boundary types are not supported");