version 3.8
porenetwork/2p/elementfluxvariablescache.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_PNM_2P_ELEMNT_FLUXVARSCACHE_HH
13#define DUMUX_PNM_2P_ELEMNT_FLUXVARSCACHE_HH
14
15#include <cstddef>
16#include <vector>
17#include <utility>
18
20
21namespace Dumux::PoreNetwork {
22
27template<class GFVC, bool cachingEnabled>
29
34template<class GFVC>
36{
38public:
39 using ParentType::ParentType;
40};
41
46template<class GFVC>
48{
49public:
52
54 using FluxVariablesCache = typename GFVC::FluxVariablesCache;
55
57 : gridFluxVarsCachePtr_(&global) {}
58
59 // Function is called by the BoxLocalJacobian prior to flux calculations on the element.
60 // We assume the FVGeometries to be bound at this point
61 template<class FVElementGeometry, class ElementVolumeVariables>
62 void bind(const typename FVElementGeometry::GridGeometry::GridView::template Codim<0>::Entity& element,
63 const FVElementGeometry& fvGeometry,
64 const ElementVolumeVariables& elemVolVars) &
65 { bindElement(element, fvGeometry, elemVolVars); }
66
72 template<class FVElementGeometry, class ElementVolumeVariables>
73 PNMTwoPElementFluxVariablesCache bind(const typename FVElementGeometry::GridGeometry::GridView::template Codim<0>::Entity& element,
74 const FVElementGeometry& fvGeometry,
75 const ElementVolumeVariables& elemVolVars) &&
76 {
77 this->bind(element, fvGeometry, elemVolVars);
78 return std::move(*this);
79 }
80
81 template<class FVElementGeometry, class ElementVolumeVariables>
82 void bindElement(const typename FVElementGeometry::GridGeometry::GridView::template Codim<0>::Entity& element,
83 const FVElementGeometry& fvGeometry,
84 const ElementVolumeVariables& elemVolVars) &
85 {
86 for (auto&& scvf : scvfs(fvGeometry))
87 fluxVarsCache_.update(gridFluxVarsCache().problem(), element, fvGeometry, elemVolVars, scvf, gridFluxVarsCache().invasionState().invaded(element));
88 }
89
95 template<class FVElementGeometry, class ElementVolumeVariables>
96 PNMTwoPElementFluxVariablesCache bindElement(const typename FVElementGeometry::GridGeometry::GridView::template Codim<0>::Entity& element,
97 const FVElementGeometry& fvGeometry,
98 const ElementVolumeVariables& elemVolVars) &&
99 {
100 this->bindElement(element, fvGeometry, elemVolVars);
101 return std::move(*this);
102 }
103
104 template<class FVElementGeometry, class ElementVolumeVariables>
105 void bindScvf(const typename FVElementGeometry::GridGeometry::GridView::template Codim<0>::Entity& element,
106 const FVElementGeometry& fvGeometry,
107 const ElementVolumeVariables& elemVolVars,
108 const typename FVElementGeometry::SubControlVolumeFace& scvf) &
109 {
110 fluxVarsCache_.update(gridFluxVarsCache().problem(), element, fvGeometry, elemVolVars, scvf, gridFluxVarsCache().invasionState().invaded(element));
111 }
112
118 template<class FVElementGeometry, class ElementVolumeVariables>
119 PNMTwoPElementFluxVariablesCache bindScvf(const typename FVElementGeometry::GridGeometry::GridView::template Codim<0>::Entity& element,
120 const FVElementGeometry& fvGeometry,
121 const ElementVolumeVariables& elemVolVars,
122 const typename FVElementGeometry::SubControlVolumeFace& scvf) &&
123 {
124 this->bindScvf(element, fvGeometry, elemVolVars, scvf);
125 return std::move(*this);
126 }
127
132 template<class FVElementGeometry, class ElementVolumeVariables>
133 void update(const typename FVElementGeometry::Element& element,
134 const FVElementGeometry& fvGeometry,
135 const ElementVolumeVariables& elemVolVars)
136 {
137 if constexpr (FluxVariablesCache::isSolDependent)
138 {
139 for (const auto& scvf : scvfs(fvGeometry))
140 fluxVarsCache_.update(
141 gridFluxVarsCache().problem(), element, fvGeometry, elemVolVars, scvf,
142 gridFluxVarsCache().invasionState().invaded(element)
143 );
144 }
145 }
146
148 template<class SubControlVolumeFace>
149 const FluxVariablesCache& operator [](const SubControlVolumeFace& scvf) const
150 { return fluxVarsCache_; }
151
153 template<class SubControlVolumeFace>
154 FluxVariablesCache& operator [](const SubControlVolumeFace& scvf)
155 { return fluxVarsCache_; }
156
159 { return *gridFluxVarsCachePtr_; }
160
161private:
162 const GridFluxVariablesCache* gridFluxVarsCachePtr_;
163 FluxVariablesCache fluxVarsCache_;
164};
165
166} // end namespace Dumux::PoreNetwork
167
168#endif
The flux variables caches for an element with caching enabled.
Definition: discretization/cvfe/elementfluxvariablescache.hh:39
The flux variables caches for an element.
Definition: discretization/cvfe/elementfluxvariablescache.hh:31
void bindElement(const typename FVElementGeometry::GridGeometry::GridView::template Codim< 0 >::Entity &element, const FVElementGeometry &fvGeometry, const ElementVolumeVariables &elemVolVars) &
Definition: porenetwork/2p/elementfluxvariablescache.hh:82
typename GFVC::FluxVariablesCache FluxVariablesCache
export the type of the flux variables cache
Definition: porenetwork/2p/elementfluxvariablescache.hh:54
PNMTwoPElementFluxVariablesCache bind(const typename FVElementGeometry::GridGeometry::GridView::template Codim< 0 >::Entity &element, const FVElementGeometry &fvGeometry, const ElementVolumeVariables &elemVolVars) &&
bind the local view (r-value overload) This overload is called when an instance of this class is a te...
Definition: porenetwork/2p/elementfluxvariablescache.hh:73
GFVC GridFluxVariablesCache
export the type of the grid flux variables cache
Definition: porenetwork/2p/elementfluxvariablescache.hh:51
void update(const typename FVElementGeometry::Element &element, const FVElementGeometry &fvGeometry, const ElementVolumeVariables &elemVolVars)
Update the caches if the volume variables have changed and the cache is solution-dependent.
Definition: porenetwork/2p/elementfluxvariablescache.hh:133
void bindScvf(const typename FVElementGeometry::GridGeometry::GridView::template Codim< 0 >::Entity &element, const FVElementGeometry &fvGeometry, const ElementVolumeVariables &elemVolVars, const typename FVElementGeometry::SubControlVolumeFace &scvf) &
Definition: porenetwork/2p/elementfluxvariablescache.hh:105
PNMTwoPElementFluxVariablesCache bindScvf(const typename FVElementGeometry::GridGeometry::GridView::template Codim< 0 >::Entity &element, const FVElementGeometry &fvGeometry, const ElementVolumeVariables &elemVolVars, const typename FVElementGeometry::SubControlVolumeFace &scvf) &&
bind the local view (r-value overload) This overload is called when an instance of this class is a te...
Definition: porenetwork/2p/elementfluxvariablescache.hh:119
PNMTwoPElementFluxVariablesCache(const GridFluxVariablesCache &global)
Definition: porenetwork/2p/elementfluxvariablescache.hh:56
PNMTwoPElementFluxVariablesCache bindElement(const typename FVElementGeometry::GridGeometry::GridView::template Codim< 0 >::Entity &element, const FVElementGeometry &fvGeometry, const ElementVolumeVariables &elemVolVars) &&
bind the local view (r-value overload) This overload is called when an instance of this class is a te...
Definition: porenetwork/2p/elementfluxvariablescache.hh:96
void bind(const typename FVElementGeometry::GridGeometry::GridView::template Codim< 0 >::Entity &element, const FVElementGeometry &fvGeometry, const ElementVolumeVariables &elemVolVars) &
Definition: porenetwork/2p/elementfluxvariablescache.hh:62
const GridFluxVariablesCache & gridFluxVarsCache() const
The global object we are a restriction of.
Definition: porenetwork/2p/elementfluxvariablescache.hh:158
The flux variables caches for an element.
Definition: porenetwork/2p/elementfluxvariablescache.hh:28
Global flux variable cache.
Definition: discretization/porenetwork/fvelementgeometry.hh:24