3.6-git
DUNE for Multi-{Phase, Component, Scale, Physics, ...} flow and transport in porous media
discretization/box/subcontrolvolume.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_BOX_SUBCONTROLVOLUME_HH
25#define DUMUX_DISCRETIZATION_BOX_SUBCONTROLVOLUME_HH
26
27#include <dune/geometry/type.hh>
28#include <dune/geometry/multilineargeometry.hh>
29
30#include <dumux/common/math.hh>
36
37namespace Dumux {
38
45template<class GridView>
47{
48 using Grid = typename GridView::Grid;
49
50 static const int dim = Grid::dimension;
51 static const int dimWorld = Grid::dimensionworld;
52
55 using Scalar = typename Grid::ctype;
57 using Geometry = Dune::MultiLinearGeometry<Scalar, dim, dimWorld, GeometryTraits>;
58 using CornerStorage = typename GeometryTraits::template CornerStorage<dim, dimWorld>::Type;
59 using GlobalPosition = typename CornerStorage::value_type;
60};
61
68template<class GV,
71: public SubControlVolumeBase<BoxSubControlVolume<GV, T>, T>
72{
75 using Geometry = typename T::Geometry;
76 using GridIndexType = typename T::GridIndexType;
77 using LocalIndexType = typename T::LocalIndexType;
78 using Scalar = typename T::Scalar;
79 using CornerStorage = typename T::CornerStorage;
80 static constexpr int dim = Geometry::mydimension;
81
82public:
84 using GlobalPosition = typename T::GlobalPosition;
86 using Traits = T;
87
90
91 // the constructor in the box case
92 template<class GeometryHelper>
93 BoxSubControlVolume(const GeometryHelper& geometryHelper,
94 LocalIndexType scvIdx,
95 GridIndexType elementIndex,
96 GridIndexType dofIndex)
97 : corners_(geometryHelper.getScvCorners(scvIdx))
98 , center_(Dumux::center(corners_))
99 , elementIndex_(elementIndex)
100 , localDofIdx_(scvIdx)
101 , dofIndex_(dofIndex)
102 {
103 volume_ = Dumux::convexPolytopeVolume<dim>(
104 Dune::GeometryTypes::cube(dim),
105 [&](unsigned int i){ return corners_[i]; }
106 );
107 }
108
110 const GlobalPosition& center() const
111 {
112 return center_;
113 }
114
116 Scalar volume() const
117 {
118 return volume_;
119 }
120
122 // e.g. for integration
123 [[deprecated("This will be removed after 3.6. Use fvGeometry.geometry(scv).")]]
124 Geometry geometry() const
125 {
126 return Geometry(Dune::GeometryTypes::cube(dim), corners_);
127 }
128
130 LocalIndexType localDofIndex() const
131 {
132 return localDofIdx_;
133 }
134
137 LocalIndexType indexInElement() const
138 {
139 return localDofIdx_;
140 }
141
143 GridIndexType dofIndex() const
144 {
145 return dofIndex_;
146 }
147
148 // The position of the dof this scv is embedded in
150 {
151 // The corner list is defined such that the first entry is the vertex itself
152 return corners_[0];
153 }
154
156 GridIndexType elementIndex() const
157 {
158 return elementIndex_;
159 }
160
162 [[deprecated("This will be removed after 3.6. Use fvGeometry.geometry(scv).corner(i).")]]
163 const GlobalPosition& corner(LocalIndexType localIdx) const
164 {
165 assert(localIdx < corners_.size() && "provided index exceeds the number of corners");
166 return corners_[localIdx];
167 }
168
169private:
170 CornerStorage corners_;
171 GlobalPosition center_;
172 Scalar volume_;
173 GridIndexType elementIndex_;
174 LocalIndexType localDofIdx_;
175 GridIndexType dofIndex_;
176};
177
178} // end namespace Dumux
179
180#endif
Defines the index types used for grid and local indices.
Define some often used mathematical functions.
Helper class constructing the dual grid finite volume geometries for the box discretizazion method.
Base class for a sub control volume.
Compute the center point of a convex polytope geometry or a random-access container of corner points.
Compute the volume of several common geometry types.
Adaption of the non-isothermal two-phase two-component flow model to problems with CO2.
Definition: adapt.hh:29
typename GridView::IndexSet::IndexType GridIndex
Definition: indextraits.hh:39
unsigned int LocalIndex
Definition: indextraits.hh:40
Traits for an efficient corner storage for box method sub control volumes.
Definition: boxgeometryhelper.hh:44
Default traits class to be used for the sub-control volumes for the box scheme.
Definition: discretization/box/subcontrolvolume.hh:47
typename GridView::Grid Grid
Definition: discretization/box/subcontrolvolume.hh:48
Dune::MultiLinearGeometry< Scalar, dim, dimWorld, GeometryTraits > Geometry
Definition: discretization/box/subcontrolvolume.hh:57
typename IndexTraits< GridView >::GridIndex GridIndexType
Definition: discretization/box/subcontrolvolume.hh:53
typename IndexTraits< GridView >::LocalIndex LocalIndexType
Definition: discretization/box/subcontrolvolume.hh:54
static const int dim
Definition: discretization/box/subcontrolvolume.hh:50
static const int dimWorld
Definition: discretization/box/subcontrolvolume.hh:51
typename Grid::ctype Scalar
Definition: discretization/box/subcontrolvolume.hh:55
typename CornerStorage::value_type GlobalPosition
Definition: discretization/box/subcontrolvolume.hh:59
typename GeometryTraits::template CornerStorage< dim, dimWorld >::Type CornerStorage
Definition: discretization/box/subcontrolvolume.hh:58
the sub control volume for the box scheme
Definition: discretization/box/subcontrolvolume.hh:72
Geometry geometry() const
The geometry of the sub control volume.
Definition: discretization/box/subcontrolvolume.hh:124
const GlobalPosition & corner(LocalIndexType localIdx) const
Return the corner for the given local index.
Definition: discretization/box/subcontrolvolume.hh:163
T Traits
state the traits public and thus export all types
Definition: discretization/box/subcontrolvolume.hh:86
LocalIndexType localDofIndex() const
The element-local index of the dof this scv is embedded in.
Definition: discretization/box/subcontrolvolume.hh:130
const GlobalPosition & center() const
The center of the sub control volume.
Definition: discretization/box/subcontrolvolume.hh:110
BoxSubControlVolume()=default
The default constructor.
typename T::GlobalPosition GlobalPosition
export the type used for global coordinates
Definition: discretization/box/subcontrolvolume.hh:84
LocalIndexType indexInElement() const
Definition: discretization/box/subcontrolvolume.hh:137
GridIndexType elementIndex() const
The global index of the element this scv is embedded in.
Definition: discretization/box/subcontrolvolume.hh:156
GridIndexType dofIndex() const
The index of the dof this scv is embedded in.
Definition: discretization/box/subcontrolvolume.hh:143
Scalar volume() const
The volume of the sub control volume.
Definition: discretization/box/subcontrolvolume.hh:116
const GlobalPosition & dofPosition() const
Definition: discretization/box/subcontrolvolume.hh:149
BoxSubControlVolume(const GeometryHelper &geometryHelper, LocalIndexType scvIdx, GridIndexType elementIndex, GridIndexType dofIndex)
Definition: discretization/box/subcontrolvolume.hh:93
Base class for a sub control volume, i.e a part of the control volume we are making the balance for....
Definition: subcontrolvolumebase.hh:38