3.1-git
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/float_cmp.hh>
29
30#include <dumux/common/math.hh>
33
35
36
37namespace Dumux {
38
39// forward declaration
40template <class TypeTag, DiscretizationMethod discMethod>
41class FouriersLawNonEquilibriumImplementation;
42
47template <class TypeTag>
49{
52 using FVElementGeometry = typename GetPropType<TypeTag, Properties::GridGeometry>::LocalView;
53 using SubControlVolumeFace = typename FVElementGeometry::SubControlVolumeFace;
54 using ElementVolumeVariables = typename GetPropType<TypeTag, Properties::GridVolumeVariables>::LocalView;
55 using ElementFluxVariablesCache = typename GetPropType<TypeTag, Properties::GridFluxVariablesCache>::LocalView;
59 using Element = typename GridView::template Codim<0>::Entity;
60
61 static constexpr auto numEnergyEqFluid = getPropValue<TypeTag, Properties::NumEnergyEqFluid>();
62 static constexpr auto sPhaseIdx = ModelTraits::numFluidPhases();
63
64public:
65 static Scalar flux(const Problem& problem,
66 const Element& element,
67 const FVElementGeometry& fvGeometry,
68 const ElementVolumeVariables& elemVolVars,
69 const SubControlVolumeFace& scvf,
70 const int phaseIdx,
71 const ElementFluxVariablesCache& elemFluxVarsCache)
72 {
73 // get inside and outside diffusion tensors and calculate the harmonic mean
74 const auto& insideScv = fvGeometry.scv(scvf.insideScvIdx());
75 const auto& outsideScv = fvGeometry.scv(scvf.outsideScvIdx());
76 const auto& insideVolVars = elemVolVars[insideScv];
77 const auto& outsideVolVars = elemVolVars[outsideScv];
78 Scalar insideLambda = 0.0;
79 Scalar outsideLambda = 0.0;
80 // effective diffusion tensors
81 if (phaseIdx != sPhaseIdx)
82 {
83 //when number of energyEq for the fluid are smaller than numPhases that means that we need an effecitve law
84 if (numEnergyEqFluid < ModelTraits::numFluidPhases())
85 {
86 insideLambda += Deprecated::template effectiveThermalConductivity<ThermalConductivityModel>(
87 insideVolVars, problem.spatialParams(), element, fvGeometry, insideScv);
88 outsideLambda += Deprecated::template effectiveThermalConductivity<ThermalConductivityModel>(
89 outsideVolVars, problem.spatialParams(), element, fvGeometry, outsideScv);
90 }
91 else
92 {
93 insideLambda += insideVolVars.fluidThermalConductivity(phaseIdx)*insideVolVars.saturation(phaseIdx)*insideVolVars.porosity();
94 outsideLambda += outsideVolVars.fluidThermalConductivity(phaseIdx)*outsideVolVars.saturation(phaseIdx)*outsideVolVars.porosity();
95 }
96 }
97 //solid phase
98 else
99 {
100 insideLambda += insideVolVars.solidThermalConductivity()*(1.0-insideVolVars.porosity());
101 outsideLambda += outsideVolVars.solidThermalConductivity()*(1.0-outsideVolVars.porosity());
102 }
103
104 // scale by extrusion factor
105 insideLambda *= insideVolVars.extrusionFactor();
106 outsideLambda *= outsideVolVars.extrusionFactor();
107
108 // the resulting averaged diffusion tensor
109 const auto lambda = problem.spatialParams().harmonicMean(insideLambda, outsideLambda, scvf.unitOuterNormal());
110
111 // evaluate gradTemp at integration point
112 const auto& fluxVarsCache = elemFluxVarsCache[scvf];
113
114 Dune::FieldVector<Scalar, GridView::dimensionworld> gradTemp(0.0);
115 for (auto&& scv : scvs(fvGeometry))
116 {
117 // compute the temperature gradient with the shape functions
118 if (phaseIdx < numEnergyEqFluid)
119 gradTemp.axpy(elemVolVars[scv].temperatureFluid(phaseIdx), fluxVarsCache.gradN(scv.indexInElement()));
120 else
121 gradTemp.axpy(elemVolVars[scv].temperatureSolid(), fluxVarsCache.gradN(scv.indexInElement()));
122 }
123
124 // comute the heat conduction flux
125 return -1.0*vtmv(scvf.unitOuterNormal(), lambda, gradTemp)*scvf.area();
126 }
127};
128
129} // end namespace Dumux
130
131#endif
Helpers for deprecation.
Define some often used mathematical functions.
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
make the local view function available whenever we use the grid geometry
Definition: adapt.hh:29
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)
Definition: box/fourierslawnonequilibrium.hh:65
Declares all properties used in Dumux.