3.6-git
DUNE for Multi-{Phase, Component, Scale, Physics, ...} flow and transport in porous media
flux/cctpfa/fourierslaw.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 *****************************************************************************/
24#ifndef DUMUX_DISCRETIZATION_CC_TPFA_FOURIERS_LAW_HH
25#define DUMUX_DISCRETIZATION_CC_TPFA_FOURIERS_LAW_HH
26
29
33
34namespace Dumux {
35
36// forward declaration
37template<class TypeTag, class DiscretizationMethod>
38class FouriersLawImplementation;
39
44template <class TypeTag>
45class FouriersLawImplementation<TypeTag, DiscretizationMethods::CCTpfa>
46{
51 using FVElementGeometry = typename GridGeometry::LocalView;
52 using SubControlVolumeFace = typename GridGeometry::SubControlVolumeFace;
53 using Extrusion = Extrusion_t<GridGeometry>;
54 using GridView = typename GridGeometry::GridView;
55 using ElementVolumeVariables = typename GetPropType<TypeTag, Properties::GridVolumeVariables>::LocalView;
56 using VolumeVariables = typename ElementVolumeVariables::VolumeVariables;
57 using Element = typename GridView::template Codim<0>::Entity;
59 using ElementFluxVarsCache = typename GridFluxVariablesCache::LocalView;
60 using FluxVariablesCache = typename GridFluxVariablesCache::FluxVariablesCache;
61
62 static const int dim = GridView::dimension;
63 static const int dimWorld = GridView::dimensionworld;
64
66 class TpfaFouriersLawCacheFiller
67 {
68 public:
71 template<class FluxVariablesCacheFiller>
72 static void fill(FluxVariablesCache& scvfFluxVarsCache,
73 const Problem& problem,
74 const Element& element,
75 const FVElementGeometry& fvGeometry,
76 const ElementVolumeVariables& elemVolVars,
77 const SubControlVolumeFace& scvf,
78 const FluxVariablesCacheFiller& fluxVarsCacheFiller)
79 {
80 scvfFluxVarsCache.updateHeatConduction(problem, element, fvGeometry, elemVolVars, scvf);
81 }
82 };
83
85 class TpfaFouriersLawCache
86 {
87 public:
88 using Filler = TpfaFouriersLawCacheFiller;
89
90 void updateHeatConduction(const Problem& problem,
91 const Element& element,
92 const FVElementGeometry& fvGeometry,
93 const ElementVolumeVariables& elemVolVars,
94 const SubControlVolumeFace &scvf)
95 {
96 tij_ = Implementation::calculateTransmissibility(problem, element, fvGeometry, elemVolVars, scvf);
97 }
98
99 const Scalar& heatConductionTij() const
100 { return tij_; }
101
102 private:
103 Scalar tij_;
104 };
105
106public:
109 static constexpr DiscretizationMethod discMethod{};
110
112 using Cache = TpfaFouriersLawCache;
113
125 static Scalar flux(const Problem& problem,
126 const Element& element,
127 const FVElementGeometry& fvGeometry,
128 const VolumeVariables& insideVolVars,
129 const VolumeVariables& outsideVolVars,
130 const SubControlVolumeFace& scvf,
131 const ElementFluxVarsCache& elemFluxVarsCache)
132 {
133 if constexpr (isMixedDimensional_)
134 if (scvf.numOutsideScv() != 1)
135 DUNE_THROW(Dune::Exception, "This flux overload requires scvf.numOutsideScv() == 1");
136
137 // heat conductivities are always solution dependent (?)
138 Scalar tij = elemFluxVarsCache[scvf].heatConductionTij();
139
140 // get the inside/outside temperatures
141 const auto tInside = insideVolVars.temperature();
142 const auto tOutside = outsideVolVars.temperature();
143
144 return tij*(tInside - tOutside);
145 }
146
154 static Scalar flux(const Problem& problem,
155 const Element& element,
156 const FVElementGeometry& fvGeometry,
157 const ElementVolumeVariables& elemVolVars,
158 const SubControlVolumeFace& scvf,
159 const ElementFluxVarsCache& elemFluxVarsCache)
160 {
161 // heat conductivities are always solution dependent (?)
162 Scalar tij = elemFluxVarsCache[scvf].heatConductionTij();
163
164 // get the inside/outside temperatures
165 const auto tInside = elemVolVars[scvf.insideScvIdx()].temperature();
166 const auto tOutside = scvf.numOutsideScvs() == 1 ? elemVolVars[scvf.outsideScvIdx()].temperature()
167 : branchingFacetTemperature_(problem, element, fvGeometry, elemVolVars, elemFluxVarsCache, scvf, tInside, tij);
168
169 return tij*(tInside - tOutside);
170 }
171
173 static Scalar calculateTransmissibility(const Problem& problem,
174 const Element& element,
175 const FVElementGeometry& fvGeometry,
176 const ElementVolumeVariables& elemVolVars,
177 const SubControlVolumeFace& scvf)
178 {
179 Scalar tij;
180
181 const auto insideScvIdx = scvf.insideScvIdx();
182 const auto& insideScv = fvGeometry.scv(insideScvIdx);
183 const auto& insideVolVars = elemVolVars[insideScvIdx];
184
185 const auto insideLambda = insideVolVars.effectiveThermalConductivity();
186 const Scalar ti = computeTpfaTransmissibility(fvGeometry, scvf, insideScv, insideLambda, insideVolVars.extrusionFactor());
187
188 // for the boundary (dirichlet) or at branching points we only need ti
189 if (scvf.boundary() || scvf.numOutsideScvs() > 1)
190 {
191 tij = Extrusion::area(fvGeometry, scvf)*ti;
192 }
193 // otherwise we compute a tpfa harmonic mean
194 else
195 {
196 const auto outsideScvIdx = scvf.outsideScvIdx();
197 const auto& outsideScv = fvGeometry.scv(outsideScvIdx);
198 const auto& outsideVolVars = elemVolVars[outsideScvIdx];
199
200 const auto outsideLambda = outsideVolVars.effectiveThermalConductivity();
201 Scalar tj;
202 if constexpr (dim == dimWorld)
203 // assume the normal vector from outside is anti parallel so we save flipping a vector
204 tj = -1.0*computeTpfaTransmissibility(fvGeometry, scvf, outsideScv, outsideLambda, outsideVolVars.extrusionFactor());
205 else
206 tj = computeTpfaTransmissibility(fvGeometry, fvGeometry.flipScvf(scvf.index()), outsideScv, outsideLambda, outsideVolVars.extrusionFactor());
207
208 // check for division by zero!
209 if (ti*tj <= 0.0)
210 tij = 0;
211 else
212 tij = Extrusion::area(fvGeometry, scvf)*(ti * tj)/(ti + tj);
213 }
214
215 return tij;
216 }
217
218private:
219
221 static Scalar branchingFacetTemperature_(const Problem& problem,
222 const Element& element,
223 const FVElementGeometry& fvGeometry,
224 const ElementVolumeVariables& elemVolVars,
225 const ElementFluxVarsCache& elemFluxVarsCache,
226 const SubControlVolumeFace& scvf,
227 Scalar insideTemperature,
228 Scalar insideTi)
229 {
230 Scalar sumTi(insideTi);
231 Scalar sumTempTi(insideTi*insideTemperature);
232
233 for (unsigned int i = 0; i < scvf.numOutsideScvs(); ++i)
234 {
235 const auto outsideScvIdx = scvf.outsideScvIdx(i);
236 const auto& outsideVolVars = elemVolVars[outsideScvIdx];
237 const auto& flippedScvf = fvGeometry.flipScvf(scvf.index(), i);
238 const auto& outsideFluxVarsCache = elemFluxVarsCache[flippedScvf];
239
240 auto outsideTi = outsideFluxVarsCache.heatConductionTij();
241 sumTi += outsideTi;
242 sumTempTi += outsideTi*outsideVolVars.temperature();
243 }
244 return sumTempTi/sumTi;
245 }
246
247 static constexpr bool isMixedDimensional_ = static_cast<int>(GridView::dimension) < static_cast<int>(GridView::dimensionworld);
248};
249
250} // end namespace Dumux
251
252#endif
The infrastructure to retrieve run-time parameters from Dune::ParameterTrees.
Helper classes to compute the integration elements.
The available discretization methods in Dumux.
Tensor::field_type computeTpfaTransmissibility(const SubControlVolumeFace &scvf, const SubControlVolume &scv, const Tensor &T, typename SubControlVolume::Traits::Scalar extrusionFactor)
Free function to evaluate the Tpfa transmissibility associated with the flux (in the form of flux = T...
Definition: tpfa/computetransmissibility.hh:48
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
typename GetProp< TypeTag, Property >::type GetPropType
get the type alias defined in the property
Definition: propertysystem.hh:180
Definition: method.hh:37
forward declaration of the method-specific implementation
Definition: flux/box/fourierslaw.hh:38
Fourier's law for cell-centered finite volume schemes with two-point flux approximation.
Definition: flux/cctpfa/fourierslaw.hh:46
static Scalar flux(const Problem &problem, const Element &element, const FVElementGeometry &fvGeometry, const ElementVolumeVariables &elemVolVars, const SubControlVolumeFace &scvf, const ElementFluxVarsCache &elemFluxVarsCache)
Returns the heat flux within the porous medium (in J/s) across the given sub-control volume face.
Definition: flux/cctpfa/fourierslaw.hh:154
static Scalar flux(const Problem &problem, const Element &element, const FVElementGeometry &fvGeometry, const VolumeVariables &insideVolVars, const VolumeVariables &outsideVolVars, const SubControlVolumeFace &scvf, const ElementFluxVarsCache &elemFluxVarsCache)
Returns the heat flux within the porous medium (in J/s) across the given sub-control volume face.
Definition: flux/cctpfa/fourierslaw.hh:125
static Scalar calculateTransmissibility(const Problem &problem, const Element &element, const FVElementGeometry &fvGeometry, const ElementVolumeVariables &elemVolVars, const SubControlVolumeFace &scvf)
Compute transmissibilities.
Definition: flux/cctpfa/fourierslaw.hh:173
TpfaFouriersLawCache Cache
export the type for the corresponding cache
Definition: flux/cctpfa/fourierslaw.hh:112
Declares all properties used in Dumux.
Free functions to evaluate the transmissibilities associated with flux evaluations across sub-control...