24#ifndef DUMUX_DISCRETIZATION_BOX_FACET_COUPLING_DARCYS_LAW_HH
25#define DUMUX_DISCRETIZATION_BOX_FACET_COUPLING_DARCYS_LAW_HH
30#include <dune/common/exceptions.hh>
31#include <dune/common/fvector.hh>
32#include <dune/common/float_cmp.hh>
49template<
class Scalar,
class Gr
idGeometry>
54 using FVElementGeometry =
typename GridGeometry::LocalView;
55 using SubControlVolume =
typename GridGeometry::SubControlVolume;
56 using SubControlVolumeFace =
typename GridGeometry::SubControlVolumeFace;
58 using GridView =
typename GridGeometry::GridView;
59 using Element =
typename GridView::template Codim<0>::Entity;
60 using CoordScalar =
typename GridView::ctype;
61 using GlobalPosition =
typename Element::Geometry::GlobalCoordinate;
63 static constexpr int dim = GridView::dimension;
64 static constexpr int dimWorld = GridView::dimensionworld;
68 template<
class Problem,
class ElementVolumeVariables,
class ElementFluxVarsCache>
69 static Scalar
flux(
const Problem& problem,
70 const Element& element,
71 const FVElementGeometry& fvGeometry,
72 const ElementVolumeVariables& elemVolVars,
73 const SubControlVolumeFace& scvf,
75 const ElementFluxVarsCache& elemFluxVarCache)
78 if (!scvf.interiorBoundary())
79 return DefaultDarcysLaw::flux(problem, element, fvGeometry, elemVolVars, scvf, phaseIdx, elemFluxVarCache);
81 static const Scalar xi = getParamFromGroup<Scalar>(problem.paramGroup(),
"FacetCoupling.Xi", 1.0);
82 if ( !Dune::FloatCmp::eq(xi, 1.0, 1e-6) )
83 DUNE_THROW(Dune::NotImplemented,
"Xi != 1.0 cannot be used with the Box-Facet-Coupling scheme");
86 const auto& fluxVarCache = elemFluxVarCache[scvf];
87 const auto& shapeValues = fluxVarCache.shapeValues();
88 const auto& insideScv = fvGeometry.scv(scvf.insideScvIdx());
89 const auto& insideVolVars = elemVolVars[insideScv];
92 const auto bcTypes = problem.interiorBoundaryTypes(element, scvf);
94 static const bool enableGravity = getParamFromGroup<bool>(problem.paramGroup(),
"Problem.EnableGravity");
97 if (bcTypes.hasOnlyNeumann())
102 for (
const auto& scv : scvs(fvGeometry))
104 const auto& volVars = elemVolVars[scv];
105 p += volVars.pressure(phaseIdx)*shapeValues[scv.indexInElement()][0];
106 rho += volVars.density(phaseIdx)*shapeValues[scv.indexInElement()][0];
110 const auto& facetVolVars = problem.couplingManager().getLowDimVolVars(element, scvf);
116 const auto a = facetVolVars.extrusionFactor();
117 auto gradP = scvf.unitOuterNormal();
118 gradP *= dim == dimWorld ? 0.5*a : 0.5*sqrt(a);
119 gradP /= gradP.two_norm2();
120 gradP *= (facetVolVars.pressure(phaseIdx) - p);
122 gradP.axpy(-rho, problem.spatialParams().gravity(scvf.center()));
125 return -1.0*Extrusion::area(fvGeometry, scvf)
126 *insideVolVars.extrusionFactor()
127 *
vtmv(scvf.unitOuterNormal(), facetVolVars.permeability(), gradP);
131 else if (bcTypes.hasOnlyDirichlet())
134 std::vector<Scalar> pressures(element.subEntities(dim));
135 for (
const auto& scv : scvs(fvGeometry))
136 pressures[scv.localDofIndex()] = elemVolVars[scv].pressure(phaseIdx);
139 for (
const auto& scvfJ : scvfs(fvGeometry))
140 if (scvfJ.interiorBoundary() && scvfJ.facetIndexInElement() == scvf.facetIndexInElement())
141 pressures[ fvGeometry.scv(scvfJ.insideScvIdx()).localDofIndex() ]
142 = problem.couplingManager().getLowDimVolVars(element, scvfJ).pressure(phaseIdx);
146 Dune::FieldVector<Scalar, dimWorld> gradP(0.0);
147 for (
const auto& scv : scvs(fvGeometry))
149 rho += elemVolVars[scv].density(phaseIdx)*shapeValues[scv.indexInElement()][0];
150 gradP.axpy(pressures[scv.localDofIndex()], fluxVarCache.gradN(scv.indexInElement()));
154 gradP.axpy(-rho, problem.spatialParams().gravity(scvf.center()));
157 return -1.0*Extrusion::area(fvGeometry, scvf)
158 *insideVolVars.extrusionFactor()
159 *
vtmv(scvf.unitOuterNormal(), insideVolVars.permeability(), gradP);
164 DUNE_THROW(Dune::NotImplemented,
"Mixed boundary types are not supported");
168 template<
class Problem,
class ElementVolumeVariables,
class FluxVarCache>
170 const Element& element,
171 const FVElementGeometry& fvGeometry,
172 const ElementVolumeVariables& elemVolVars,
173 const SubControlVolumeFace& scvf,
174 const FluxVarCache& fluxVarCache)
176 DUNE_THROW(Dune::NotImplemented,
"transmissibilty computation for BoxFacetCouplingDarcysLaw");
The infrastructure to retrieve run-time parameters from Dune::ParameterTrees.
Helper classes to compute the integration elements.
The available discretization methods in Dumux.
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:863
Adaption of the non-isothermal two-phase two-component flow model to problems with CO2.
Definition: adapt.hh:29
typename Extrusion< T >::type Extrusion_t
Convenience alias for obtaining the extrusion type.
Definition: extrusion.hh:251
Darcy's law for control-volume finite element schemes.
Definition: flux/cvfe/darcyslaw.hh:48
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:71
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:51
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:69
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:169
Declares all properties used in Dumux.
Specialization of Darcy's Law for control-volume finite element schemes.