3.2-git
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"
23
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 elementMapper_.update();
93 vertexMapper_.update();
94 cellDataVector_.resize(gridView_.size(0));
95 }
96
98
102 void adaptVariableSize(const int size)
103 {
104 cellDataVector_.resize(size);
105 }
106
109 {
110 return cellDataVector_;
111 }
112
114 {
115 assert(cellDataVector_.size() == gridView_.size(0));
116
117 return cellDataVector_;
118 }
119
121 CellData& cellData(const int idx)
122 {
123 assert(cellDataVector_.size() == gridView_.size(0));
124
125 return cellDataVector_[idx];
126 }
127
128 const CellData& cellData(const int idx) const
129 {
130 assert(cellDataVector_.size() == gridView_.size(0));
131
132 return cellDataVector_[idx];
133 }
134
136
140 int index(const Element& element) const
141 {
142 return elementMapper_.index(element);
143 }
144
146
150 int index(const Vertex& vertex) const
151 {
152 return vertexMapper_.index(vertex);
153 }
154
156 const GridView& gridView() const
157 {
158 return gridView_;
159 }
160
162 ElementMapper& elementMapper()
163 {
164 return elementMapper_;
165 }
167 const ElementMapper& elementMapper() const
168 {
169 return elementMapper_;
170 }
172 VertexMapper& vertexMapper()
173 {
174 return vertexMapper_;
175 }
177 const VertexMapper& vertexMapper() const
178 {
179 return vertexMapper_;
180 }
181};
182}
183#endif
Definition: adapt.hh:29
typename Properties::Detail::GetPropImpl< TypeTag, Property >::type GetProp
get the type of a property (equivalent to old macro GET_PROP(...))
Definition: propertysystem.hh:140
typename Properties::Detail::GetPropImpl< TypeTag, Property >::type::type GetPropType
get the type alias defined in the property (equivalent to old macro GET_PROP_TYPE(....
Definition: propertysystem.hh:149
Definition: common/pdesolver.hh:35
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:150
const CellData & cellData(const int idx) const
Definition: variableclass.hh:128
CellData & cellData(const int idx)
Return the cell data of a specific cell.
Definition: variableclass.hh:121
typename std::vector< CellData > CellDataVector
Definition: variableclass.hh:67
CellDataVector & cellDataGlobal()
Return the vector holding all cell data.
Definition: variableclass.hh:108
void initialize()
Initializes the variable class.
Definition: variableclass.hh:90
const ElementMapper & elementMapper() const
Return mapper for elements (for static grids)
Definition: variableclass.hh:167
int index(const Element &element) const
Get index of element (codim 0 entity)
Definition: variableclass.hh:140
const VertexMapper & vertexMapper() const
Return mapper for vertices (for static grids)
Definition: variableclass.hh:177
const GridView & gridView() const
Return gridView.
Definition: variableclass.hh:156
VertexMapper & vertexMapper()
Return mapper for vertices (for adaptive grids)
Definition: variableclass.hh:172
ElementMapper & elementMapper()
Return mapper for elements (for adaptive grids)
Definition: variableclass.hh:162
VariableClass(const GridView &gridView)
Constructs a VariableClass object.
Definition: variableclass.hh:80
const CellDataVector & cellDataGlobal() const
Definition: variableclass.hh:113
void adaptVariableSize(const int size)
Resizes sequential variable vectors.
Definition: variableclass.hh:102
Base file for properties related to sequential models.