version 3.11-dev
discretization/box/subcontrolvolumeface.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-FileCopyrightText: Copyright © DuMux Project contributors, see AUTHORS.md in root folder
5// SPDX-License-Identifier: GPL-3.0-or-later
6//
12#ifndef DUMUX_DISCRETIZATION_BOX_SUBCONTROLVOLUMEFACE_HH
13#define DUMUX_DISCRETIZATION_BOX_SUBCONTROLVOLUMEFACE_HH
14
15#include <utility>
16
17#include <dune/geometry/type.hh>
18#include <dune/geometry/multilineargeometry.hh>
19
25
26namespace Dumux {
27
34template<class GridView>
36{
37 using Grid = typename GridView::Grid;
38 static constexpr int dim = Grid::dimension;
39 static constexpr int dimWorld = Grid::dimensionworld;
42 using Scalar = typename Grid::ctype;
44 using Geometry = Dune::MultiLinearGeometry<Scalar, dim-1, dimWorld, GeometryTraits>;
45 using CornerStorage = typename GeometryTraits::template CornerStorage<dim-1, dimWorld>::Type;
46 using GlobalPosition = typename Geometry::GlobalCoordinate;
48};
49
57template<class GV,
60{
62 using GridIndexType = typename T::GridIndexType;
63 using LocalIndexType = typename T::LocalIndexType;
64 using Scalar = typename T::Scalar;
65 using Geometry = typename T::Geometry;
66 using BoundaryFlag = typename T::BoundaryFlag;
67 static constexpr int dim = Geometry::mydimension;
68
69public:
71 using GlobalPosition = typename T::GlobalPosition;
73 using Traits = T;
74
77
79 template<class Corners, class Element>
80 BoxSubControlVolumeFace(const Corners& corners,
82 const Element& element,
83 GridIndexType scvfIndex,
84 std::array<LocalIndexType, 2>&& scvIndices)
85 : center_(Dumux::center(corners))
86 , unitOuterNormal_(normal)
87 , scvfIndex_(scvfIndex)
88 , scvIndices_(std::move(scvIndices))
89 , boundaryFlag_{}
90 {
91 area_ = Dumux::convexPolytopeVolume<dim>(
92 Dune::GeometryTypes::cube(dim),
93 [&](unsigned int i){ return corners[i]; }
94 );
95 }
96
98 template<class Corners, class Intersection>
99 BoxSubControlVolumeFace(const Corners& corners,
100 const GlobalPosition& normal,
101 const Intersection& intersection,
102 LocalIndexType indexInIntersection,
103 GridIndexType scvfIndex,
104 std::array<LocalIndexType, 2>&& scvIndices)
105 : center_(Dumux::center(corners))
106 , unitOuterNormal_(normal)
107 , scvfIndex_(scvfIndex)
108 , scvIndices_(std::move(scvIndices))
109 , boundaryFlag_{intersection}
110 {
111 area_ = Dumux::convexPolytopeVolume<dim>(
112 Dune::GeometryTypes::cube(dim),
113 [&](unsigned int i){ return corners[i]; }
114 );
115 }
116
118 const GlobalPosition& center() const
119 {
120 return center_;
121 }
122
125 {
126 return center_;
127 }
128
130 Scalar area() const
131 {
132 return area_;
133 }
134
136 bool boundary() const
137 {
138 return static_cast<bool>(boundaryFlag_);
139 }
140
142 {
143 return unitOuterNormal_;
144 }
145
147 LocalIndexType insideScvIdx() const
148 {
149 return scvIndices_[0];
150 }
151
153 // Results in undefined behaviour if i >= numOutsideScvs()
154 LocalIndexType outsideScvIdx(int i = 0) const
155 {
156 assert(!boundary());
157 return scvIndices_[1];
158 }
159
161 std::size_t numOutsideScvs() const
162 {
163 return static_cast<std::size_t>(!boundary());
164 }
165
167 GridIndexType index() const
168 {
169 return scvfIndex_;
170 }
171
174 {
175 return boundaryFlag_.get();
176 }
177
178private:
179 GlobalPosition center_;
180 GlobalPosition unitOuterNormal_;
181 Scalar area_;
182 GridIndexType scvfIndex_;
183 std::array<LocalIndexType, 2> scvIndices_;
184 BoundaryFlag boundaryFlag_;
185};
186
187} // end namespace Dumux
188
189#endif
Boundary flag to store e.g. in sub control volume faces.
Helper class constructing the dual grid finite volume geometries for the box discretizazion method.
Compute the center point of a convex polytope geometry or a random-access container of corner points.
Boundary flag to store e.g. in sub control volume faces.
Definition: boundaryflag.hh:58
std::size_t value_type
Definition: boundaryflag.hh:28
Class for a sub control volume face in the box method, i.e a part of the boundary of a sub control vo...
Definition: discretization/box/subcontrolvolumeface.hh:60
BoxSubControlVolumeFace(const Corners &corners, const GlobalPosition &normal, const Element &element, GridIndexType scvfIndex, std::array< LocalIndexType, 2 > &&scvIndices)
Constructor for inner scvfs.
Definition: discretization/box/subcontrolvolumeface.hh:80
LocalIndexType outsideScvIdx(int i=0) const
Index of the i-th outside sub control volume or boundary scv index.
Definition: discretization/box/subcontrolvolumeface.hh:154
const GlobalPosition & unitOuterNormal() const
Definition: discretization/box/subcontrolvolumeface.hh:141
T Traits
state the traits public and thus export all types
Definition: discretization/box/subcontrolvolumeface.hh:73
GridIndexType index() const
The local index of this sub control volume face.
Definition: discretization/box/subcontrolvolumeface.hh:167
BoxSubControlVolumeFace(const Corners &corners, const GlobalPosition &normal, const Intersection &intersection, LocalIndexType indexInIntersection, GridIndexType scvfIndex, std::array< LocalIndexType, 2 > &&scvIndices)
Constructor for boundary scvfs.
Definition: discretization/box/subcontrolvolumeface.hh:99
BoxSubControlVolumeFace()=default
The default constructor.
const GlobalPosition & center() const
The center of the sub control volume face.
Definition: discretization/box/subcontrolvolumeface.hh:118
bool boundary() const
returns true if the sub control volume face is on the boundary
Definition: discretization/box/subcontrolvolumeface.hh:136
LocalIndexType insideScvIdx() const
index of the inside sub control volume
Definition: discretization/box/subcontrolvolumeface.hh:147
BoundaryFlag::value_type boundaryFlag() const
Return the boundary flag.
Definition: discretization/box/subcontrolvolumeface.hh:173
std::size_t numOutsideScvs() const
The number of scvs on the outside of this face.
Definition: discretization/box/subcontrolvolumeface.hh:161
const GlobalPosition & ipGlobal() const
The integration point for flux evaluations in global coordinates.
Definition: discretization/box/subcontrolvolumeface.hh:124
typename T::GlobalPosition GlobalPosition
export the type used for global coordinates
Definition: discretization/box/subcontrolvolumeface.hh:71
Scalar area() const
The area of the sub control volume face.
Definition: discretization/box/subcontrolvolumeface.hh:130
Vector normal(const Vector &v)
Create a vector normal to the given one (v is expected to be non-zero)
Definition: normal.hh:26
Defines the index types used for grid and local indices.
Definition: adapt.hh:17
Default traits class to be used for the sub-control volume faces for the box scheme.
Definition: discretization/box/subcontrolvolumeface.hh:36
typename Grid::ctype Scalar
Definition: discretization/box/subcontrolvolumeface.hh:42
typename GridView::Grid Grid
Definition: discretization/box/subcontrolvolumeface.hh:37
typename GeometryTraits::template CornerStorage< dim-1, dimWorld >::Type CornerStorage
Definition: discretization/box/subcontrolvolumeface.hh:45
static constexpr int dimWorld
Definition: discretization/box/subcontrolvolumeface.hh:39
typename IndexTraits< GridView >::LocalIndex LocalIndexType
Definition: discretization/box/subcontrolvolumeface.hh:41
static constexpr int dim
Definition: discretization/box/subcontrolvolumeface.hh:38
typename IndexTraits< GridView >::GridIndex GridIndexType
Definition: discretization/box/subcontrolvolumeface.hh:40
typename Geometry::GlobalCoordinate GlobalPosition
Definition: discretization/box/subcontrolvolumeface.hh:46
Dune::MultiLinearGeometry< Scalar, dim-1, dimWorld, GeometryTraits > Geometry
Definition: discretization/box/subcontrolvolumeface.hh:44
Traits for an efficient corner storage for box method sub control volumes.
Definition: boxgeometryhelper.hh:33
typename GridView::IndexSet::IndexType GridIndex
Definition: indextraits.hh:27
unsigned int LocalIndex
Definition: indextraits.hh:28
Compute the volume of several common geometry types.