3.3.0
DUNE for Multi-{Phase, Component, Scale, Physics, ...} flow and transport in porous media
box/fourierslawnonequilibrium.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 *****************************************************************************/
25#ifndef DUMUX_DISCRETIZATION_BOX_FOURIERS_LAW_NONEQUILIBRIUM_HH
26#define DUMUX_DISCRETIZATION_BOX_FOURIERS_LAW_NONEQUILIBRIUM_HH
27
28#include <dune/common/fvector.hh>
29
30#include <dumux/common/math.hh>
32
35
36namespace Dumux {
37
38// forward declaration
39template <class TypeTag, DiscretizationMethod discMethod>
40class FouriersLawNonEquilibriumImplementation;
41
46template <class TypeTag>
48{
52 using FVElementGeometry = typename GridGeometry::LocalView;
53 using SubControlVolumeFace = typename GridGeometry::SubControlVolumeFace;
54 using Extrusion = Extrusion_t<GridGeometry>;
55 using ElementVolumeVariables = typename GetPropType<TypeTag, Properties::GridVolumeVariables>::LocalView;
56 using ElementFluxVariablesCache = typename GetPropType<TypeTag, Properties::GridFluxVariablesCache>::LocalView;
60 using Element = typename GridView::template Codim<0>::Entity;
61
62 static constexpr auto numEnergyEqSolid = getPropValue<TypeTag, Properties::NumEnergyEqSolid>();
63 static constexpr auto numEnergyEqFluid = getPropValue<TypeTag, Properties::NumEnergyEqFluid>();
64 static constexpr auto numEnergyEq = numEnergyEqSolid + numEnergyEqFluid;
65 static constexpr auto sPhaseIdx = ModelTraits::numFluidPhases();
66
67public:
72 static Scalar flux(const Problem& problem,
73 const Element& element,
74 const FVElementGeometry& fvGeometry,
75 const ElementVolumeVariables& elemVolVars,
76 const SubControlVolumeFace& scvf,
77 const int phaseIdx,
78 const ElementFluxVariablesCache& elemFluxVarsCache)
79 {
80 // get inside and outside diffusion tensors and calculate the harmonic mean
81 const auto& insideScv = fvGeometry.scv(scvf.insideScvIdx());
82 const auto& outsideScv = fvGeometry.scv(scvf.outsideScvIdx());
83 const auto& insideVolVars = elemVolVars[insideScv];
84 const auto& outsideVolVars = elemVolVars[outsideScv];
85 const auto computeLambda = [&](const auto& v){
86 if constexpr (numEnergyEq == 1)
87 return v.effectiveThermalConductivity();
88 else if constexpr (numEnergyEqFluid == 1)
89 return (phaseIdx != sPhaseIdx)
90 ? v.effectiveFluidThermalConductivity()
91 : v.effectiveSolidThermalConductivity();
92 else
93 return v.effectivePhaseThermalConductivity(phaseIdx);
94 };
95
96 auto insideLambda = computeLambda(insideVolVars);
97 auto outsideLambda = computeLambda(outsideVolVars);
98
99 // scale by extrusion factor
100 insideLambda *= insideVolVars.extrusionFactor();
101 outsideLambda *= outsideVolVars.extrusionFactor();
102
103 // the resulting averaged diffusion tensor
104 const auto lambda = problem.spatialParams().harmonicMean(insideLambda, outsideLambda, scvf.unitOuterNormal());
105
106 // evaluate gradTemp at integration point
107 const auto& fluxVarsCache = elemFluxVarsCache[scvf];
108
109 Dune::FieldVector<Scalar, GridView::dimensionworld> gradTemp(0.0);
110 for (auto&& scv : scvs(fvGeometry))
111 {
112 // compute the temperature gradient with the shape functions
113 if (phaseIdx < numEnergyEqFluid)
114 gradTemp.axpy(elemVolVars[scv].temperatureFluid(phaseIdx), fluxVarsCache.gradN(scv.indexInElement()));
115 else
116 gradTemp.axpy(elemVolVars[scv].temperatureSolid(), fluxVarsCache.gradN(scv.indexInElement()));
117 }
118
119 // comute the heat conduction flux
120 return -1.0*vtmv(scvf.unitOuterNormal(), lambda, gradTemp)*Extrusion::area(scvf);
121 }
122};
123
124} // end namespace Dumux
125
126#endif
Define some often used mathematical functions.
The available discretization methods in Dumux.
Helper classes to compute the integration elements.
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:849
Definition: adapt.hh:29
typename Extrusion< T >::type Extrusion_t
Convenience alias for obtaining the extrusion type.
Definition: extrusion.hh:177
typename Properties::Detail::GetPropImpl< TypeTag, Property >::type::type GetPropType
get the type alias defined in the property (equivalent to old macro GET_PROP_TYPE(....
Definition: propertysystem.hh:149
Definition: fourierslawnonequilibrium.hh:36
static Scalar flux(const Problem &problem, const Element &element, const FVElementGeometry &fvGeometry, const ElementVolumeVariables &elemVolVars, const SubControlVolumeFace &scvf, const int phaseIdx, const ElementFluxVariablesCache &elemFluxVarsCache)
Returns the heat flux within a fluid or solid phase (in J/s) across the given sub-control volume face...
Definition: box/fourierslawnonequilibrium.hh:72
Declares all properties used in Dumux.