3.3.0
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, DiscretizationMethod discMethod>
37class FouriersLawImplementation;
38
43template <class TypeTag>
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:
151 // state the discretization method this implementation belongs to
153
154 // state the type for the corresponding cache and its filler
155 using Cache = MpfaFouriersLawCache;
156
164 static Scalar flux(const Problem& problem,
165 const Element& element,
166 const FVElementGeometry& fvGeometry,
167 const ElementVolumeVariables& elemVolVars,
168 const SubControlVolumeFace& scvf,
169 const ElementFluxVarsCache& elemFluxVarsCache)
170 {
171 const auto& fluxVarsCache = elemFluxVarsCache[scvf];
172
173 // forward to the private function taking the iv data handle
174 if (fluxVarsCache.usesSecondaryIv())
175 return flux_(problem, fluxVarsCache, fluxVarsCache.heatConductionSecondaryDataHandle());
176 else
177 return flux_(problem, fluxVarsCache, fluxVarsCache.heatConductionPrimaryDataHandle());
178 }
179
180private:
181 template< class Problem, class FluxVarsCache, class DataHandle >
182 static Scalar flux_(const Problem& problem,
183 const FluxVarsCache& cache,
184 const DataHandle& dataHandle)
185 {
186 const bool switchSign = cache.heatConductionSwitchFluxSign();
187
188 const auto localFaceIdx = cache.ivLocalFaceIndex();
189 const auto idxInOutside = cache.indexInOutsideFaces();
190 const auto& Tj = dataHandle.uj();
191 const auto& tij = dim == dimWorld ? dataHandle.T()[localFaceIdx]
192 : (!switchSign ? dataHandle.T()[localFaceIdx]
193 : dataHandle.tijOutside()[localFaceIdx][idxInOutside]);
194 Scalar scvfFlux = tij*Tj;
195
196 // switch the sign if necessary
197 if (switchSign)
198 scvfFlux *= -1.0;
199
200 return scvfFlux;
201 }
202};
203
204} // end namespace Dumux
205
206#endif
The available discretization methods in Dumux.
DiscretizationMethod
The available discretization methods in Dumux.
Definition: method.hh:37
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
forward declaration of the method-specific implementation
Definition: flux/fourierslaw.hh:37
MpfaFouriersLawCache Cache
Definition: flux/ccmpfa/fourierslaw.hh:155
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:164
Declares all properties used in Dumux.