3.6-git
DUNE for Multi-{Phase, Component, Scale, Physics, ...} flow and transport in porous media
facecentered/diamond/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_DISCRETIZATION_FACECENTERED_DIAMOND_ELEMENT_SOLUTION_HH
25#define DUMUX_DISCRETIZATION_FACECENTERED_DIAMOND_ELEMENT_SOLUTION_HH
26
27#include <type_traits>
28#include <array>
29
30#include <dune/common/reservedvector.hh>
33
34namespace Dumux {
35
40template<class FVElementGeometry, class PV>
42{
43 using GridGeometry = typename FVElementGeometry::GridGeometry;
44 using GridView = typename GridGeometry::GridView;
45 using Element = typename GridView::template Codim<0>::Entity;
46
47 static constexpr int dim = GridView::dimension;
48 static constexpr int numCubeFaces = 2*dim;
49
50public:
52 using PrimaryVariables = PV;
53
55
57 template<class SolutionVector>
58 FaceCenteredDiamondElementSolution(const Element& element, const SolutionVector& sol,
59 const GridGeometry& gridGeometry)
60 {
61 update(element, sol, gridGeometry);
62 }
63
65 template<class ElementVolumeVariables>
66 FaceCenteredDiamondElementSolution(const Element& element, const ElementVolumeVariables& elemVolVars,
67 const FVElementGeometry& fvGeometry)
68 {
69 priVars_.resize(fvGeometry.numScv());
70 for (const auto& scv : scvs(fvGeometry))
71 priVars_[scv.localDofIndex()] = elemVolVars[scv].priVars();
72 }
73
75 template<class SolutionVector>
76 void update(const Element& element, const SolutionVector& sol,
77 const GridGeometry& gridGeometry)
78 {
79 const auto numFaces = element.subEntities(1);
80 priVars_.resize(numFaces);
81 for (int fIdx = 0; fIdx < numFaces; ++fIdx)
82 priVars_[fIdx] = sol[gridGeometry.dofMapper().subIndex(element, fIdx, 1)];
83 }
84
86 template<class SolutionVector>
87 void update(const Element& element, const SolutionVector& sol,
88 const FVElementGeometry& fvGeometry)
89 {
90 priVars_.resize(fvGeometry.numScv());
91 for (const auto& scv : scvs(fvGeometry))
92 priVars_[scv.localDofIndex()] = sol[scv.dofIndex()];
93 }
94
96 template<typename IndexType>
97 const PrimaryVariables& operator [](IndexType localScvIdx) const
98 { return priVars_[localScvIdx]; }
99
101 template<typename IndexType>
102 PrimaryVariables& operator [](IndexType localScvIdx)
103 { return priVars_[localScvIdx]; }
104
106 std::size_t size() const
107 { return priVars_.size(); }
108
109private:
110 Dune::ReservedVector<PrimaryVariables, numCubeFaces> priVars_;
111};
112
117template<class Element, class SolutionVector, class GridGeometry>
118auto elementSolution(const Element& element, const SolutionVector& sol, const GridGeometry& gg)
119-> std::enable_if_t<GridGeometry::discMethod == DiscretizationMethods::fcdiamond,
120 FaceCenteredDiamondElementSolution<typename GridGeometry::LocalView,
121 std::decay_t<decltype(std::declval<SolutionVector>()[0])>>
122 >
123{
124 using PrimaryVariables = std::decay_t<decltype(std::declval<SolutionVector>()[0])>;
125 return FaceCenteredDiamondElementSolution<typename GridGeometry::LocalView, PrimaryVariables>(element, sol, gg);
126}
127
132template<class Element, class ElementVolumeVariables, class FVElementGeometry>
133auto elementSolution(const Element& element, const ElementVolumeVariables& elemVolVars, const FVElementGeometry& gg)
134-> std::enable_if_t<FVElementGeometry::GridGeometry::discMethod == DiscretizationMethods::fcdiamond,
135 FaceCenteredDiamondElementSolution<FVElementGeometry, typename ElementVolumeVariables::VolumeVariables::PrimaryVariables>>
136{
137 using PrimaryVariables = typename ElementVolumeVariables::VolumeVariables::PrimaryVariables;
138 return FaceCenteredDiamondElementSolution<FVElementGeometry, PrimaryVariables>(element, elemVolVars, gg);
139}
140
141} // end namespace Dumux
142
143#endif
Defines the index types used for grid and local indices.
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
Adaption of the non-isothermal two-phase two-component flow model to problems with CO2.
Definition: adapt.hh:29
constexpr FCDiamond fcdiamond
Definition: method.hh:141
The global face variables class for face-centered diamond models.
Definition: facecentered/diamond/elementsolution.hh:42
std::size_t size() const
return the size of the element solution
Definition: facecentered/diamond/elementsolution.hh:106
PV PrimaryVariables
export the primary variables type
Definition: facecentered/diamond/elementsolution.hh:52
FaceCenteredDiamondElementSolution(const Element &element, const ElementVolumeVariables &elemVolVars, const FVElementGeometry &fvGeometry)
Constructor with element, element volume variables and fv element geometry.
Definition: facecentered/diamond/elementsolution.hh:66
const PrimaryVariables & operator[](IndexType localScvIdx) const
bracket operator const access
Definition: facecentered/diamond/elementsolution.hh:97
void update(const Element &element, const SolutionVector &sol, const GridGeometry &gridGeometry)
extract the element solution from the solution vector using a mapper
Definition: facecentered/diamond/elementsolution.hh:76
FaceCenteredDiamondElementSolution(const Element &element, const SolutionVector &sol, const GridGeometry &gridGeometry)
Constructor with element, solution vector and grid geometry.
Definition: facecentered/diamond/elementsolution.hh:58
void update(const Element &element, const SolutionVector &sol, const FVElementGeometry &fvGeometry)
extract the element solution from the solution vector using a mapper
Definition: facecentered/diamond/elementsolution.hh:87