version 3.10-dev
porousmediumflow/boxdfm/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//
13#ifndef DUMUX_POROUSMEDIUMFLOW_BOXDFM_SUBCONTROLVOLUMEFACE_HH
14#define DUMUX_POROUSMEDIUMFLOW_BOXDFM_SUBCONTROLVOLUMEFACE_HH
15
16#include <utility>
17
18#include <dune/geometry/type.hh>
19#include <dune/geometry/multilineargeometry.hh>
20
25
26namespace Dumux {
27
38template<class GridView>
40{
41 using Grid = typename GridView::Grid;
42 static constexpr int dim = Grid::dimension;
43 static constexpr int dimWorld = Grid::dimensionworld;
44 using GridIndexType = typename Grid::LeafGridView::IndexSet::IndexType;
45 using LocalIndexType = unsigned int;
46 using Scalar = typename Grid::ctype;
48 using Geometry = Dune::MultiLinearGeometry<Scalar, dim-1, dimWorld, GeometryTraits>;
49 using CornerStorage = typename GeometryTraits::template CornerStorage<dim-1, dimWorld>::Type;
50 using GlobalPosition = typename CornerStorage::value_type;
52};
53
61template<class GV,
64: public SubControlVolumeFaceBase<BoxDfmSubControlVolumeFace<GV, T>, T>
65{
68 using GridIndexType = typename T::GridIndexType;
69 using LocalIndexType = typename T::LocalIndexType;
70 using Scalar = typename T::Scalar;
71 using GlobalPosition = typename T::GlobalPosition;
72 using Geometry = typename T::Geometry;
73 using BoundaryFlag = typename T::BoundaryFlag;
74
75 static_assert(T::dim == 2 || T::dim == 3, "Box-Dfm sub-control volume face only implemented in 2d or 3d");
76
77public:
79 using Traits = T;
80
83
85 template<class GeometryHelper, class Element>
86 BoxDfmSubControlVolumeFace(const GeometryHelper& geometryHelper,
87 const Element& element,
88 const typename Element::Geometry& elemGeometry,
89 GridIndexType scvfIndex,
90 std::vector<LocalIndexType>&& scvIndices)
91 : center_(0.0)
92 , scvfIndex_(scvfIndex)
93 , scvIndices_(std::move(scvIndices))
94 , boundary_(false)
95 , isFractureScvf_(false)
96 , boundaryFlag_{}
97 , facetIdx_(0)
98 , indexInIntersection_(0)
99 {
100 const auto corners = geometryHelper.getScvfCorners(scvfIndex);
101 unitOuterNormal_ = geometryHelper.normal(corners, scvIndices_);
102 area_ = Dumux::convexPolytopeVolume<T::dim-1>(
103 Dune::GeometryTypes::cube(T::dim-1),
104 [&](unsigned int i){ return corners[i]; });
105
106 for (const auto& corner : corners)
107 center_ += corner;
108 center_ /= corners.size();
109 }
110
112 template<class GeometryHelper, class Intersection>
113 BoxDfmSubControlVolumeFace(const GeometryHelper& geometryHelper,
114 const Intersection& intersection,
115 const typename Intersection::Geometry& isGeometry,
116 LocalIndexType indexInIntersection,
117 GridIndexType scvfIndex,
118 std::vector<LocalIndexType>&& scvIndices)
119 : center_(0.0)
120 , unitOuterNormal_(intersection.centerUnitOuterNormal())
121 , scvfIndex_(scvfIndex)
122 , scvIndices_(std::move(scvIndices))
123 , boundary_(true)
124 , isFractureScvf_(false)
125 , boundaryFlag_{intersection}
126 , facetIdx_(0)
127 , indexInIntersection_(0)
128 {
129 const auto corners = geometryHelper.getBoundaryScvfCorners(intersection.indexInInside(), indexInIntersection);
130 area_ = Dumux::convexPolytopeVolume<T::dim-1>(
131 Dune::GeometryTypes::cube(T::dim-1),
132 [&](unsigned int i){ return corners[i]; });
133 for (const auto& corner : corners)
134 center_ += corner;
135 center_ /= corners.size();
136 }
137
139 template<class GeometryHelper, class Intersection>
140 BoxDfmSubControlVolumeFace(const GeometryHelper& geometryHelper,
141 const Intersection& intersection,
142 const typename Intersection::Geometry& isGeometry,
143 LocalIndexType indexInIntersection,
144 GridIndexType scvfIndex,
145 std::vector<LocalIndexType>&& scvIndices,
146 bool boundary)
147 : center_(0.0)
148 , scvfIndex_(scvfIndex)
149 , scvIndices_(std::move(scvIndices))
150 , boundary_(boundary)
151 , isFractureScvf_(true)
152 , boundaryFlag_{intersection}
153 , facetIdx_(intersection.indexInInside())
154 , indexInIntersection_(indexInIntersection)
155 {
156 const auto corners = geometryHelper.getFractureScvfCorners(intersection.indexInInside(), indexInIntersection);
157 // The area here is given in meters. In order to
158 // get the right dimensions, the user has to provide
159 // the appropriate aperture in the problem (via an extrusion factor)
160 if (T::dim == 3)
161 area_ = (corners[1]-corners[0]).two_norm();
162 else if (T::dim == 2)
163 area_ = 1.0;
164
165 // obtain the unit normal vector
166 unitOuterNormal_ = geometryHelper.fractureNormal(corners, intersection, indexInIntersection);
167
168 // compute the scvf center
169 for (const auto& corner : corners)
170 center_ += corner;
171 center_ /= corners.size();
172 }
173
175 const GlobalPosition& center() const
176 { return center_; }
177
179 const GlobalPosition& ipGlobal() const
180 { return center_; }
181
183 Scalar area() const
184 { return area_; }
185
187 bool boundary() const
188 { return boundary_; }
189
191 const GlobalPosition& unitOuterNormal() const
192 { return unitOuterNormal_; }
193
195 GridIndexType index() const
196 { return scvfIndex_; }
197
199 bool isOnFracture() const
200 { return isFractureScvf_; }
201
203 LocalIndexType facetIndexInElement() const
204 { assert(isFractureScvf_); return facetIdx_; }
205
207 LocalIndexType indexInIntersection() const
208 { assert(isFractureScvf_); return indexInIntersection_; }
209
212 { return boundaryFlag_.get(); }
213
215 LocalIndexType insideScvIdx() const
216 { return scvIndices_[0]; }
217
219 // Results in undefined behaviour if i >= numOutsideScvs()
220 LocalIndexType outsideScvIdx(int i = 0) const
221 {
222 assert(!boundary());
223 return scvIndices_[1];
224 }
225
227 std::size_t numOutsideScvs() const
228 {
229 return static_cast<std::size_t>(!boundary());
230 }
231
232private:
233 GlobalPosition center_;
234 GlobalPosition unitOuterNormal_;
235 Scalar area_;
236 GridIndexType scvfIndex_;
237 std::vector<LocalIndexType> scvIndices_;
238 bool boundary_;
239 bool isFractureScvf_;
240 BoundaryFlag boundaryFlag_;
241 LocalIndexType facetIdx_;
242 LocalIndexType indexInIntersection_;
243};
244
245} // end namespace Dumux
246
247#endif
Boundary flag to store e.g. in sub control volume faces.
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 discrete fracture method, i.e a part of the boundary o...
Definition: porousmediumflow/boxdfm/subcontrolvolumeface.hh:65
BoxDfmSubControlVolumeFace(const GeometryHelper &geometryHelper, const Intersection &intersection, const typename Intersection::Geometry &isGeometry, LocalIndexType indexInIntersection, GridIndexType scvfIndex, std::vector< LocalIndexType > &&scvIndices, bool boundary)
Constructor for inner fracture scvfs.
Definition: porousmediumflow/boxdfm/subcontrolvolumeface.hh:140
std::size_t numOutsideScvs() const
The number of scvs on the outside of this face.
Definition: porousmediumflow/boxdfm/subcontrolvolumeface.hh:227
const GlobalPosition & unitOuterNormal() const
returns the unit normal vector pointing outwards
Definition: porousmediumflow/boxdfm/subcontrolvolumeface.hh:191
BoxDfmSubControlVolumeFace(const GeometryHelper &geometryHelper, const Intersection &intersection, const typename Intersection::Geometry &isGeometry, LocalIndexType indexInIntersection, GridIndexType scvfIndex, std::vector< LocalIndexType > &&scvIndices)
Constructor for boundary scvfs.
Definition: porousmediumflow/boxdfm/subcontrolvolumeface.hh:113
BoundaryFlag::value_type boundaryFlag() const
Returns the boundary flag.
Definition: porousmediumflow/boxdfm/subcontrolvolumeface.hh:211
LocalIndexType indexInIntersection() const
The local edge index inside the intersection.
Definition: porousmediumflow/boxdfm/subcontrolvolumeface.hh:207
LocalIndexType insideScvIdx() const
index of the inside sub control volume
Definition: porousmediumflow/boxdfm/subcontrolvolumeface.hh:215
const GlobalPosition & ipGlobal() const
The integration point for flux evaluations in global coordinates.
Definition: porousmediumflow/boxdfm/subcontrolvolumeface.hh:179
const GlobalPosition & center() const
The center of the sub control volume face.
Definition: porousmediumflow/boxdfm/subcontrolvolumeface.hh:175
LocalIndexType facetIndexInElement() const
The element-local facet index for which a fracture scv was created.
Definition: porousmediumflow/boxdfm/subcontrolvolumeface.hh:203
BoxDfmSubControlVolumeFace()=default
The default constructor.
bool isOnFracture() const
Return if this is a fracture scvf.
Definition: porousmediumflow/boxdfm/subcontrolvolumeface.hh:199
bool boundary() const
returns true if the sub control volume face is on the boundary
Definition: porousmediumflow/boxdfm/subcontrolvolumeface.hh:187
BoxDfmSubControlVolumeFace(const GeometryHelper &geometryHelper, const Element &element, const typename Element::Geometry &elemGeometry, GridIndexType scvfIndex, std::vector< LocalIndexType > &&scvIndices)
Constructor for inner scvfs.
Definition: porousmediumflow/boxdfm/subcontrolvolumeface.hh:86
T Traits
State the traits public and thus export all types.
Definition: porousmediumflow/boxdfm/subcontrolvolumeface.hh:79
LocalIndexType outsideScvIdx(int i=0) const
Index of the i-th outside sub control volume or boundary scv index.
Definition: porousmediumflow/boxdfm/subcontrolvolumeface.hh:220
GridIndexType index() const
The global index of this sub control volume face.
Definition: porousmediumflow/boxdfm/subcontrolvolumeface.hh:195
Scalar area() const
The area of the sub control volume face.
Definition: porousmediumflow/boxdfm/subcontrolvolumeface.hh:183
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
auto convexPolytopeVolume(Dune::GeometryType type, const CornerF &c)
Compute the volume of several common geometry types.
Definition: volume.hh:41
Definition: adapt.hh:17
Helper class constructing the dual grid finite volume geometries for the box discrete fracture model.
Default traits class to be used for the sub-control volume faces for the box discrete fracture scheme...
Definition: porousmediumflow/boxdfm/subcontrolvolumeface.hh:40
static constexpr int dim
Definition: porousmediumflow/boxdfm/subcontrolvolumeface.hh:42
Dune::MultiLinearGeometry< Scalar, dim-1, dimWorld, GeometryTraits > Geometry
Definition: porousmediumflow/boxdfm/subcontrolvolumeface.hh:48
typename Grid::LeafGridView::IndexSet::IndexType GridIndexType
Definition: porousmediumflow/boxdfm/subcontrolvolumeface.hh:44
typename GeometryTraits::template CornerStorage< dim-1, dimWorld >::Type CornerStorage
Definition: porousmediumflow/boxdfm/subcontrolvolumeface.hh:49
static constexpr int dimWorld
Definition: porousmediumflow/boxdfm/subcontrolvolumeface.hh:43
typename CornerStorage::value_type GlobalPosition
Definition: porousmediumflow/boxdfm/subcontrolvolumeface.hh:50
typename Grid::ctype Scalar
Definition: porousmediumflow/boxdfm/subcontrolvolumeface.hh:46
typename GridView::Grid Grid
Definition: porousmediumflow/boxdfm/subcontrolvolumeface.hh:41
unsigned int LocalIndexType
Definition: porousmediumflow/boxdfm/subcontrolvolumeface.hh:45
Definition: porousmediumflow/boxdfm/geometryhelper.hh:26
Base class for a sub control volume face.
Compute the volume of several common geometry types.