3.5-git
DUNE for Multi-{Phase, Component, Scale, Physics, ...} flow and transport in porous media
cellcentered/elementsolution.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 * See the file COPYING for full copying permissions. *
5 * *
6 * This program is free software: you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License as published by *
8 * the Free Software Foundation, either version 3 of the License, or *
9 * (at your option) any later version. *
10 * *
11 * This program is distributed in the hope that it will be useful, *
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14 * GNU General Public License for more details. *
15 * *
16 * You should have received a copy of the GNU General Public License *
17 * along with this program. If not, see <http://www.gnu.org/licenses/>. *
18 *****************************************************************************/
24#ifndef DUMUX_CC_ELEMENT_SOLUTION_HH
25#define DUMUX_CC_ELEMENT_SOLUTION_HH
26
27#include <cassert>
28#include <utility>
29#include <type_traits>
31
32namespace Dumux {
33
38template<class FVElementGeometry, class PV>
40{
41 using GridGeometry = typename FVElementGeometry::GridGeometry;
42 using GridView = typename GridGeometry::GridView;
43 using Element = typename GridView::template Codim<0>::Entity;
44
45public:
47 using PrimaryVariables = PV;
48
50 CCElementSolution() = default;
51
53 template<class SolutionVector>
54 CCElementSolution(const Element& element, const SolutionVector& sol,
55 const GridGeometry& gridGeometry)
56 : CCElementSolution(sol[gridGeometry.elementMapper().index(element)])
57 {}
58
60 template<class ElementVolumeVariables>
61 CCElementSolution(const Element& element, const ElementVolumeVariables& elemVolVars,
62 const FVElementGeometry& fvGeometry)
63 {
64 for (const auto& scv : scvs(fvGeometry))
65 priVars_ = elemVolVars[scv].priVars();
66 }
67
70 : priVars_(std::move(priVars)) {}
71
74 : priVars_(priVars) {}
75
77 template<class SolutionVector>
78 void update(const Element& element, const SolutionVector& sol,
79 const GridGeometry& gridGeometry)
80 {
81 priVars_ = sol[gridGeometry.elementMapper().index(element)];
82 }
83
85 constexpr std::size_t size() const
86 { return 1; }
87
89 template<typename IndexType>
90 const PrimaryVariables& operator [](IndexType i) const
91 {
92 assert(i == 0 && "Index exceeds valid range!");
93 return priVars_;
94 }
95
97 template<typename IndexType>
99 {
100 assert(i == 0 && "Index exceeds valid range!");
101 return priVars_;
102 }
103
104private:
105 PrimaryVariables priVars_;
106};
107
112template<class Element, class SolutionVector, class GridGeometry>
113auto elementSolution(const Element& element, const SolutionVector& sol, const GridGeometry& gg)
114-> std::enable_if_t<GridGeometry::discMethod == DiscretizationMethods::cctpfa ||
115 GridGeometry::discMethod == DiscretizationMethods::ccmpfa,
116 CCElementSolution<typename GridGeometry::LocalView,
117 std::decay_t<decltype(std::declval<SolutionVector>()[0])>>
118 >
119{
120 using PrimaryVariables = std::decay_t<decltype(std::declval<SolutionVector>()[0])>;
121 return CCElementSolution<typename GridGeometry::LocalView, PrimaryVariables>(element, sol, gg);
122}
123
128template<class Element, class ElementVolumeVariables, class FVElementGeometry>
129auto elementSolution(const Element& element, const ElementVolumeVariables& elemVolVars, const FVElementGeometry& gg)
130-> std::enable_if_t<FVElementGeometry::GridGeometry::discMethod == DiscretizationMethods::cctpfa ||
131 FVElementGeometry::GridGeometry::discMethod == DiscretizationMethods::ccmpfa,
132 CCElementSolution<FVElementGeometry, typename ElementVolumeVariables::VolumeVariables::PrimaryVariables>>
133{
134 using PrimaryVariables = typename ElementVolumeVariables::VolumeVariables::PrimaryVariables;
135 return CCElementSolution<FVElementGeometry, PrimaryVariables>(element, elemVolVars, gg);
136}
137
143template<class FVElementGeometry, class PrimaryVariables>
144auto elementSolution(PrimaryVariables&& priVars)
145-> std::enable_if_t<FVElementGeometry::GridGeometry::discMethod == DiscretizationMethods::cctpfa ||
146 FVElementGeometry::GridGeometry::discMethod == DiscretizationMethods::ccmpfa,
148{
150}
151
157template<class FVElementGeometry, class PrimaryVariables>
158auto elementSolution(const PrimaryVariables& priVars)
159-> std::enable_if_t<FVElementGeometry::GridGeometry::discMethod == DiscretizationMethods::cctpfa ||
160 FVElementGeometry::GridGeometry::discMethod == DiscretizationMethods::ccmpfa,
162{
164}
165
166} // end namespace Dumux
167
168#endif
The available discretization methods in Dumux.
auto elementSolution(const Element &element, const SolutionVector &sol, const GridGeometry &gg) -> std::enable_if_t< GridGeometry::discMethod==DiscretizationMethods::box, BoxElementSolution< typename GridGeometry::LocalView, std::decay_t< decltype(std::declval< SolutionVector >()[0])> > >
Make an element solution for box schemes.
Definition: box/elementsolution.hh:118
Definition: adapt.hh:29
constexpr CCMpfa ccmpfa
Definition: method.hh:138
constexpr CCTpfa cctpfa
Definition: method.hh:137
The element solution vector.
Definition: cellcentered/elementsolution.hh:40
CCElementSolution(PrimaryVariables &&priVars)
Constructor with a primary variable object.
Definition: cellcentered/elementsolution.hh:69
const PrimaryVariables & operator[](IndexType i) const
bracket operator const access
Definition: cellcentered/elementsolution.hh:90
CCElementSolution(const Element &element, const SolutionVector &sol, const GridGeometry &gridGeometry)
Constructor with element, solution vector and grid geometry.
Definition: cellcentered/elementsolution.hh:54
constexpr std::size_t size() const
return the size of the element solution
Definition: cellcentered/elementsolution.hh:85
void update(const Element &element, const SolutionVector &sol, const GridGeometry &gridGeometry)
extract the element solution from the solution vector using a mapper
Definition: cellcentered/elementsolution.hh:78
CCElementSolution(const Element &element, const ElementVolumeVariables &elemVolVars, const FVElementGeometry &fvGeometry)
Constructor with element, element volume variables and fv element geometry.
Definition: cellcentered/elementsolution.hh:61
PV PrimaryVariables
export the primary variables type
Definition: cellcentered/elementsolution.hh:47
CCElementSolution(const PrimaryVariables &priVars)
Constructor with a primary variable object.
Definition: cellcentered/elementsolution.hh:73
CCElementSolution()=default
default constructor