3.5-git
DUNE for Multi-{Phase, Component, Scale, Physics, ...} flow and transport in porous media
discretization/porenetwork/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_PNM_SUBCONTROLVOLUME_HH
25#define DUMUX_DISCRETIZATION_PNM_SUBCONTROLVOLUME_HH
26
27#include <dune/geometry/affinegeometry.hh>
28#include <dumux/common/math.hh>
31
32namespace Dumux::PoreNetwork {
33
39template<class GridView>
41{
42 using Grid = typename GridView::Grid;
43
44 static const int dim = Grid::dimension;
45 static const int dimWorld = Grid::dimensionworld;
46
49 using Scalar = typename Grid::ctype;
50 using GlobalPosition = Dune::FieldVector<Scalar, dimWorld>;
51 using CornerStorage = std::array<GlobalPosition, 2>;
52 using Geometry = Dune::AffineGeometry<Scalar, 1, dimWorld>;
53};
54
61template<class GV,
64: public Dumux::SubControlVolumeBase<PNMSubControlVolume<GV, T>, T>
65{
68 using GridIndexType = typename T::GridIndexType;
69 using LocalIndexType = typename T::LocalIndexType;
70 using Scalar = typename T::Scalar;
71 using CornerStorage = typename T::CornerStorage;
72 using Geometry = typename T::Geometry;
73
74public:
76 using GlobalPosition = typename T::GlobalPosition;
78 using Traits = T;
79
82
83 // the contructor in the box case
84 template<class Corners>
86 LocalIndexType scvIdx,
87 GridIndexType elementIndex,
88 Corners&& corners,
89 const Scalar volume)
90 : center_((corners[0]+corners[1])/2.0),
91 corners_(std::forward<CornerStorage>(corners)),
92 volume_(volume),
93 elementIndex_(elementIndex),
94 localDofIdx_(scvIdx),
95 dofIndex_(dofIndex)
96 {}
97
100 const GlobalPosition& center() const
101 { return center_; }
102
104 Scalar volume() const
105 { return volume_; }
106
108 LocalIndexType localDofIndex() const
109 { return localDofIdx_; }
110
112 LocalIndexType indexInElement() const
113 { return localDofIdx_; }
114
116 GridIndexType dofIndex() const
117 { return dofIndex_; }
118
119 // The position of the dof this scv is embedded in
121 { return corners_[0]; }
122
124 GridIndexType elementIndex() const
125 { return elementIndex_; }
126
128 const GlobalPosition& corner(LocalIndexType localIdx) const
129 {
130 assert(localIdx < corners_.size() && "provided index exceeds the number of corners");
131 return corners_[localIdx];
132 }
133
135 Geometry geometry() const
136 {
137 return Geometry(Dune::GeometryTypes::simplex(1), corners_);
138 }
139
140private:
141 GlobalPosition center_;
142 CornerStorage corners_;
143 Scalar volume_;
144 GridIndexType elementIndex_;
145 LocalIndexType localDofIdx_;
146 GridIndexType dofIndex_;
147};
148
149} // end namespace Dumux::PoreNetwork
150
151#endif
Defines the index types used for grid and local indices.
Define some often used mathematical functions.
Base class for a sub control volume.
Definition: discretization/porenetwork/fvelementgeometry.hh:34
typename GridView::IndexSet::IndexType GridIndex
Definition: indextraits.hh:39
unsigned int LocalIndex
Definition: indextraits.hh:40
Default traits class.
Definition: discretization/porenetwork/subcontrolvolume.hh:41
static const int dim
Definition: discretization/porenetwork/subcontrolvolume.hh:44
typename GridView::Grid Grid
Definition: discretization/porenetwork/subcontrolvolume.hh:42
typename Grid::ctype Scalar
Definition: discretization/porenetwork/subcontrolvolume.hh:49
std::array< GlobalPosition, 2 > CornerStorage
Definition: discretization/porenetwork/subcontrolvolume.hh:51
Dune::AffineGeometry< Scalar, 1, dimWorld > Geometry
Definition: discretization/porenetwork/subcontrolvolume.hh:52
static const int dimWorld
Definition: discretization/porenetwork/subcontrolvolume.hh:45
Dune::FieldVector< Scalar, dimWorld > GlobalPosition
Definition: discretization/porenetwork/subcontrolvolume.hh:50
typename IndexTraits< GridView >::LocalIndex LocalIndexType
Definition: discretization/porenetwork/subcontrolvolume.hh:48
typename IndexTraits< GridView >::GridIndex GridIndexType
Definition: discretization/porenetwork/subcontrolvolume.hh:47
the sub control volume for porenetworks
Definition: discretization/porenetwork/subcontrolvolume.hh:65
Geometry geometry() const
The geometry of the sub control volume e.g. for integration.
Definition: discretization/porenetwork/subcontrolvolume.hh:135
T Traits
state the traits public and thus export all types
Definition: discretization/porenetwork/subcontrolvolume.hh:78
LocalIndexType localDofIndex() const
The element-local index of the dof this scv is embedded in.
Definition: discretization/porenetwork/subcontrolvolume.hh:108
GridIndexType dofIndex() const
The index of the dof this scv is embedded in.
Definition: discretization/porenetwork/subcontrolvolume.hh:116
const GlobalPosition & corner(LocalIndexType localIdx) const
Return the corner for the given local index.
Definition: discretization/porenetwork/subcontrolvolume.hh:128
GridIndexType elementIndex() const
The global index of the element this scv is embedded in.
Definition: discretization/porenetwork/subcontrolvolume.hh:124
const GlobalPosition & center() const
Definition: discretization/porenetwork/subcontrolvolume.hh:100
Scalar volume() const
The volume of the sub control volume (part of a pore)
Definition: discretization/porenetwork/subcontrolvolume.hh:104
PNMSubControlVolume(GridIndexType dofIndex, LocalIndexType scvIdx, GridIndexType elementIndex, Corners &&corners, const Scalar volume)
Definition: discretization/porenetwork/subcontrolvolume.hh:85
PNMSubControlVolume()=default
The default constructor.
typename T::GlobalPosition GlobalPosition
export the type used for global coordinates
Definition: discretization/porenetwork/subcontrolvolume.hh:76
LocalIndexType indexInElement() const
The element-local index of this scv.
Definition: discretization/porenetwork/subcontrolvolume.hh:112
const GlobalPosition & dofPosition() const
Definition: discretization/porenetwork/subcontrolvolume.hh:120
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