3.4
DUNE for Multi-{Phase, Component, Scale, Physics, ...} flow and transport in porous media
variableclass.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 *****************************************************************************/
19#ifndef DUMUX_VARIABLECLASS_HH
20#define DUMUX_VARIABLECLASS_HH
21
22#include "properties.hh"
24
25// for parallelization
26//#include <dumux/parallel/elementhandles.hh>
27
33namespace Dumux
34{
35
40
47template<class TypeTag>
49{
50private:
54
55 enum
56 {
57 dim = GridView::dimension,
58 };
59
60 using Element = typename GridView::Traits::template Codim<0>::Entity;
61 using Vertex = typename GridView::Traits::template Codim<dim>::Entity;
62
63 using VertexMapper = typename SolutionTypes::VertexMapper;
64 using ElementMapper = typename SolutionTypes::ElementMapper;
65
66public:
67 using CellDataVector = typename std::vector<CellData>;
68
69private:
70 const GridView gridView_;
71 ElementMapper elementMapper_;
72 VertexMapper vertexMapper_;
73 CellDataVector cellDataVector_;
74
75public:
77
80 VariableClass(const GridView& gridView) :
81 gridView_(gridView),
82 elementMapper_(gridView, Dune::mcmgElementLayout()),
83 vertexMapper_(gridView, Dune::mcmgVertexLayout())
84 {}
85
87
91 {
92 if constexpr (Deprecated::hasUpdateGridView<ElementMapper, GridView>())
93 elementMapper_.update(gridView_);
94 else
95 Deprecated::update(elementMapper_);
96
97 if constexpr (Deprecated::hasUpdateGridView<VertexMapper, GridView>())
98 vertexMapper_.update(gridView_);
99 else
100 Deprecated::update(vertexMapper_);
101
102 cellDataVector_.resize(gridView_.size(0));
103 }
104
106
110 void adaptVariableSize(const int size)
111 {
112 cellDataVector_.resize(size);
113 }
114
117 {
118 return cellDataVector_;
119 }
120
122 {
123 assert(cellDataVector_.size() == gridView_.size(0));
124
125 return cellDataVector_;
126 }
127
129 CellData& cellData(const int idx)
130 {
131 assert(cellDataVector_.size() == gridView_.size(0));
132
133 return cellDataVector_[idx];
134 }
135
136 const CellData& cellData(const int idx) const
137 {
138 assert(cellDataVector_.size() == gridView_.size(0));
139
140 return cellDataVector_[idx];
141 }
142
144
148 int index(const Element& element) const
149 {
150 return elementMapper_.index(element);
151 }
152
154
158 int index(const Vertex& vertex) const
159 {
160 return vertexMapper_.index(vertex);
161 }
162
164 const GridView& gridView() const
165 {
166 return gridView_;
167 }
168
170 ElementMapper& elementMapper()
171 {
172 return elementMapper_;
173 }
175 const ElementMapper& elementMapper() const
176 {
177 return elementMapper_;
178 }
180 VertexMapper& vertexMapper()
181 {
182 return vertexMapper_;
183 }
185 const VertexMapper& vertexMapper() const
186 {
187 return vertexMapper_;
188 }
189};
190}
191#endif
Helpers for deprecation.
Definition: adapt.hh:29
typename Properties::Detail::GetPropImpl< TypeTag, Property >::type GetProp
get the type of a property
Definition: propertysystem.hh:141
typename Properties::Detail::GetPropImpl< TypeTag, Property >::type::type GetPropType
get the type alias defined in the property
Definition: propertysystem.hh:150
Definition: common/pdesolver.hh:36
Base class holding the variables and discretized data for sequential models.
Definition: variableclass.hh:49
int index(const Vertex &vertex) const
Get index of vertex (codim dim entity)
Definition: variableclass.hh:158
const CellData & cellData(const int idx) const
Definition: variableclass.hh:136
CellData & cellData(const int idx)
Return the cell data of a specific cell.
Definition: variableclass.hh:129
typename std::vector< CellData > CellDataVector
Definition: variableclass.hh:67
CellDataVector & cellDataGlobal()
Return the vector holding all cell data.
Definition: variableclass.hh:116
void initialize()
Initializes the variable class.
Definition: variableclass.hh:90
const ElementMapper & elementMapper() const
Return mapper for elements (for static grids)
Definition: variableclass.hh:175
int index(const Element &element) const
Get index of element (codim 0 entity)
Definition: variableclass.hh:148
const VertexMapper & vertexMapper() const
Return mapper for vertices (for static grids)
Definition: variableclass.hh:185
const GridView & gridView() const
Return gridView.
Definition: variableclass.hh:164
VertexMapper & vertexMapper()
Return mapper for vertices (for adaptive grids)
Definition: variableclass.hh:180
ElementMapper & elementMapper()
Return mapper for elements (for adaptive grids)
Definition: variableclass.hh:170
VariableClass(const GridView &gridView)
Constructs a VariableClass object.
Definition: variableclass.hh:80
const CellDataVector & cellDataGlobal() const
Definition: variableclass.hh:121
void adaptVariableSize(const int size)
Resizes sequential variable vectors.
Definition: variableclass.hh:110
Base file for properties related to sequential models.