3.2-git
DUNE for Multi-{Phase, Component, Scale, Physics, ...} flow and transport in porous media
flux/box/darcyslaw.hh
Go to the documentation of this file.
1// -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2// vi: set et ts=4 sw=4 sts=4:
3/*****************************************************************************
4 * See the file COPYING for full copying permissions. *
5 * *
6 * This program is free software: you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License as published by *
8 * the Free Software Foundation, either version 3 of the License, or *
9 * (at your option) any later version. *
10 * *
11 * This program is distributed in the hope that it will be useful, *
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14 * GNU General Public License for more details. *
15 * *
16 * You should have received a copy of the GNU General Public License *
17 * along with this program. If not, see <http://www.gnu.org/licenses/>. *
18 *****************************************************************************/
28#ifndef DUMUX_DISCRETIZATION_BOX_DARCYS_LAW_HH
29#define DUMUX_DISCRETIZATION_BOX_DARCYS_LAW_HH
30
31#include <dumux/common/math.hh>
35
36namespace Dumux {
37
38// forward declaration
39template<class TypeTag, DiscretizationMethod discMethod>
40class DarcysLawImplementation;
41
42// forward declaration
43template<class Scalar, class GridGeometry>
44class BoxDarcysLaw;
45
50template<class TypeTag>
52: public BoxDarcysLaw<GetPropType<TypeTag, Properties::Scalar>, GetPropType<TypeTag, Properties::GridGeometry>>
53{ };
54
61template<class Scalar, class GridGeometry>
63{
64 using FVElementGeometry = typename GridGeometry::LocalView;
65 using SubControlVolumeFace = typename FVElementGeometry::SubControlVolumeFace;
66 using GridView = typename GridGeometry::GridView;
67 using Element = typename GridView::template Codim<0>::Entity;
68
69 enum { dim = GridView::dimension};
70 enum { dimWorld = GridView::dimensionworld};
71
72public:
73
74 template<class Problem, class ElementVolumeVariables, class ElementFluxVarsCache>
75 static Scalar flux(const Problem& problem,
76 const Element& element,
77 const FVElementGeometry& fvGeometry,
78 const ElementVolumeVariables& elemVolVars,
79 const SubControlVolumeFace& scvf,
80 const int phaseIdx,
81 const ElementFluxVarsCache& elemFluxVarCache)
82 {
83 const auto& fluxVarCache = elemFluxVarCache[scvf];
84 const auto& insideScv = fvGeometry.scv(scvf.insideScvIdx());
85 const auto& outsideScv = fvGeometry.scv(scvf.outsideScvIdx());
86 const auto& insideVolVars = elemVolVars[insideScv];
87 const auto& outsideVolVars = elemVolVars[outsideScv];
88
89 auto insideK = insideVolVars.permeability();
90 auto outsideK = outsideVolVars.permeability();
91
92 // scale with correct extrusion factor
93 insideK *= insideVolVars.extrusionFactor();
94 outsideK *= outsideVolVars.extrusionFactor();
95
96 const auto K = problem.spatialParams().harmonicMean(insideK, outsideK, scvf.unitOuterNormal());
97 static const bool enableGravity = getParamFromGroup<bool>(problem.paramGroup(), "Problem.EnableGravity");
98
99 const auto& shapeValues = fluxVarCache.shapeValues();
100
101 // evaluate gradP - rho*g at integration point
102 Dune::FieldVector<Scalar, dimWorld> gradP(0.0);
103 Scalar rho(0.0);
104 for (auto&& scv : scvs(fvGeometry))
105 {
106 const auto& volVars = elemVolVars[scv];
107
108 if (enableGravity)
109 rho += volVars.density(phaseIdx)*shapeValues[scv.indexInElement()][0];
110
111 // the global shape function gradient
112 gradP.axpy(volVars.pressure(phaseIdx), fluxVarCache.gradN(scv.indexInElement()));
113 }
114
115 if (enableGravity)
116 gradP.axpy(-rho, problem.spatialParams().gravity(scvf.center()));
117
118 // apply the permeability and return the flux
119 return -1.0*vtmv(scvf.unitOuterNormal(), K, gradP)*scvf.area();
120 }
121
122 // compute transmissibilities ti for analytical jacobians
123 template<class Problem, class ElementVolumeVariables, class FluxVarCache>
124 static std::vector<Scalar> calculateTransmissibilities(const Problem& problem,
125 const Element& element,
126 const FVElementGeometry& fvGeometry,
127 const ElementVolumeVariables& elemVolVars,
128 const SubControlVolumeFace& scvf,
129 const FluxVarCache& fluxVarCache)
130 {
131 const auto& insideScv = fvGeometry.scv(scvf.insideScvIdx());
132 const auto& outsideScv = fvGeometry.scv(scvf.outsideScvIdx());
133 const auto& insideVolVars = elemVolVars[insideScv];
134 const auto& outsideVolVars = elemVolVars[outsideScv];
135
136 auto insideK = insideVolVars.permeability();
137 auto outsideK = outsideVolVars.permeability();
138
139 // scale with correct extrusion factor
140 insideK *= insideVolVars.extrusionFactor();
141 outsideK *= outsideVolVars.extrusionFactor();
142
143 const auto K = problem.spatialParams().harmonicMean(insideK, outsideK, scvf.unitOuterNormal());
144
145 std::vector<Scalar> ti(fvGeometry.numScv());
146 for (const auto& scv : scvs(fvGeometry))
147 ti[scv.indexInElement()] =
148 -1.0*scvf.area()*vtmv(scvf.unitOuterNormal(), K, fluxVarCache.gradN(scv.indexInElement()));
149
150 return ti;
151 }
152};
153
154} // end namespace Dumux
155
156#endif
Define some often used mathematical functions.
The infrastructure to retrieve run-time parameters from Dune::ParameterTrees.
The available discretization methods in Dumux.
DiscretizationMethod
The available discretization methods in Dumux.
Definition: method.hh:37
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
Definition: adapt.hh:29
forward declaration of the method-specific implementation
Definition: flux/darcyslaw.hh:38
Darcy's law for the box scheme.
Definition: flux/box/darcyslaw.hh:63
static std::vector< Scalar > calculateTransmissibilities(const Problem &problem, const Element &element, const FVElementGeometry &fvGeometry, const ElementVolumeVariables &elemVolVars, const SubControlVolumeFace &scvf, const FluxVarCache &fluxVarCache)
Definition: flux/box/darcyslaw.hh:124
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: flux/box/darcyslaw.hh:75
Declares all properties used in Dumux.