version 3.8
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// SPDX-FileCopyrightInfo: Copyright © DuMux Project contributors, see AUTHORS.md in root folder
5// SPDX-License-Identifier: GPL-3.0-or-later
6//
12#ifndef DUMUX_DISCRETIZATION_CC_MPFA_FOURIERS_LAW_HH
13#define DUMUX_DISCRETIZATION_CC_MPFA_FOURIERS_LAW_HH
14
15#include <dune/common/dynvector.hh>
16#include <dune/common/dynmatrix.hh>
17
20
21namespace Dumux {
22
24template<class TypeTag, class DiscretizationMethod>
25class FouriersLawImplementation;
26
31template <class TypeTag>
32class FouriersLawImplementation<TypeTag, DiscretizationMethods::CCMpfa>
33{
37 using Element = typename GridView::template Codim<0>::Entity;
38
39 static constexpr int dim = GridView::dimension;
40 static constexpr int dimWorld = GridView::dimensionworld;
41
43 using FVElementGeometry = typename GridGeometry::LocalView;
44 using SubControlVolumeFace = typename FVElementGeometry::SubControlVolumeFace;
45 using ElementVolumeVariables = typename GetPropType<TypeTag, Properties::GridVolumeVariables>::LocalView;
47 using ElementFluxVarsCache = typename GridFluxVariablesCache::LocalView;
48 using FluxVariablesCache = typename GridFluxVariablesCache::FluxVariablesCache;
49
51 class MpfaFouriersLawCacheFiller
52 {
53 public:
56 template<class FluxVariablesCacheFiller>
57 static void fill(FluxVariablesCache& scvfFluxVarsCache,
58 const Problem& problem,
59 const Element& element,
60 const FVElementGeometry& fvGeometry,
61 const ElementVolumeVariables& elemVolVars,
62 const SubControlVolumeFace& scvf,
63 const FluxVariablesCacheFiller& fluxVarsCacheFiller)
64 {
65 // get interaction volume from the flux vars cache filler & update the cache
66 if (fvGeometry.gridGeometry().vertexUsesSecondaryInteractionVolume(scvf.vertexIndex()))
67 scvfFluxVarsCache.updateHeatConduction(fluxVarsCacheFiller.secondaryInteractionVolume(),
68 fluxVarsCacheFiller.secondaryIvLocalFaceData(),
69 fluxVarsCacheFiller.secondaryIvDataHandle());
70 else
71 scvfFluxVarsCache.updateHeatConduction(fluxVarsCacheFiller.primaryInteractionVolume(),
72 fluxVarsCacheFiller.primaryIvLocalFaceData(),
73 fluxVarsCacheFiller.primaryIvDataHandle());
74 }
75 };
76
78 class MpfaFouriersLawCache
79 {
81 using Stencil = typename DualGridNodalIndexSet::NodalGridStencilType;
82
83 static constexpr bool considerSecondaryIVs = GridGeometry::MpfaHelper::considerSecondaryIVs();
84 using PrimaryDataHandle = typename ElementFluxVarsCache::PrimaryIvDataHandle::HeatConductionHandle;
85 using SecondaryDataHandle = typename ElementFluxVarsCache::SecondaryIvDataHandle::HeatConductionHandle;
86
88 template< bool doSecondary = considerSecondaryIVs, std::enable_if_t<doSecondary, int> = 0 >
89 void setHandlePointer_(const SecondaryDataHandle& dataHandle)
90 { secondaryHandlePtr_ = &dataHandle; }
91
93 void setHandlePointer_(const PrimaryDataHandle& dataHandle)
94 { primaryHandlePtr_ = &dataHandle; }
95
96 public:
97 // export filler type
98 using Filler = MpfaFouriersLawCacheFiller;
99
108 template<class IV, class LocalFaceData, class DataHandle>
109 void updateHeatConduction(const IV& iv,
110 const LocalFaceData& localFaceData,
111 const DataHandle& dataHandle)
112 {
113 switchFluxSign_ = localFaceData.isOutsideFace();
114 stencil_ = &iv.stencil();
115 setHandlePointer_(dataHandle.heatConductionHandle());
116 }
117
119 const Stencil& heatConductionStencil() const { return *stencil_; }
120
122 const PrimaryDataHandle& heatConductionPrimaryDataHandle() const { return *primaryHandlePtr_; }
123 const SecondaryDataHandle& heatConductionSecondaryDataHandle() const { return *secondaryHandlePtr_; }
124
126 bool heatConductionSwitchFluxSign() const { return switchFluxSign_; }
127
128 private:
129 bool switchFluxSign_;
130
132 const PrimaryDataHandle* primaryHandlePtr_;
133 const SecondaryDataHandle* secondaryHandlePtr_;
134
136 const Stencil* stencil_;
137 };
138
139public:
141 // state the discretization method this implementation belongs to
142 static constexpr DiscretizationMethod discMethod{};
143
144 // state the type for the corresponding cache and its filler
145 using Cache = MpfaFouriersLawCache;
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 const auto& fluxVarsCache = elemFluxVarsCache[scvf];
162
163 // forward to the private function taking the iv data handle
164 if (fluxVarsCache.usesSecondaryIv())
165 return flux_(problem, fluxVarsCache, fluxVarsCache.heatConductionSecondaryDataHandle());
166 else
167 return flux_(problem, fluxVarsCache, fluxVarsCache.heatConductionPrimaryDataHandle());
168 }
169
170private:
171 template< class Problem, class FluxVarsCache, class DataHandle >
172 static Scalar flux_(const Problem& problem,
173 const FluxVarsCache& cache,
174 const DataHandle& dataHandle)
175 {
176 const bool switchSign = cache.heatConductionSwitchFluxSign();
177
178 const auto localFaceIdx = cache.ivLocalFaceIndex();
179 const auto idxInOutside = cache.indexInOutsideFaces();
180 const auto& Tj = dataHandle.uj();
181 const auto& tij = dim == dimWorld ? dataHandle.T()[localFaceIdx]
182 : (!switchSign ? dataHandle.T()[localFaceIdx]
183 : dataHandle.tijOutside()[localFaceIdx][idxInOutside]);
184 Scalar scvfFlux = tij*Tj;
185
186 // switch the sign if necessary
187 if (switchSign)
188 scvfFlux *= -1.0;
189
190 return scvfFlux;
191 }
192};
193
194} // end namespace Dumux
195
196#endif
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:154
MpfaFouriersLawCache Cache
Definition: flux/ccmpfa/fourierslaw.hh:145
forward declaration of the method-specific implementation
Definition: flux/box/fourierslaw.hh:26
Defines all properties used in Dumux.
typename GetProp< TypeTag, Property >::type GetPropType
get the type alias defined in the property
Definition: propertysystem.hh:296
The available discretization methods in Dumux.
Definition: adapt.hh:17
Definition: method.hh:33