version 3.8
facecentered/staggered/gridvolumevariables.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_FACECENTERED_GRID_VOLUMEVARIABLES_HH
13#define DUMUX_DISCRETIZATION_FACECENTERED_GRID_VOLUMEVARIABLES_HH
14
15#include <vector>
16#include <type_traits>
17
19
20// make the local view function available whenever we use this class
24
25namespace Dumux {
26
27template<class P, class VV>
29{
30 using Problem = P;
31 using VolumeVariables = VV;
32
33 template<class GridVolumeVariables, bool cachingEnabled>
35};
36
44template<class Traits, bool cachingEnabled = false>
46
48template<class Traits>
49class FaceCenteredStaggeredGridVolumeVariables<Traits, /*cachingEnabled*/true>
50{
52
53public:
55 using Problem = typename Traits::Problem;
56
58 using VolumeVariables = typename Traits::VolumeVariables;
59
61 static constexpr bool cachingEnabled = true;
62
64 using LocalView = typename Traits::template LocalView<ThisType, cachingEnabled>;
65
66 FaceCenteredStaggeredGridVolumeVariables(const Problem& problem) : problemPtr_(&problem) {}
67
68 template<class GridGeometry, class SolutionVector>
69 void update(const GridGeometry& gridGeometry, const SolutionVector& sol)
70 {
71 volumeVariables_.resize(gridGeometry.numScv());
72 Dumux::parallelFor(gridGeometry.gridView().size(0), [&, &problem = problem()](const std::size_t eIdx)
73 {
74 const auto element = gridGeometry.element(eIdx);
75 const auto fvGeometry = localView(gridGeometry).bindElement(element);
76 const auto elemSol = elementSolution(element, sol, gridGeometry);
77
78 for (const auto& scv : scvs(fvGeometry))
79 volumeVariables_[scv.index()].update(elemSol, problem, element, scv);
80 });
81 }
82
83 const VolumeVariables& volVars(const std::size_t scvIdx) const
84 { return volumeVariables_[scvIdx]; }
85
86 VolumeVariables& volVars(const std::size_t scvIdx)
87 { return volumeVariables_[scvIdx]; }
88
89 template<class SubControlVolume, typename std::enable_if_t<!std::is_integral<SubControlVolume>::value, int> = 0>
90 const VolumeVariables& volVars(const SubControlVolume scv) const
91 { return volumeVariables_[scv.index()]; }
92
93 template<class SubControlVolume, typename std::enable_if_t<!std::is_integral<SubControlVolume>::value, int> = 0>
94 VolumeVariables& volVars(const SubControlVolume scv)
95 { return volumeVariables_[scv.index()]; }
96
97 // required for compatibility with the box method
98 const VolumeVariables& volVars(const std::size_t scvIdx, const std::size_t localIdx) const
99 { return volumeVariables_[scvIdx]; }
100
101 // required for compatibility with the box method
102 VolumeVariables& volVars(const std::size_t scvIdx, const std::size_t localIdx)
103 { return volumeVariables_[scvIdx]; }
104
106 const Problem& problem() const
107 { return *problemPtr_; }
108
109private:
110 const Problem* problemPtr_;
111 std::vector<VolumeVariables> volumeVariables_;
112};
113
114
116template<class Traits>
117class FaceCenteredStaggeredGridVolumeVariables<Traits, /*cachingEnabled*/false>
118{
120
121public:
123 using Problem = typename Traits::Problem;
124
126 using VolumeVariables = typename Traits::VolumeVariables;
127
129 static constexpr bool cachingEnabled = false;
130
132 using LocalView = typename Traits::template LocalView<ThisType, cachingEnabled>;
133
134 FaceCenteredStaggeredGridVolumeVariables(const Problem& problem) : problemPtr_(&problem) {}
135
136 template<class GridGeometry, class SolutionVector>
137 void update(const GridGeometry& gridGeometry, const SolutionVector& sol) {}
138
140 const Problem& problem() const
141 { return *problemPtr_;}
142
143private:
144 const Problem* problemPtr_;
145};
146
147} // end namespace Dumux
148
149#endif
Base class for the face variables vector.
Definition: facecentered/staggered/elementvolumevariables.hh:29
Specialization when the current volume variables are not stored globally.
Definition: facecentered/staggered/gridvolumevariables.hh:118
FaceCenteredStaggeredGridVolumeVariables(const Problem &problem)
Definition: facecentered/staggered/gridvolumevariables.hh:134
typename Traits::VolumeVariables VolumeVariables
export the volume variables type
Definition: facecentered/staggered/gridvolumevariables.hh:126
typename Traits::template LocalView< ThisType, cachingEnabled > LocalView
export the type of the local view
Definition: facecentered/staggered/gridvolumevariables.hh:132
typename Traits::Problem Problem
export the problem type
Definition: facecentered/staggered/gridvolumevariables.hh:123
void update(const GridGeometry &gridGeometry, const SolutionVector &sol)
Definition: facecentered/staggered/gridvolumevariables.hh:137
const Problem & problem() const
The problem we are solving.
Definition: facecentered/staggered/gridvolumevariables.hh:140
specialization in case of storing the volume variables
Definition: facecentered/staggered/gridvolumevariables.hh:50
void update(const GridGeometry &gridGeometry, const SolutionVector &sol)
Definition: facecentered/staggered/gridvolumevariables.hh:69
FaceCenteredStaggeredGridVolumeVariables(const Problem &problem)
Definition: facecentered/staggered/gridvolumevariables.hh:66
VolumeVariables & volVars(const std::size_t scvIdx, const std::size_t localIdx)
Definition: facecentered/staggered/gridvolumevariables.hh:102
const VolumeVariables & volVars(const std::size_t scvIdx) const
Definition: facecentered/staggered/gridvolumevariables.hh:83
typename Traits::Problem Problem
export the problem type
Definition: facecentered/staggered/gridvolumevariables.hh:55
const VolumeVariables & volVars(const SubControlVolume scv) const
Definition: facecentered/staggered/gridvolumevariables.hh:90
typename Traits::VolumeVariables VolumeVariables
export the volume variables type
Definition: facecentered/staggered/gridvolumevariables.hh:58
VolumeVariables & volVars(const SubControlVolume scv)
Definition: facecentered/staggered/gridvolumevariables.hh:94
VolumeVariables & volVars(const std::size_t scvIdx)
Definition: facecentered/staggered/gridvolumevariables.hh:86
typename Traits::template LocalView< ThisType, cachingEnabled > LocalView
export the type of the local view
Definition: facecentered/staggered/gridvolumevariables.hh:64
const Problem & problem() const
The problem we are solving.
Definition: facecentered/staggered/gridvolumevariables.hh:106
const VolumeVariables & volVars(const std::size_t scvIdx, const std::size_t localIdx) const
Definition: facecentered/staggered/gridvolumevariables.hh:98
Base class for the grid volume variables.
Definition: facecentered/staggered/gridvolumevariables.hh:45
GridCache::LocalView localView(const GridCache &gridCache)
Free function to get the local view of a grid cache object.
Definition: localview.hh:26
auto elementSolution(const Element &element, const SolutionVector &sol, const GridGeometry &gg) -> std::enable_if_t< GridGeometry::discMethod==DiscretizationMethods::cctpfa||GridGeometry::discMethod==DiscretizationMethods::ccmpfa, CCElementSolution< typename GridGeometry::LocalView, std::decay_t< decltype(std::declval< SolutionVector >()[0])> > >
Make an element solution for cell-centered schemes.
Definition: cellcentered/elementsolution.hh:101
void parallelFor(const std::size_t count, const FunctorType &functor)
A parallel for loop (multithreading)
Definition: parallel_for.hh:160
Free function to get the local view of a grid cache object.
Definition: adapt.hh:17
Parallel for loop (multithreading)
Definition: facecentered/staggered/gridvolumevariables.hh:29
P Problem
Definition: facecentered/staggered/gridvolumevariables.hh:30
VV VolumeVariables
Definition: facecentered/staggered/gridvolumevariables.hh:31