3.6-git
DUNE for Multi-{Phase, Component, Scale, Physics, ...} flow and transport in porous media
discretization/facecentered/staggered/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_FACECENTERED_STAGGERED_SUBCONTROLVOLUME_HH
25#define DUMUX_DISCRETIZATION_FACECENTERED_STAGGERED_SUBCONTROLVOLUME_HH
26
27#include <array>
28#include <utility>
29
30#include <dune/geometry/type.hh>
31#include <dune/geometry/axisalignedcubegeometry.hh>
32
34
35namespace Dumux {
36
43template<class GridView>
45{
48 using Scalar = typename GridView::ctype;
49 using Element = typename GridView::template Codim<0>::Entity;
50 using GlobalPosition = typename Element::Geometry::GlobalCoordinate;
51
52 static constexpr int dim = GridView::Grid::dimension;
53 static constexpr int dimWorld = GridView::Grid::dimensionworld;
54 using CornerStorage = std::array<GlobalPosition, (1<<(dim))>;
55 using Geometry = Dune::AxisAlignedCubeGeometry<Scalar, dim, dimWorld>;
56};
57
62template<class GridView, class T = FaceCenteredDefaultScvGeometryTraits<GridView>>
64{
65 using Geometry = typename T::Geometry;
66 using CornerStorage = typename T::CornerStorage;
67 using Element = typename T::Element;
68 using GlobalPosition = typename T::GlobalPosition;
69 using Scalar = typename T::Scalar;
70 using GridIndexType = typename T::GridIndexType;
71 using SmallLocalIndexType = typename IndexTraits<GridView>::SmallLocalIndex;
72
73 using ElementGeometry = typename Element::Geometry;
74 using IntersectionGeometry = typename GridView::Intersection::Geometry;
75
76
77public:
79 using Traits = T;
80
82
83 FaceCenteredStaggeredSubControlVolume(const ElementGeometry& elementGeometry,
84 const IntersectionGeometry& intersectionGeometry,
85 const GridIndexType globalIndex,
86 const SmallLocalIndexType indexInElement,
87 const GridIndexType dofIdx,
88 const SmallLocalIndexType dofAxis,
89 const GridIndexType eIdx,
90 const bool boundary)
91 : center_(0.5*(intersectionGeometry.center() + elementGeometry.center()))
92 , dofPosition_(intersectionGeometry.center())
93 , volume_(elementGeometry.volume()*0.5)
94 , globalIndex_(globalIndex)
95 , indexInElement_(indexInElement)
96 , dofIdx_(dofIdx)
97 , dofAxis_(dofAxis)
98 , eIdx_(eIdx)
99 , boundary_(boundary)
100 {
101 for (int i = 0; i < corners_.size(); ++i)
102 {
103 auto& corner = corners_[i];
104
105 // copy the corner of the corresponding element
106 corner = elementGeometry.corner(i);
107
108 // shift the corner such that the scvf covers half of the lateral facet
109 // (keep the outer corner positions)
110 using std::abs;
111 const auto eps = 1e-8; // TODO
112 if (abs(corner[dofAxis] - intersectionGeometry.center()[dofAxis]) > eps)
113 corner[dofAxis] = elementGeometry.center()[dofAxis];
114 }
115
116 directionSign_ = (indexInElement % 2) ? 1.0 : -1.0;
117 }
118
120 const GlobalPosition& center() const
121 { return center_; }
122
124 const GlobalPosition& dofPosition() const
125 { return dofPosition_; }
126
127 Scalar volume() const
128 { return volume_; }
129
130 GridIndexType dofIndex() const
131 { return dofIdx_; }
132
133 GridIndexType index() const
134 { return globalIndex_; }
135
136 GridIndexType elementIndex() const
137 { return eIdx_; }
138
139 SmallLocalIndexType indexInElement() const
140 { return indexInElement_; }
141
142 SmallLocalIndexType localDofIndex() const
143 { return indexInElement_; }
144
145 SmallLocalIndexType dofAxis() const
146 { return dofAxis_; }
147
148 std::int_least8_t directionSign() const
149 { return directionSign_; }
150
151 bool boundary() const
152 { return boundary_; }
153
154 const GlobalPosition& corner(unsigned int localIdx) const
155 {
156 assert(localIdx < corners_.size() && "provided index exceeds the number of corners");
157 return corners_[localIdx];
158 }
159
161 Geometry geometry() const
162 {
163 return Geometry(corners_.front(), corners_.back());
164 }
165
166private:
167 GlobalPosition center_;
168 GlobalPosition dofPosition_;
169 CornerStorage corners_;
170 Scalar volume_;
171 GridIndexType globalIndex_;
172 SmallLocalIndexType indexInElement_;
173 GridIndexType dofIdx_;
174 SmallLocalIndexType dofAxis_;
175 std::int_least8_t directionSign_;
176 GridIndexType eIdx_;
177 bool boundary_;
178};
179
180} // end namespace Dumux
181
182#endif
Defines the index types used for grid and local indices.
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
std::uint_least8_t SmallLocalIndex
Definition: indextraits.hh:41
unsigned int LocalIndex
Definition: indextraits.hh:40
Default traits class to be used for the sub-control volumes for the face-centered staggered scheme.
Definition: discretization/facecentered/staggered/subcontrolvolume.hh:45
static constexpr int dimWorld
Definition: discretization/facecentered/staggered/subcontrolvolume.hh:53
typename GridView::template Codim< 0 >::Entity Element
Definition: discretization/facecentered/staggered/subcontrolvolume.hh:49
std::array< GlobalPosition,(1<<(dim))> CornerStorage
Definition: discretization/facecentered/staggered/subcontrolvolume.hh:54
typename GridView::ctype Scalar
Definition: discretization/facecentered/staggered/subcontrolvolume.hh:48
static constexpr int dim
Definition: discretization/facecentered/staggered/subcontrolvolume.hh:52
typename IndexTraits< GridView >::GridIndex GridIndexType
Definition: discretization/facecentered/staggered/subcontrolvolume.hh:46
Dune::AxisAlignedCubeGeometry< Scalar, dim, dimWorld > Geometry
Definition: discretization/facecentered/staggered/subcontrolvolume.hh:55
typename Element::Geometry::GlobalCoordinate GlobalPosition
Definition: discretization/facecentered/staggered/subcontrolvolume.hh:50
typename IndexTraits< GridView >::LocalIndex LocalIndexType
Definition: discretization/facecentered/staggered/subcontrolvolume.hh:47
Face centered staggered sub control volume.
Definition: discretization/facecentered/staggered/subcontrolvolume.hh:64
const GlobalPosition & center() const
The center of the sub control volume.
Definition: discretization/facecentered/staggered/subcontrolvolume.hh:120
const GlobalPosition & dofPosition() const
The position of the degree of freedom.
Definition: discretization/facecentered/staggered/subcontrolvolume.hh:124
GridIndexType elementIndex() const
Definition: discretization/facecentered/staggered/subcontrolvolume.hh:136
T Traits
state the traits public and thus export all types
Definition: discretization/facecentered/staggered/subcontrolvolume.hh:79
SmallLocalIndexType localDofIndex() const
Definition: discretization/facecentered/staggered/subcontrolvolume.hh:142
Scalar volume() const
Definition: discretization/facecentered/staggered/subcontrolvolume.hh:127
SmallLocalIndexType dofAxis() const
Definition: discretization/facecentered/staggered/subcontrolvolume.hh:145
GridIndexType index() const
Definition: discretization/facecentered/staggered/subcontrolvolume.hh:133
SmallLocalIndexType indexInElement() const
Definition: discretization/facecentered/staggered/subcontrolvolume.hh:139
FaceCenteredStaggeredSubControlVolume(const ElementGeometry &elementGeometry, const IntersectionGeometry &intersectionGeometry, const GridIndexType globalIndex, const SmallLocalIndexType indexInElement, const GridIndexType dofIdx, const SmallLocalIndexType dofAxis, const GridIndexType eIdx, const bool boundary)
Definition: discretization/facecentered/staggered/subcontrolvolume.hh:83
const GlobalPosition & corner(unsigned int localIdx) const
Definition: discretization/facecentered/staggered/subcontrolvolume.hh:154
std::int_least8_t directionSign() const
Definition: discretization/facecentered/staggered/subcontrolvolume.hh:148
GridIndexType dofIndex() const
Definition: discretization/facecentered/staggered/subcontrolvolume.hh:130
Geometry geometry() const
The geometry of the sub control volume face.
Definition: discretization/facecentered/staggered/subcontrolvolume.hh:161
bool boundary() const
Definition: discretization/facecentered/staggered/subcontrolvolume.hh:151