12#ifndef DUMUX_DISCRETIZATION_BOX_FACET_COUPLING_DARCYS_LAW_HH
13#define DUMUX_DISCRETIZATION_BOX_FACET_COUPLING_DARCYS_LAW_HH
18#include <dune/common/exceptions.hh>
19#include <dune/common/fvector.hh>
20#include <dune/common/float_cmp.hh>
37template<
class Scalar,
class Gr
idGeometry>
42 using FVElementGeometry =
typename GridGeometry::LocalView;
43 using SubControlVolume =
typename GridGeometry::SubControlVolume;
44 using SubControlVolumeFace =
typename GridGeometry::SubControlVolumeFace;
46 using GridView =
typename GridGeometry::GridView;
47 using Element =
typename GridView::template Codim<0>::Entity;
48 using CoordScalar =
typename GridView::ctype;
49 using GlobalPosition =
typename Element::Geometry::GlobalCoordinate;
51 static constexpr int dim = GridView::dimension;
52 static constexpr int dimWorld = GridView::dimensionworld;
56 template<
class Problem,
class ElementVolumeVariables,
class ElementFluxVarsCache>
57 static Scalar
flux(
const Problem& problem,
58 const Element& element,
59 const FVElementGeometry& fvGeometry,
60 const ElementVolumeVariables& elemVolVars,
61 const SubControlVolumeFace& scvf,
63 const ElementFluxVarsCache& elemFluxVarCache)
66 if (!scvf.interiorBoundary())
67 return DefaultDarcysLaw::flux(problem, element, fvGeometry, elemVolVars, scvf, phaseIdx, elemFluxVarCache);
69 static const Scalar xi = getParamFromGroup<Scalar>(problem.paramGroup(),
"FacetCoupling.Xi", 1.0);
70 if ( !Dune::FloatCmp::eq(xi, 1.0, 1e-6) )
71 DUNE_THROW(Dune::NotImplemented,
"Xi != 1.0 cannot be used with the Box-Facet-Coupling scheme");
74 const auto& fluxVarCache = elemFluxVarCache[scvf];
75 const auto& shapeValues = fluxVarCache.shapeValues();
76 const auto& insideScv = fvGeometry.scv(scvf.insideScvIdx());
77 const auto& insideVolVars = elemVolVars[insideScv];
80 const auto bcTypes = problem.interiorBoundaryTypes(element, scvf);
82 static const bool enableGravity = getParamFromGroup<bool>(problem.paramGroup(),
"Problem.EnableGravity");
85 if (bcTypes.hasOnlyNeumann())
90 for (
const auto& scv : scvs(fvGeometry))
92 const auto& volVars = elemVolVars[scv];
93 p += volVars.pressure(phaseIdx)*shapeValues[scv.indexInElement()][0];
94 rho += volVars.density(phaseIdx)*shapeValues[scv.indexInElement()][0];
98 const auto& facetVolVars = problem.couplingManager().getLowDimVolVars(element, scvf);
104 const auto a = facetVolVars.extrusionFactor();
105 auto gradP = scvf.unitOuterNormal();
106 gradP *= dim == dimWorld ? 0.5*a : 0.5*sqrt(a);
107 gradP /= gradP.two_norm2();
108 gradP *= (facetVolVars.pressure(phaseIdx) - p);
110 gradP.axpy(-rho, problem.spatialParams().gravity(scvf.center()));
113 return -1.0*Extrusion::area(fvGeometry, scvf)
114 *insideVolVars.extrusionFactor()
115 *
vtmv(scvf.unitOuterNormal(), facetVolVars.permeability(), gradP);
119 else if (bcTypes.hasOnlyDirichlet())
122 std::vector<Scalar> pressures(element.subEntities(dim));
123 for (
const auto& scv : scvs(fvGeometry))
124 pressures[scv.localDofIndex()] = elemVolVars[scv].pressure(phaseIdx);
127 for (
const auto& scvfJ : scvfs(fvGeometry))
128 if (scvfJ.interiorBoundary() && scvfJ.facetIndexInElement() == scvf.facetIndexInElement())
129 pressures[ fvGeometry.scv(scvfJ.insideScvIdx()).localDofIndex() ]
130 = problem.couplingManager().getLowDimVolVars(element, scvfJ).pressure(phaseIdx);
134 Dune::FieldVector<Scalar, dimWorld> gradP(0.0);
135 for (
const auto& scv : scvs(fvGeometry))
137 rho += elemVolVars[scv].density(phaseIdx)*shapeValues[scv.indexInElement()][0];
138 gradP.axpy(pressures[scv.localDofIndex()], fluxVarCache.gradN(scv.indexInElement()));
142 gradP.axpy(-rho, problem.spatialParams().gravity(scvf.center()));
145 return -1.0*Extrusion::area(fvGeometry, scvf)
146 *insideVolVars.extrusionFactor()
147 *
vtmv(scvf.unitOuterNormal(), insideVolVars.permeability(), gradP);
152 DUNE_THROW(Dune::NotImplemented,
"Mixed boundary types are not supported");
156 template<
class Problem,
class ElementVolumeVariables,
class FluxVarCache>
158 const Element& element,
159 const FVElementGeometry& fvGeometry,
160 const ElementVolumeVariables& elemVolVars,
161 const SubControlVolumeFace& scvf,
162 const FluxVarCache& fluxVarCache)
164 DUNE_THROW(Dune::NotImplemented,
"transmissibilty computation for BoxFacetCouplingDarcysLaw");
Darcy's law for the box scheme in the context of coupled models where coupling occurs across the face...
Definition: multidomain/facet/box/darcyslaw.hh:39
static Scalar 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/darcyslaw.hh:57
static std::vector< Scalar > calculateTransmissibilities(const Problem &problem, const Element &element, const FVElementGeometry &fvGeometry, const ElementVolumeVariables &elemVolVars, const SubControlVolumeFace &scvf, const FluxVarCache &fluxVarCache)
Definition: multidomain/facet/box/darcyslaw.hh:157
Darcy's law for control-volume finite element schemes.
Definition: flux/cvfe/darcyslaw.hh:36
static Scalar flux(const Problem &problem, const Element &element, const FVElementGeometry &fvGeometry, const ElementVolumeVariables &elemVolVars, const SubControlVolumeFace &scvf, const int phaseIdx, const ElementFluxVarsCache &elemFluxVarCache)
Returns the advective flux of a fluid phase across the given sub-control volume face.
Definition: flux/cvfe/darcyslaw.hh:59
Defines all properties used in Dumux.
Helper classes to compute the integration elements.
Specialization of Darcy's Law for control-volume finite element schemes.
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
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.