version 3.8
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// SPDX-FileCopyrightInfo: Copyright © DuMux Project contributors, see AUTHORS.md in root folder
5// SPDX-License-Identifier: GPL-3.0-or-later
6//
12#ifndef DUMUX_DISCRETIZATION_FACECENTERED_STAGGERED_SUBCONTROLVOLUME_HH
13#define DUMUX_DISCRETIZATION_FACECENTERED_STAGGERED_SUBCONTROLVOLUME_HH
14
15#include <array>
16#include <utility>
17
18#include <dune/geometry/type.hh>
19#include <dune/geometry/axisalignedcubegeometry.hh>
20
22
23namespace Dumux {
24
31template<class GridView>
33{
36 using Scalar = typename GridView::ctype;
37 using Element = typename GridView::template Codim<0>::Entity;
38 using GlobalPosition = typename Element::Geometry::GlobalCoordinate;
39
40 static constexpr int dim = GridView::Grid::dimension;
41 static constexpr int dimWorld = GridView::Grid::dimensionworld;
42 using CornerStorage = std::array<GlobalPosition, (1<<(dim))>;
43 using Geometry = Dune::AxisAlignedCubeGeometry<Scalar, dim, dimWorld>;
44};
45
50template<class GridView, class T = FaceCenteredDefaultScvGeometryTraits<GridView>>
52{
53 using Geometry = typename T::Geometry;
54 using CornerStorage = typename T::CornerStorage;
55 using Element = typename T::Element;
56 using GlobalPosition = typename T::GlobalPosition;
57 using Scalar = typename T::Scalar;
58 using GridIndexType = typename T::GridIndexType;
59 using SmallLocalIndexType = typename IndexTraits<GridView>::SmallLocalIndex;
60
61 using ElementGeometry = typename Element::Geometry;
62 using IntersectionGeometry = typename GridView::Intersection::Geometry;
63
64
65public:
67 using Traits = T;
68
70
71 FaceCenteredStaggeredSubControlVolume(const ElementGeometry& elementGeometry,
72 const IntersectionGeometry& intersectionGeometry,
73 const GridIndexType globalIndex,
74 const SmallLocalIndexType indexInElement,
75 const GridIndexType dofIdx,
76 const SmallLocalIndexType dofAxis,
77 const GridIndexType eIdx,
78 const bool boundary)
79 : center_(0.5*(intersectionGeometry.center() + elementGeometry.center()))
80 , dofPosition_(intersectionGeometry.center())
81 , volume_(elementGeometry.volume()*0.5)
82 , globalIndex_(globalIndex)
83 , indexInElement_(indexInElement)
84 , dofIdx_(dofIdx)
85 , dofAxis_(dofAxis)
86 , eIdx_(eIdx)
87 , boundary_(boundary)
88 {
89 directionSign_ = (indexInElement % 2) ? 1.0 : -1.0;
90 }
91
93 const GlobalPosition& center() const
94 { return center_; }
95
97 const GlobalPosition& dofPosition() const
98 { return dofPosition_; }
99
100 Scalar volume() const
101 { return volume_; }
102
103 GridIndexType dofIndex() const
104 { return dofIdx_; }
105
106 GridIndexType index() const
107 { return globalIndex_; }
108
109 GridIndexType elementIndex() const
110 { return eIdx_; }
111
112 SmallLocalIndexType indexInElement() const
113 { return indexInElement_; }
114
115 SmallLocalIndexType localDofIndex() const
116 { return indexInElement_; }
117
118 SmallLocalIndexType dofAxis() const
119 { return dofAxis_; }
120
121 std::int_least8_t directionSign() const
122 { return directionSign_; }
123
124 bool boundary() const
125 { return boundary_; }
126
127private:
128 GlobalPosition center_;
129 GlobalPosition dofPosition_;
130 Scalar volume_;
131 GridIndexType globalIndex_;
132 SmallLocalIndexType indexInElement_;
133 GridIndexType dofIdx_;
134 SmallLocalIndexType dofAxis_;
135 std::int_least8_t directionSign_;
136 GridIndexType eIdx_;
137 bool boundary_;
138};
139
140} // end namespace Dumux
141
142#endif
Face centered staggered sub control volume.
Definition: discretization/facecentered/staggered/subcontrolvolume.hh:52
const GlobalPosition & center() const
The center of the sub control volume.
Definition: discretization/facecentered/staggered/subcontrolvolume.hh:93
const GlobalPosition & dofPosition() const
The position of the degree of freedom.
Definition: discretization/facecentered/staggered/subcontrolvolume.hh:97
GridIndexType elementIndex() const
Definition: discretization/facecentered/staggered/subcontrolvolume.hh:109
T Traits
state the traits public and thus export all types
Definition: discretization/facecentered/staggered/subcontrolvolume.hh:67
SmallLocalIndexType localDofIndex() const
Definition: discretization/facecentered/staggered/subcontrolvolume.hh:115
Scalar volume() const
Definition: discretization/facecentered/staggered/subcontrolvolume.hh:100
SmallLocalIndexType dofAxis() const
Definition: discretization/facecentered/staggered/subcontrolvolume.hh:118
GridIndexType index() const
Definition: discretization/facecentered/staggered/subcontrolvolume.hh:106
SmallLocalIndexType indexInElement() const
Definition: discretization/facecentered/staggered/subcontrolvolume.hh:112
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:71
std::int_least8_t directionSign() const
Definition: discretization/facecentered/staggered/subcontrolvolume.hh:121
GridIndexType dofIndex() const
Definition: discretization/facecentered/staggered/subcontrolvolume.hh:103
bool boundary() const
Definition: discretization/facecentered/staggered/subcontrolvolume.hh:124
Defines the index types used for grid and local indices.
Definition: adapt.hh:17
Default traits class to be used for the sub-control volumes for the face-centered staggered scheme.
Definition: discretization/facecentered/staggered/subcontrolvolume.hh:33
static constexpr int dimWorld
Definition: discretization/facecentered/staggered/subcontrolvolume.hh:41
typename GridView::template Codim< 0 >::Entity Element
Definition: discretization/facecentered/staggered/subcontrolvolume.hh:37
std::array< GlobalPosition,(1<<(dim))> CornerStorage
Definition: discretization/facecentered/staggered/subcontrolvolume.hh:42
typename GridView::ctype Scalar
Definition: discretization/facecentered/staggered/subcontrolvolume.hh:36
static constexpr int dim
Definition: discretization/facecentered/staggered/subcontrolvolume.hh:40
typename IndexTraits< GridView >::GridIndex GridIndexType
Definition: discretization/facecentered/staggered/subcontrolvolume.hh:34
Dune::AxisAlignedCubeGeometry< Scalar, dim, dimWorld > Geometry
Definition: discretization/facecentered/staggered/subcontrolvolume.hh:43
typename Element::Geometry::GlobalCoordinate GlobalPosition
Definition: discretization/facecentered/staggered/subcontrolvolume.hh:38
typename IndexTraits< GridView >::LocalIndex LocalIndexType
Definition: discretization/facecentered/staggered/subcontrolvolume.hh:35
typename GridView::IndexSet::IndexType GridIndex
Definition: indextraits.hh:27
std::uint_least8_t SmallLocalIndex
Definition: indextraits.hh:29
unsigned int LocalIndex
Definition: indextraits.hh:28