12#ifndef DUMUX_DISCRETIZATION_BOX_FACET_COUPLING_FICKS_LAW_HH
13#define DUMUX_DISCRETIZATION_BOX_FACET_COUPLING_FICKS_LAW_HH
18#include <dune/common/exceptions.hh>
19#include <dune/common/fvector.hh>
20#include <dune/common/float_cmp.hh>
38template<
class TypeTag, ReferenceSystemFormulation referenceSystem = ReferenceSystemFormulation::massAveraged>
45 using FVElementGeometry =
typename GridGeometry::LocalView;
46 using SubControlVolumeFace =
typename GridGeometry::SubControlVolumeFace;
48 using GridView =
typename GridGeometry::GridView;
49 using Element =
typename GridView::template Codim<0>::Entity;
51 static constexpr int dim = GridView::dimension;
52 static constexpr int dimWorld = GridView::dimensionworld;
57 static constexpr int numComponents = ModelTraits::numFluidComponents();
60 using ComponentFluxVector = Dune::FieldVector<Scalar, numComponents>;
64 template<
class Problem,
class ElementVolumeVariables,
class ElementFluxVarsCache>
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");
180 template<
class Problem,
class ElementVolumeVariables,
class FluxVarCache>
182 const Element& element,
183 const FVElementGeometry& fvGeometry,
184 const ElementVolumeVariables& elemVolVars,
185 const SubControlVolumeFace& scvf,
186 const FluxVarCache& fluxVarCache,
187 unsigned int phaseIdx)
189 DUNE_THROW(Dune::NotImplemented,
"transmissibilty computation for BoxFacetCouplingFicksLaw");
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:41
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:181
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:65
Specialization of Fick's Law for the box method.
Definition: flux/box/fickslaw.hh:40
static ComponentFluxVector flux(const Problem &problem, const Element &element, const FVElementGeometry &fvGeometry, const ElementVolumeVariables &elemVolVars, const SubControlVolumeFace &scvf, const int phaseIdx, const ElementFluxVariablesCache &elemFluxVarsCache)
Returns the diffusive fluxes of all components within a fluid phase across the given sub-control volu...
Definition: flux/box/fickslaw.hh:82
forward declaration of the method-specific implementation
Definition: flux/box/fickslaw.hh:32
Defines all properties used in Dumux.
Helper classes to compute the integration elements.
This file contains the data which is required to calculate diffusive fluxes due to molecular diffusio...
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:851
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:54
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:43
typename GetProp< TypeTag, Property >::type GetPropType
get the type alias defined in the property
Definition: propertysystem.hh:296
The available discretization methods in Dumux.
typename Extrusion< T >::type Extrusion_t
Convenience alias for obtaining the extrusion type.
Definition: extrusion.hh:166
The infrastructure to retrieve run-time parameters from Dune::ParameterTrees.