version 3.8
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-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_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
26
27namespace Dumux {
28
35template<class GridView>
37{
38 using Grid = typename GridView::Grid;
39 static constexpr int dim = Grid::dimension;
40 static constexpr int dimWorld = Grid::dimensionworld;
43 using Scalar = typename Grid::ctype;
45 using Geometry = Dune::MultiLinearGeometry<Scalar, dim-1, dimWorld, GeometryTraits>;
46 using CornerStorage = typename GeometryTraits::template CornerStorage<dim-1, dimWorld>::Type;
47 using GlobalPosition = typename Geometry::GlobalCoordinate;
49};
50
58template<class GV,
61: public SubControlVolumeFaceBase<BoxSubControlVolumeFace<GV, T>, T>
62{
65 using GridIndexType = typename T::GridIndexType;
66 using LocalIndexType = typename T::LocalIndexType;
67 using Scalar = typename T::Scalar;
68 using Geometry = typename T::Geometry;
69 using BoundaryFlag = typename T::BoundaryFlag;
70 static constexpr int dim = Geometry::mydimension;
71
72public:
74 using GlobalPosition = typename T::GlobalPosition;
76 using Traits = T;
77
80
82 template<class Corners, class Element>
83 BoxSubControlVolumeFace(const Corners& corners,
85 const Element& element,
86 const typename Element::Geometry& elemGeometry,
87 GridIndexType scvfIndex,
88 std::vector<LocalIndexType>&& scvIndices,
89 bool boundary = false)
90 : center_(Dumux::center(corners))
91 , unitOuterNormal_(normal)
92 , scvfIndex_(scvfIndex)
93 , scvIndices_(std::move(scvIndices))
94 , boundary_(boundary)
95 , boundaryFlag_{}
96 {
97 area_ = Dumux::convexPolytopeVolume<dim>(
98 Dune::GeometryTypes::cube(dim),
99 [&](unsigned int i){ return corners[i]; }
100 );
101 }
102
104 template<class Corners, class Intersection>
105 BoxSubControlVolumeFace(const Corners& corners,
106 const GlobalPosition& normal,
107 const Intersection& intersection,
108 const typename Intersection::Geometry& isGeometry,
109 LocalIndexType indexInIntersection,
110 GridIndexType scvfIndex,
111 std::vector<LocalIndexType>&& scvIndices,
112 bool boundary = false)
113 : center_(Dumux::center(corners))
114 , unitOuterNormal_(normal)
115 , scvfIndex_(scvfIndex)
116 , scvIndices_(std::move(scvIndices))
117 , boundary_(boundary)
118 , boundaryFlag_{intersection}
119 {
120 area_ = Dumux::convexPolytopeVolume<dim>(
121 Dune::GeometryTypes::cube(dim),
122 [&](unsigned int i){ return corners[i]; }
123 );
124 }
125
127 const GlobalPosition& center() const
128 {
129 return center_;
130 }
131
134 {
135 return center_;
136 }
137
139 Scalar area() const
140 {
141 return area_;
142 }
143
145 bool boundary() const
146 {
147 return boundary_;
148 }
149
151 {
152 return unitOuterNormal_;
153 }
154
156 LocalIndexType insideScvIdx() const
157 {
158 return scvIndices_[0];
159 }
160
162 // Results in undefined behaviour if i >= numOutsideScvs()
163 LocalIndexType outsideScvIdx(int i = 0) const
164 {
165 assert(!boundary());
166 return scvIndices_[1];
167 }
168
170 std::size_t numOutsideScvs() const
171 {
172 return static_cast<std::size_t>(!boundary());
173 }
174
176 GridIndexType index() const
177 {
178 return scvfIndex_;
179 }
180
183 {
184 return boundaryFlag_.get();
185 }
186
187private:
188 GlobalPosition center_;
189 GlobalPosition unitOuterNormal_;
190 Scalar area_;
191 GridIndexType scvfIndex_;
192 std::vector<LocalIndexType> scvIndices_;
193 bool boundary_;
194 BoundaryFlag boundaryFlag_;
195};
196
197} // end namespace Dumux
198
199#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:55
std::size_t value_type
Definition: boundaryflag.hh:39
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:62
LocalIndexType outsideScvIdx(int i=0) const
Index of the i-th outside sub control volume or boundary scv index.
Definition: discretization/box/subcontrolvolumeface.hh:163
const GlobalPosition & unitOuterNormal() const
Definition: discretization/box/subcontrolvolumeface.hh:150
T Traits
state the traits public and thus export all types
Definition: discretization/box/subcontrolvolumeface.hh:76
GridIndexType index() const
The local index of this sub control volume face.
Definition: discretization/box/subcontrolvolumeface.hh:176
BoxSubControlVolumeFace(const Corners &corners, const GlobalPosition &normal, const Element &element, const typename Element::Geometry &elemGeometry, GridIndexType scvfIndex, std::vector< LocalIndexType > &&scvIndices, bool boundary=false)
Constructor for inner scvfs.
Definition: discretization/box/subcontrolvolumeface.hh:83
BoxSubControlVolumeFace()=default
The default constructor.
const GlobalPosition & center() const
The center of the sub control volume face.
Definition: discretization/box/subcontrolvolumeface.hh:127
bool boundary() const
returns true if the sub control volume face is on the boundary
Definition: discretization/box/subcontrolvolumeface.hh:145
LocalIndexType insideScvIdx() const
index of the inside sub control volume
Definition: discretization/box/subcontrolvolumeface.hh:156
BoundaryFlag::value_type boundaryFlag() const
Return the boundary flag.
Definition: discretization/box/subcontrolvolumeface.hh:182
std::size_t numOutsideScvs() const
The number of scvs on the outside of this face.
Definition: discretization/box/subcontrolvolumeface.hh:170
BoxSubControlVolumeFace(const Corners &corners, const GlobalPosition &normal, const Intersection &intersection, const typename Intersection::Geometry &isGeometry, LocalIndexType indexInIntersection, GridIndexType scvfIndex, std::vector< LocalIndexType > &&scvIndices, bool boundary=false)
Constructor for boundary scvfs.
Definition: discretization/box/subcontrolvolumeface.hh:105
const GlobalPosition & ipGlobal() const
The integration point for flux evaluations in global coordinates.
Definition: discretization/box/subcontrolvolumeface.hh:133
typename T::GlobalPosition GlobalPosition
export the type used for global coordinates
Definition: discretization/box/subcontrolvolumeface.hh:74
Scalar area() const
The area of the sub control volume face.
Definition: discretization/box/subcontrolvolumeface.hh:139
Base class for a sub control volume face, i.e a part of the boundary of a sub control volume we compu...
Definition: subcontrolvolumefacebase.hh:29
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:37
typename Grid::ctype Scalar
Definition: discretization/box/subcontrolvolumeface.hh:43
typename GridView::Grid Grid
Definition: discretization/box/subcontrolvolumeface.hh:38
typename GeometryTraits::template CornerStorage< dim-1, dimWorld >::Type CornerStorage
Definition: discretization/box/subcontrolvolumeface.hh:46
static constexpr int dimWorld
Definition: discretization/box/subcontrolvolumeface.hh:40
typename IndexTraits< GridView >::LocalIndex LocalIndexType
Definition: discretization/box/subcontrolvolumeface.hh:42
static constexpr int dim
Definition: discretization/box/subcontrolvolumeface.hh:39
typename IndexTraits< GridView >::GridIndex GridIndexType
Definition: discretization/box/subcontrolvolumeface.hh:41
typename Geometry::GlobalCoordinate GlobalPosition
Definition: discretization/box/subcontrolvolumeface.hh:47
Dune::MultiLinearGeometry< Scalar, dim-1, dimWorld, GeometryTraits > Geometry
Definition: discretization/box/subcontrolvolumeface.hh:45
Traits for an efficient corner storage for box method sub control volumes.
Definition: boxgeometryhelper.hh:32
typename GridView::IndexSet::IndexType GridIndex
Definition: indextraits.hh:27
unsigned int LocalIndex
Definition: indextraits.hh:28
Base class for a sub control volume face.
Compute the volume of several common geometry types.