version 3.11-dev
Loading...
Searching...
No Matches
flux/cvfe/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// SPDX-FileCopyrightText: Copyright © DuMux Project contributors, see AUTHORS.md in root folder
5// SPDX-License-Identifier: GPL-3.0-or-later
6//
16#ifndef DUMUX_DISCRETIZATION_CVFE_DARCYS_LAW_HH
17#define DUMUX_DISCRETIZATION_CVFE_DARCYS_LAW_HH
18
19#include <dumux/common/math.hh>
26
27namespace Dumux {
28
37template<class Scalar, class GridGeometry, class GravityTermDensity = PhaseDensityInGravityTerm>
39{
40 using FVElementGeometry = typename GridGeometry::LocalView;
41 using SubControlVolumeFace = typename FVElementGeometry::SubControlVolumeFace;
42 using Extrusion = Extrusion_t<GridGeometry>;
43 using GridView = typename GridGeometry::GridView;
44 using Element = typename GridView::template Codim<0>::Entity;
45
46 static constexpr int dim = GridView::dimension;
47 static constexpr int dimWorld = GridView::dimensionworld;
48
49public:
50
61 template<class Problem, class ElementVolumeVariables, class ElementFluxVarsCache>
62 static Scalar flux(const Problem& problem,
63 const Element& element,
64 const FVElementGeometry& fvGeometry,
65 const ElementVolumeVariables& elemVolVars,
66 const SubControlVolumeFace& scvf,
67 const int phaseIdx,
68 const ElementFluxVarsCache& elemFluxVarCache)
69 {
70 const auto& fluxVarCache = elemFluxVarCache[scvf];
71 const auto& insideScv = fvGeometry.scv(scvf.insideScvIdx());
72 const auto& outsideScv = fvGeometry.scv(scvf.outsideScvIdx());
73 const auto& insideVolVars = elemVolVars[insideScv];
74 const auto& outsideVolVars = elemVolVars[outsideScv];
75
76 auto insideK = insideVolVars.permeability();
77 auto outsideK = outsideVolVars.permeability();
78
79 // scale with correct extrusion factor
80 insideK *= insideVolVars.extrusionFactor();
81 outsideK *= outsideVolVars.extrusionFactor();
82
83 const auto K = faceTensorAverage(insideK, outsideK, scvf.unitOuterNormal());
84 static const bool enableGravity = getParamFromGroup<bool>(problem.paramGroup(), "Problem.EnableGravity");
85
86 const auto& shapeValues = fluxVarCache.shapeValues();
87
88 // evaluate gradP - rho*g at integration point
89 Dune::FieldVector<Scalar, dimWorld> gradP(0.0);
90 Scalar rho(0.0);
91 for (auto&& scv : scvs(fvGeometry))
92 {
93 const auto& volVars = elemVolVars[scv];
94
95 if (enableGravity)
96 rho += GravityTermDensity::density(problem, volVars, phaseIdx)*shapeValues[scv.indexInElement()][0];
97
98 // the global shape function gradient
99 gradP.axpy(volVars.pressure(phaseIdx), fluxVarCache.gradN(scv.indexInElement()));
100 }
101
102 if (enableGravity)
103 gradP.axpy(-rho, problem.spatialParams().gravity(scvf.center()));
104
105 // apply the permeability and return the flux
106 return -1.0*vtmv(scvf.unitOuterNormal(), K, gradP)*Extrusion::area(fvGeometry, scvf);
107 }
108
109 // compute transmissibilities ti for analytical Jacobians
110 template<class Problem, class ElementVolumeVariables, class FluxVarCache>
111 static std::vector<Scalar> calculateTransmissibilities(const Problem& problem,
112 const Element& element,
113 const FVElementGeometry& fvGeometry,
114 const ElementVolumeVariables& elemVolVars,
115 const SubControlVolumeFace& scvf,
116 const FluxVarCache& fluxVarCache)
117 {
118 const auto& insideScv = fvGeometry.scv(scvf.insideScvIdx());
119 const auto& outsideScv = fvGeometry.scv(scvf.outsideScvIdx());
120 const auto& insideVolVars = elemVolVars[insideScv];
121 const auto& outsideVolVars = elemVolVars[outsideScv];
122
123 auto insideK = insideVolVars.permeability();
124 auto outsideK = outsideVolVars.permeability();
125
126 // scale with correct extrusion factor
127 insideK *= insideVolVars.extrusionFactor();
128 outsideK *= outsideVolVars.extrusionFactor();
129
130 const auto K = faceTensorAverage(insideK, outsideK, scvf.unitOuterNormal());
131
132 std::vector<Scalar> ti(fvGeometry.numScv());
133 for (const auto& scv : scvs(fvGeometry))
134 ti[scv.indexInElement()] =
135 -1.0*Extrusion::area(fvGeometry, scvf)*vtmv(scvf.unitOuterNormal(), K, fluxVarCache.gradN(scv.indexInElement()));
136
137 return ti;
138 }
139};
140
141// forward declaration
142template<class TypeTag, class DiscretizationMethod>
143class DarcysLawImplementation;
144
149template<class TypeTag, class DM>
151: public CVFEDarcysLaw<GetPropType<TypeTag, Properties::Scalar>, GetPropType<TypeTag, Properties::GridGeometry>>
152{};
153
154} // end namespace Dumux
155
156#endif
Darcy's law for control-volume finite element schemes.
Definition flux/cvfe/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)
Returns the advective flux of a fluid phase across the given sub-control volume face.
Definition flux/cvfe/darcyslaw.hh:62
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/cvfe/darcyslaw.hh:111
forward declaration of the method-specific implementation
Definition flux/ccmpfa/darcyslaw.hh:27
Defines all properties used in Dumux.
Helper classes to compute the integration elements.
A free function to average a Tensor at an interface.
The density in the gravity term of Darcy's law.
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:880
T getParamFromGroup(Args &&... args)
A free function to get a parameter from the parameter tree singleton with a model group.
Definition parameters.hh:165
Define some often used mathematical functions.
The available discretization methods in Dumux.
Definition interpolate.hh:27
Definition method.hh:20
Definition adapt.hh:17
std::ranges::range auto scvs(const FVElementGeometry &fvGeometry, const LocalDof &localDof)
Definition localdof.hh:82
Scalar faceTensorAverage(const Scalar T1, const Scalar T2, const Dune::FieldVector< Scalar, dim > &normal)
Average of a discontinuous scalar field at discontinuity interface (for compatibility reasons with th...
Definition facetensoraverage.hh:29
typename Extrusion< T >::type Extrusion_t
Convenience alias for obtaining the extrusion type.
Definition extrusion.hh:257
The infrastructure to retrieve run-time parameters from Dune::ParameterTrees.