24#ifndef DUMUX_DISCRETIZATION_BOX_FACET_COUPLING_FICKS_LAW_HH
25#define DUMUX_DISCRETIZATION_BOX_FACET_COUPLING_FICKS_LAW_HH
30#include <dune/common/exceptions.hh>
31#include <dune/common/fvector.hh>
32#include <dune/common/float_cmp.hh>
49template<
class TypeTag, ReferenceSystemFormulation referenceSystem = ReferenceSystemFormulation::massAveraged>
56 using FVElementGeometry =
typename GridGeometry::LocalView;
57 using SubControlVolumeFace =
typename FVElementGeometry::SubControlVolumeFace;
58 using GridView =
typename GridGeometry::GridView;
59 using Element =
typename GridView::template Codim<0>::Entity;
61 static constexpr int dim = GridView::dimension;
62 static constexpr int dimWorld = GridView::dimensionworld;
67 static constexpr int numComponents = ModelTraits::numFluidComponents();
70 using ComponentFluxVector = Dune::FieldVector<Scalar, numComponents>;
74 template<
class Problem,
class ElementVolumeVariables,
class ElementFluxVarsCache>
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);
87 static const Scalar xi = getParamFromGroup<Scalar>(problem.paramGroup(),
"FacetCoupling.Xi", 1.0);
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");
190 template<
class Problem,
class ElementVolumeVariables,
class FluxVarCache>
192 const Element& element,
193 const FVElementGeometry& fvGeometry,
194 const ElementVolumeVariables& elemVolVars,
195 const SubControlVolumeFace& scvf,
196 const FluxVarCache& fluxVarCache,
197 unsigned int phaseIdx)
199 DUNE_THROW(Dune::NotImplemented,
"transmissibilty computation for BoxFacetCouplingFicksLaw");
The infrastructure to retrieve run-time parameters from Dune::ParameterTrees.
The available discretization methods in Dumux.
The reference frameworks and formulations available for splitting total fluxes into a advective and d...
VolumeVariables::PrimaryVariables::value_type massOrMoleFraction(const VolumeVariables &volVars, ReferenceSystemFormulation referenceSys, const int phaseIdx, const int compIdx)
returns the mass or mole fraction to be used in Fick's law based on the reference system
Definition: referencesystemformulation.hh:66
VolumeVariables::PrimaryVariables::value_type massOrMolarDensity(const VolumeVariables &volVars, ReferenceSystemFormulation referenceSys, const int phaseIdx)
evaluates the density to be used in Fick's law based on the reference system
Definition: referencesystemformulation.hh:55
Dune::DenseMatrix< MAT >::value_type vtmv(const Dune::DenseVector< V1 > &v1, const Dune::DenseMatrix< MAT > &M, const Dune::DenseVector< V2 > &v2)
Evaluates the scalar product of a vector v2, projected by a matrix M, with a vector v1.
Definition: math.hh:840
typename Properties::Detail::GetPropImpl< TypeTag, Property >::type::type GetPropType
get the type alias defined in the property (equivalent to old macro GET_PROP_TYPE(....
Definition: propertysystem.hh:149
forward declaration of the method-specific implemetation
Definition: flux/box/fickslaw.hh:43
Specialization of Fick's Law for the box method.
Definition: flux/box/fickslaw.hh:51
static ComponentFluxVector flux(const Problem &problem, const Element &element, const FVElementGeometry &fvGeometry, const ElementVolumeVariables &elemVolVars, const SubControlVolumeFace &scvf, const int phaseIdx, const ElementFluxVariablesCache &elemFluxVarsCache)
Definition: flux/box/fickslaw.hh:84
Ficks's law for the box scheme in the context of coupled models where coupling occurs across the face...
Definition: multidomain/facet/box/fickslaw.hh:52
static std::vector< Scalar > calculateTransmissibilities(const Problem &problem, const Element &element, const FVElementGeometry &fvGeometry, const ElementVolumeVariables &elemVolVars, const SubControlVolumeFace &scvf, const FluxVarCache &fluxVarCache, unsigned int phaseIdx)
Definition: multidomain/facet/box/fickslaw.hh:191
static ComponentFluxVector flux(const Problem &problem, const Element &element, const FVElementGeometry &fvGeometry, const ElementVolumeVariables &elemVolVars, const SubControlVolumeFace &scvf, const int phaseIdx, const ElementFluxVarsCache &elemFluxVarCache)
Definition: multidomain/facet/box/fickslaw.hh:75
Declares all properties used in Dumux.
This file contains the data which is required to calculate diffusive fluxes due to molecular diffusio...