version 3.10-dev
gridfacevariables.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_STAGGERED_GRID_FACEVARIABLES_HH
13#define DUMUX_DISCRETIZATION_STAGGERED_GRID_FACEVARIABLES_HH
14
15// make the local view function available whenever we use this class
19
20namespace Dumux {
21
29template<class P, class FV>
31{
32 template<class GridFaceVariables, bool enableCache>
34
35 using FaceVariables = FV;
36 using Problem = P;
37};
38
43template<class Problem,
44 class FaceVariables,
45 bool cachingEnabled = false,
48
54template<class P, class FV, class Traits>
55class StaggeredGridFaceVariables<P, FV, /*cachingEnabled*/true, Traits>
56{
57 using ThisType = StaggeredGridFaceVariables<P, FV, /*cachingEnabled*/true, Traits>;
58 using Problem = typename Traits::Problem;
59
60public:
62 static constexpr bool cachingEnabled = true;
63
65 using LocalView = typename Traits::template LocalView<ThisType, cachingEnabled>;
66
68 using FaceVariables = typename Traits::FaceVariables;
69
70 StaggeredGridFaceVariables(const Problem& problem) : problemPtr_(&problem) {}
71
73 template<class GridGeometry, class SolutionVector>
74 void update(const GridGeometry& gridGeometry, const SolutionVector& sol)
75 {
76 faceVariables_.resize(gridGeometry.numScvf());
77 auto fvGeometry = localView(gridGeometry);
78 for (auto&& element : elements(gridGeometry.gridView()))
79 {
80 fvGeometry.bindElement(element);
81
82 for (auto&& scvf : scvfs(fvGeometry))
83 {
84 const auto faceSol = StaggeredFaceSolution(scvf, sol, gridGeometry);
85 faceVariables_[scvf.index()].update(faceSol, problem(), element, fvGeometry, scvf);
86 }
87 }
88 }
89
90 const FaceVariables& faceVars(const std::size_t facetIdx) const
91 { return faceVariables_[facetIdx]; }
92
93 FaceVariables& faceVars(const std::size_t facetIdx)
94 { return faceVariables_[facetIdx]; }
95
96 const Problem& problem() const
97 { return *problemPtr_; }
98
99private:
100 const Problem* problemPtr_;
101 std::vector<FaceVariables> faceVariables_;
102};
103
109template<class P, class FV, class Traits>
110class StaggeredGridFaceVariables<P, FV, /*cachingEnabled*/false, Traits>
111{
112 using ThisType = StaggeredGridFaceVariables<P, FV, /*cachingEnabled*/false, Traits>;
113 using Problem = typename Traits::Problem;
114
115public:
117 static constexpr bool cachingEnabled = false;
118
120 using LocalView = typename Traits::template LocalView<ThisType, cachingEnabled>;
121
123 using FaceVariables = typename Traits::FaceVariables;
124
125 StaggeredGridFaceVariables(const Problem& problem) : problemPtr_(&problem) {}
126
128 template<class GridGeometry, class SolutionVector>
129 void update(const GridGeometry& gridGeometry, const SolutionVector& sol) {}
130
131 const Problem& problem() const
132 { return *problemPtr_; }
133
134private:
135 const Problem* problemPtr_;
136};
137
138} // end namespace Dumux
139
140#endif
Base class for the face variables vector.
Definition: elementfacevariables.hh:28
The global face variables class for staggered models.
Definition: facesolution.hh:28
Face variables cache class for staggered models. Specialization in case of not storing the face varia...
Definition: gridfacevariables.hh:111
StaggeredGridFaceVariables(const Problem &problem)
Definition: gridfacevariables.hh:125
const Problem & problem() const
Definition: gridfacevariables.hh:131
typename Traits::FaceVariables FaceVariables
export the type of the face variables
Definition: gridfacevariables.hh:123
typename Traits::template LocalView< ThisType, cachingEnabled > LocalView
export the type of the local view
Definition: gridfacevariables.hh:120
void update(const GridGeometry &gridGeometry, const SolutionVector &sol)
Do nothing here.
Definition: gridfacevariables.hh:129
Face variables cache class for staggered models. Specialization in case of storing the face variables...
Definition: gridfacevariables.hh:56
typename Traits::template LocalView< ThisType, cachingEnabled > LocalView
export the type of the local view
Definition: gridfacevariables.hh:65
void update(const GridGeometry &gridGeometry, const SolutionVector &sol)
Update all face variables.
Definition: gridfacevariables.hh:74
typename Traits::FaceVariables FaceVariables
export the type of the face variables
Definition: gridfacevariables.hh:68
StaggeredGridFaceVariables(const Problem &problem)
Definition: gridfacevariables.hh:70
const Problem & problem() const
Definition: gridfacevariables.hh:96
FaceVariables & faceVars(const std::size_t facetIdx)
Definition: gridfacevariables.hh:93
const FaceVariables & faceVars(const std::size_t facetIdx) const
Definition: gridfacevariables.hh:90
Face variables cache class for staggered models.
Definition: gridfacevariables.hh:47
GridCache::LocalView localView(const GridCache &gridCache)
Free function to get the local view of a grid cache object.
Definition: localview.hh:26
Free function to get the local view of a grid cache object.
Definition: adapt.hh:17
Traits class to be used for the StaggeredGridFaceVariables.
Definition: gridfacevariables.hh:31
P Problem
Definition: gridfacevariables.hh:36
FV FaceVariables
Definition: gridfacevariables.hh:35