3.5-git
DUNE for Multi-{Phase, Component, Scale, Physics, ...} flow and transport in porous media
flux/ccmpfa/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_MPFA_FOURIERS_LAW_HH
25#define DUMUX_DISCRETIZATION_CC_MPFA_FOURIERS_LAW_HH
26
27#include <dune/common/dynvector.hh>
28#include <dune/common/dynmatrix.hh>
29
32
33namespace Dumux {
34
36template<class TypeTag, class DiscretizationMethod>
37class FouriersLawImplementation;
38
43template <class TypeTag>
44class FouriersLawImplementation<TypeTag, DiscretizationMethods::CCMpfa>
45{
49 using Element = typename GridView::template Codim<0>::Entity;
50
51 static constexpr int dim = GridView::dimension;
52 static constexpr int dimWorld = GridView::dimensionworld;
53
55 using FVElementGeometry = typename GridGeometry::LocalView;
56 using SubControlVolumeFace = typename FVElementGeometry::SubControlVolumeFace;
57 using ElementVolumeVariables = typename GetPropType<TypeTag, Properties::GridVolumeVariables>::LocalView;
60
62 class MpfaFouriersLawCacheFiller
63 {
64 public:
67 template<class FluxVariablesCacheFiller>
68 static void fill(FluxVariablesCache& scvfFluxVarsCache,
69 const Problem& problem,
70 const Element& element,
71 const FVElementGeometry& fvGeometry,
72 const ElementVolumeVariables& elemVolVars,
73 const SubControlVolumeFace& scvf,
74 const FluxVariablesCacheFiller& fluxVarsCacheFiller)
75 {
76 // get interaction volume from the flux vars cache filler & upate the cache
77 if (fvGeometry.gridGeometry().vertexUsesSecondaryInteractionVolume(scvf.vertexIndex()))
78 scvfFluxVarsCache.updateHeatConduction(fluxVarsCacheFiller.secondaryInteractionVolume(),
79 fluxVarsCacheFiller.secondaryIvLocalFaceData(),
80 fluxVarsCacheFiller.secondaryIvDataHandle());
81 else
82 scvfFluxVarsCache.updateHeatConduction(fluxVarsCacheFiller.primaryInteractionVolume(),
83 fluxVarsCacheFiller.primaryIvLocalFaceData(),
84 fluxVarsCacheFiller.primaryIvDataHandle());
85 }
86 };
87
89 class MpfaFouriersLawCache
90 {
92 using Stencil = typename DualGridNodalIndexSet::NodalGridStencilType;
93
94 static constexpr bool considerSecondaryIVs = GridGeometry::MpfaHelper::considerSecondaryIVs();
95 using PrimaryDataHandle = typename ElementFluxVarsCache::PrimaryIvDataHandle::HeatConductionHandle;
96 using SecondaryDataHandle = typename ElementFluxVarsCache::SecondaryIvDataHandle::HeatConductionHandle;
97
99 template< bool doSecondary = considerSecondaryIVs, std::enable_if_t<doSecondary, int> = 0 >
100 void setHandlePointer_(const SecondaryDataHandle& dataHandle)
101 { secondaryHandlePtr_ = &dataHandle; }
102
104 void setHandlePointer_(const PrimaryDataHandle& dataHandle)
105 { primaryHandlePtr_ = &dataHandle; }
106
107 public:
108 // export filler type
109 using Filler = MpfaFouriersLawCacheFiller;
110
119 template<class IV, class LocalFaceData, class DataHandle>
120 void updateHeatConduction(const IV& iv,
121 const LocalFaceData& localFaceData,
122 const DataHandle& dataHandle)
123 {
124 switchFluxSign_ = localFaceData.isOutsideFace();
125 stencil_ = &iv.stencil();
126 setHandlePointer_(dataHandle.heatConductionHandle());
127 }
128
130 const Stencil& heatConductionStencil() const { return *stencil_; }
131
133 const PrimaryDataHandle& heatConductionPrimaryDataHandle() const { return *primaryHandlePtr_; }
134 const SecondaryDataHandle& heatConductionSecondaryDataHandle() const { return *secondaryHandlePtr_; }
135
137 bool heatConductionSwitchFluxSign() const { return switchFluxSign_; }
138
139 private:
140 bool switchFluxSign_;
141
143 const PrimaryDataHandle* primaryHandlePtr_;
144 const SecondaryDataHandle* secondaryHandlePtr_;
145
147 const Stencil* stencil_;
148 };
149
150public:
152 // state the discretization method this implementation belongs to
153 static constexpr DiscretizationMethod discMethod{};
154
155 // state the type for the corresponding cache and its filler
156 using Cache = MpfaFouriersLawCache;
157
165 static Scalar flux(const Problem& problem,
166 const Element& element,
167 const FVElementGeometry& fvGeometry,
168 const ElementVolumeVariables& elemVolVars,
169 const SubControlVolumeFace& scvf,
170 const ElementFluxVarsCache& elemFluxVarsCache)
171 {
172 const auto& fluxVarsCache = elemFluxVarsCache[scvf];
173
174 // forward to the private function taking the iv data handle
175 if (fluxVarsCache.usesSecondaryIv())
176 return flux_(problem, fluxVarsCache, fluxVarsCache.heatConductionSecondaryDataHandle());
177 else
178 return flux_(problem, fluxVarsCache, fluxVarsCache.heatConductionPrimaryDataHandle());
179 }
180
181private:
182 template< class Problem, class FluxVarsCache, class DataHandle >
183 static Scalar flux_(const Problem& problem,
184 const FluxVarsCache& cache,
185 const DataHandle& dataHandle)
186 {
187 const bool switchSign = cache.heatConductionSwitchFluxSign();
188
189 const auto localFaceIdx = cache.ivLocalFaceIndex();
190 const auto idxInOutside = cache.indexInOutsideFaces();
191 const auto& Tj = dataHandle.uj();
192 const auto& tij = dim == dimWorld ? dataHandle.T()[localFaceIdx]
193 : (!switchSign ? dataHandle.T()[localFaceIdx]
194 : dataHandle.tijOutside()[localFaceIdx][idxInOutside]);
195 Scalar scvfFlux = tij*Tj;
196
197 // switch the sign if necessary
198 if (switchSign)
199 scvfFlux *= -1.0;
200
201 return scvfFlux;
202 }
203};
204
205} // end namespace Dumux
206
207#endif
The available discretization methods in Dumux.
Definition: adapt.hh:29
typename Properties::Detail::GetPropImpl< TypeTag, Property >::type::type GetPropType
get the type alias defined in the property
Definition: propertysystem.hh:150
Definition: method.hh:61
forward declaration of the method-specific implementation
Definition: flux/box/fourierslaw.hh:38
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/ccmpfa/fourierslaw.hh:165
MpfaFouriersLawCache Cache
Definition: flux/ccmpfa/fourierslaw.hh:156
Declares all properties used in Dumux.