version 3.10-dev
cellcentered/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_CC_GRID_VOLUMEVARIABLES_HH
13#define DUMUX_DISCRETIZATION_CC_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
23
24namespace Dumux {
25
33template<class Traits, bool cachingEnabled = false>
35
37template<class Traits>
38class CCGridVolumeVariables<Traits, /*cachingEnabled*/true>
39{
41
42public:
44 using Problem = typename Traits::Problem;
45
47 using VolumeVariables = typename Traits::VolumeVariables;
48
50 static constexpr bool cachingEnabled = true;
51
53 using LocalView = typename Traits::template LocalView<ThisType, cachingEnabled>;
54
55 CCGridVolumeVariables(const Problem& problem) : problemPtr_(&problem) {}
56
57 template<class GridGeometry, class SolutionVector>
58 void update(const GridGeometry& gridGeometry, const SolutionVector& sol)
59 {
60 volumeVariables_.resize(gridGeometry.numScv());
61 Dumux::parallelFor(gridGeometry.gridView().size(0), [&, &problem = problem()](const std::size_t eIdx)
62 {
63 const auto element = gridGeometry.element(eIdx);
64 const auto fvGeometry = localView(gridGeometry).bindElement(element);
65 for (const auto& scv : scvs(fvGeometry))
66 {
67 const auto elemSol = elementSolution(element, sol, gridGeometry);
68 volumeVariables_[scv.dofIndex()].update(elemSol, problem, element, scv);
69 }
70 });
71 }
72
73 const VolumeVariables& volVars(const std::size_t scvIdx) const
74 { return volumeVariables_[scvIdx]; }
75
76 VolumeVariables& volVars(const std::size_t scvIdx)
77 { return volumeVariables_[scvIdx]; }
78
79 template<class SubControlVolume, typename std::enable_if_t<!std::is_integral<SubControlVolume>::value, int> = 0>
80 const VolumeVariables& volVars(const SubControlVolume& scv) const
81 { return volumeVariables_[scv.dofIndex()]; }
82
83 template<class SubControlVolume, typename std::enable_if_t<!std::is_integral<SubControlVolume>::value, int> = 0>
84 VolumeVariables& volVars(const SubControlVolume& scv)
85 { return volumeVariables_[scv.dofIndex()]; }
86
87 // required for compatibility with the box method
88 const VolumeVariables& volVars(const std::size_t scvIdx, const std::size_t localIdx) const
89 { return volumeVariables_[scvIdx]; }
90
91 // required for compatibility with the box method
92 VolumeVariables& volVars(const std::size_t scvIdx, const std::size_t localIdx)
93 { return volumeVariables_[scvIdx]; }
94
96 const Problem& problem() const
97 { return *problemPtr_; }
98
99private:
100 const Problem* problemPtr_;
101 std::vector<VolumeVariables> volumeVariables_;
102};
103
104
106template<class Traits>
107class CCGridVolumeVariables<Traits, /*cachingEnabled*/false>
108{
110
111public:
113 using Problem = typename Traits::Problem;
114
116 using VolumeVariables = typename Traits::VolumeVariables;
117
119 static constexpr bool cachingEnabled = false;
120
122 using LocalView = typename Traits::template LocalView<ThisType, cachingEnabled>;
123
124 CCGridVolumeVariables(const Problem& problem) : problemPtr_(&problem) {}
125
126 template<class GridGeometry, class SolutionVector>
127 void update(const GridGeometry& gridGeometry, const SolutionVector& sol) {}
128
130 const Problem& problem() const
131 { return *problemPtr_;}
132
133private:
134 const Problem* problemPtr_;
135};
136
137} // end namespace Dumux
138
139#endif
The local element solution class for cell-centered methods.
Specialization when the current volume variables are not stored globally.
Definition: cellcentered/gridvolumevariables.hh:108
typename Traits::VolumeVariables VolumeVariables
export the volume variables type
Definition: cellcentered/gridvolumevariables.hh:116
CCGridVolumeVariables(const Problem &problem)
Definition: cellcentered/gridvolumevariables.hh:124
typename Traits::Problem Problem
export the problem type
Definition: cellcentered/gridvolumevariables.hh:113
const Problem & problem() const
The problem we are solving.
Definition: cellcentered/gridvolumevariables.hh:130
void update(const GridGeometry &gridGeometry, const SolutionVector &sol)
Definition: cellcentered/gridvolumevariables.hh:127
typename Traits::template LocalView< ThisType, cachingEnabled > LocalView
export the type of the local view
Definition: cellcentered/gridvolumevariables.hh:122
specialization in case of storing the volume variables
Definition: cellcentered/gridvolumevariables.hh:39
void update(const GridGeometry &gridGeometry, const SolutionVector &sol)
Definition: cellcentered/gridvolumevariables.hh:58
VolumeVariables & volVars(const std::size_t scvIdx)
Definition: cellcentered/gridvolumevariables.hh:76
typename Traits::template LocalView< ThisType, cachingEnabled > LocalView
export the type of the local view
Definition: cellcentered/gridvolumevariables.hh:53
VolumeVariables & volVars(const SubControlVolume &scv)
Definition: cellcentered/gridvolumevariables.hh:84
const Problem & problem() const
The problem we are solving.
Definition: cellcentered/gridvolumevariables.hh:96
const VolumeVariables & volVars(const std::size_t scvIdx, const std::size_t localIdx) const
Definition: cellcentered/gridvolumevariables.hh:88
const VolumeVariables & volVars(const std::size_t scvIdx) const
Definition: cellcentered/gridvolumevariables.hh:73
typename Traits::Problem Problem
export the problem type
Definition: cellcentered/gridvolumevariables.hh:44
const VolumeVariables & volVars(const SubControlVolume &scv) const
Definition: cellcentered/gridvolumevariables.hh:80
typename Traits::VolumeVariables VolumeVariables
export the volume variables type
Definition: cellcentered/gridvolumevariables.hh:47
CCGridVolumeVariables(const Problem &problem)
Definition: cellcentered/gridvolumevariables.hh:55
VolumeVariables & volVars(const std::size_t scvIdx, const std::size_t localIdx)
Definition: cellcentered/gridvolumevariables.hh:92
Base class for the grid volume variables.
Definition: cellcentered/gridvolumevariables.hh:34
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)