3.6-git
DUNE for Multi-{Phase, Component, Scale, Physics, ...} flow and transport in porous media
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 * 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 *****************************************************************************/
25#ifndef DUMUX_POROUSMEDIUMFLOW_BOXDFM_SUBCONTROLVOLUMEFACE_HH
26#define DUMUX_POROUSMEDIUMFLOW_BOXDFM_SUBCONTROLVOLUMEFACE_HH
27
28#include <utility>
29
30#include <dune/geometry/type.hh>
31#include <dune/geometry/multilineargeometry.hh>
32
37
38namespace Dumux {
39
50template<class GridView>
52{
53 using Grid = typename GridView::Grid;
54 static constexpr int dim = Grid::dimension;
55 static constexpr int dimWorld = Grid::dimensionworld;
56 using GridIndexType = typename Grid::LeafGridView::IndexSet::IndexType;
57 using LocalIndexType = unsigned int;
58 using Scalar = typename Grid::ctype;
60 using Geometry = Dune::MultiLinearGeometry<Scalar, dim-1, dimWorld, GeometryTraits>;
61 using CornerStorage = typename GeometryTraits::template CornerStorage<dim-1, dimWorld>::Type;
62 using GlobalPosition = typename CornerStorage::value_type;
64};
65
73template<class GV,
76: public SubControlVolumeFaceBase<BoxDfmSubControlVolumeFace<GV, T>, T>
77{
80 using GridIndexType = typename T::GridIndexType;
81 using LocalIndexType = typename T::LocalIndexType;
82 using Scalar = typename T::Scalar;
83 using GlobalPosition = typename T::GlobalPosition;
84 using CornerStorage = typename T::CornerStorage;
85 using Geometry = typename T::Geometry;
86 using BoundaryFlag = typename T::BoundaryFlag;
87
88 static_assert(T::dim == 2 || T::dim == 3, "Box-Dfm sub-control volume face only implemented in 2d or 3d");
89
90public:
92 using Traits = T;
93
96
98 template<class GeometryHelper, class Element>
99 BoxDfmSubControlVolumeFace(const GeometryHelper& geometryHelper,
100 const Element& element,
101 const typename Element::Geometry& elemGeometry,
102 GridIndexType scvfIndex,
103 std::vector<LocalIndexType>&& scvIndices)
104 : corners_(geometryHelper.getScvfCorners(scvfIndex))
105 , center_(0.0)
106 , unitOuterNormal_(geometryHelper.normal(corners_, scvIndices))
107 , area_(Dumux::convexPolytopeVolume<T::dim-1>(
108 Dune::GeometryTypes::cube(T::dim-1),
109 [&](unsigned int i){ return corners_[i]; })
110 )
111 , scvfIndex_(scvfIndex)
112 , scvIndices_(std::move(scvIndices))
113 , boundary_(false)
114 , isFractureScvf_(false)
115 , boundaryFlag_{}
116 , facetIdx_(0)
117 {
118 for (const auto& corner : corners_)
119 center_ += corner;
120 center_ /= corners_.size();
121 }
122
124 template<class GeometryHelper, class Intersection>
125 BoxDfmSubControlVolumeFace(const GeometryHelper& geometryHelper,
126 const Intersection& intersection,
127 const typename Intersection::Geometry& isGeometry,
128 LocalIndexType indexInIntersection,
129 GridIndexType scvfIndex,
130 std::vector<LocalIndexType>&& scvIndices)
131 : corners_(geometryHelper.getBoundaryScvfCorners(intersection.indexInInside(), indexInIntersection))
132 , center_(0.0)
133 , unitOuterNormal_(intersection.centerUnitOuterNormal())
134 , area_(Dumux::convexPolytopeVolume<T::dim-1>(
135 Dune::GeometryTypes::cube(T::dim-1),
136 [&](unsigned int i){ return corners_[i]; })
137 )
138 , scvfIndex_(scvfIndex)
139 , scvIndices_(std::move(scvIndices))
140 , boundary_(true)
141 , isFractureScvf_(false)
142 , boundaryFlag_{intersection}
143 , facetIdx_(0)
144 {
145 for (const auto& corner : corners_)
146 center_ += corner;
147 center_ /= corners_.size();
148 }
149
151 template<class GeometryHelper, class Intersection>
152 BoxDfmSubControlVolumeFace(const GeometryHelper& geometryHelper,
153 const Intersection& intersection,
154 const typename Intersection::Geometry& isGeometry,
155 LocalIndexType indexInIntersection,
156 GridIndexType scvfIndex,
157 std::vector<LocalIndexType>&& scvIndices,
158 bool boundary)
159 : corners_(geometryHelper.getFractureScvfCorners(intersection.indexInInside(), indexInIntersection))
160 , center_(0.0)
161 , scvfIndex_(scvfIndex)
162 , scvIndices_(std::move(scvIndices))
163 , boundary_(boundary)
164 , isFractureScvf_(true)
165 , boundaryFlag_{intersection}
166 , facetIdx_(intersection.indexInInside())
167 {
168 // The area here is given in meters. In order to
169 // get the right dimensions, the user has to provide
170 // the appropriate aperture in the problem (via an extrusion factor)
171 if (T::dim == 3)
172 area_ = (corners_[1]-corners_[0]).two_norm();
173 else if (T::dim == 2)
174 area_ = 1.0;
175
176 // obtain the unit normal vector
177 unitOuterNormal_ = geometryHelper.fractureNormal(corners_, intersection, indexInIntersection);
178
179 // compute the scvf center
180 for (const auto& corner : corners_)
181 center_ += corner;
182 center_ /= corners_.size();
183 }
184
186 const GlobalPosition& center() const
187 { return center_; }
188
190 const GlobalPosition& ipGlobal() const
191 { return center_; }
192
194 Scalar area() const
195 { return area_; }
196
198 bool boundary() const
199 { return boundary_; }
200
202 const GlobalPosition& unitOuterNormal() const
203 { return unitOuterNormal_; }
204
206 GridIndexType index() const
207 { return scvfIndex_; }
208
210 bool isOnFracture() const
211 { return isFractureScvf_; }
212
214 LocalIndexType facetIndexInElement() const
215 { assert(isFractureScvf_); return facetIdx_; }
216
219 { return boundaryFlag_.get(); }
220
222 LocalIndexType insideScvIdx() const
223 { return scvIndices_[0]; }
224
226 // Results in undefined behaviour if i >= numOutsideScvs()
227 LocalIndexType outsideScvIdx(int i = 0) const
228 {
229 assert(!boundary());
230 return scvIndices_[1];
231 }
232
234 std::size_t numOutsideScvs() const
235 {
236 return static_cast<std::size_t>(!boundary());
237 }
238
240 const GlobalPosition& corner(unsigned int localIdx) const
241 {
242 assert(localIdx < corners_.size() && "provided index exceeds the number of corners");
243 return corners_[localIdx];
244 }
245
247 Geometry geometry() const
248 {
249 if (isFractureScvf_)
250 DUNE_THROW(Dune::InvalidStateException, "The geometry object cannot be defined for fracture scvs "
251 "because the number of known corners is insufficient. "
252 "You can do this manually by extract the corners from this scv "
253 "and extrude them by the corresponding aperture. ");
254
255 return Geometry(Dune::GeometryTypes::cube(Geometry::mydimension), corners_);
256 }
257
258private:
259 CornerStorage corners_;
260 GlobalPosition center_;
261 GlobalPosition unitOuterNormal_;
262 Scalar area_;
263 GridIndexType scvfIndex_;
264 std::vector<LocalIndexType> scvIndices_;
265 bool boundary_;
266 bool isFractureScvf_;
267 BoundaryFlag boundaryFlag_;
268 LocalIndexType facetIdx_;
269};
270
271} // end namespace Dumux
272
273#endif
Boundary flag to store e.g. in sub control volume faces.
Base class for a sub control volume face.
Compute the volume of several common geometry types.
Vector normal(const Vector &v)
Create a vector normal to the given one (v is expected to be non-zero)
Definition: normal.hh:38
auto convexPolytopeVolume(Dune::GeometryType type, const CornerF &c)
Compute the volume of several common geometry types.
Definition: volume.hh:53
Adaption of the non-isothermal two-phase two-component flow model to problems with CO2.
Definition: adapt.hh:29
Definition: deprecated.hh:149
std::size_t value_type
Definition: boundaryflag.hh:51
Boundary flag to store e.g. in sub control volume faces.
Definition: boundaryflag.hh:67
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:41
Definition: porousmediumflow/boxdfm/geometryhelper.hh:38
Default traits class to be used for the sub-control volume faces for the box discrete fracture scheme...
Definition: porousmediumflow/boxdfm/subcontrolvolumeface.hh:52
static constexpr int dim
Definition: porousmediumflow/boxdfm/subcontrolvolumeface.hh:54
Dune::MultiLinearGeometry< Scalar, dim-1, dimWorld, GeometryTraits > Geometry
Definition: porousmediumflow/boxdfm/subcontrolvolumeface.hh:60
typename Grid::LeafGridView::IndexSet::IndexType GridIndexType
Definition: porousmediumflow/boxdfm/subcontrolvolumeface.hh:56
typename GeometryTraits::template CornerStorage< dim-1, dimWorld >::Type CornerStorage
Definition: porousmediumflow/boxdfm/subcontrolvolumeface.hh:61
static constexpr int dimWorld
Definition: porousmediumflow/boxdfm/subcontrolvolumeface.hh:55
typename CornerStorage::value_type GlobalPosition
Definition: porousmediumflow/boxdfm/subcontrolvolumeface.hh:62
typename Grid::ctype Scalar
Definition: porousmediumflow/boxdfm/subcontrolvolumeface.hh:58
typename GridView::Grid Grid
Definition: porousmediumflow/boxdfm/subcontrolvolumeface.hh:53
unsigned int LocalIndexType
Definition: porousmediumflow/boxdfm/subcontrolvolumeface.hh:57
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:77
const GlobalPosition & corner(unsigned int localIdx) const
Returns a corner of the sub control volume face.
Definition: porousmediumflow/boxdfm/subcontrolvolumeface.hh:240
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:152
std::size_t numOutsideScvs() const
The number of scvs on the outside of this face.
Definition: porousmediumflow/boxdfm/subcontrolvolumeface.hh:234
const GlobalPosition & unitOuterNormal() const
returns the unit normal vector pointing outwards
Definition: porousmediumflow/boxdfm/subcontrolvolumeface.hh:202
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:125
BoundaryFlag::value_type boundaryFlag() const
Returns the boundary flag.
Definition: porousmediumflow/boxdfm/subcontrolvolumeface.hh:218
LocalIndexType insideScvIdx() const
index of the inside sub control volume
Definition: porousmediumflow/boxdfm/subcontrolvolumeface.hh:222
const GlobalPosition & ipGlobal() const
The integration point for flux evaluations in global coordinates.
Definition: porousmediumflow/boxdfm/subcontrolvolumeface.hh:190
const GlobalPosition & center() const
The center of the sub control volume face.
Definition: porousmediumflow/boxdfm/subcontrolvolumeface.hh:186
LocalIndexType facetIndexInElement() const
The element-local facet index for which a fracture scv was created.
Definition: porousmediumflow/boxdfm/subcontrolvolumeface.hh:214
BoxDfmSubControlVolumeFace()=default
The default constructor.
bool isOnFracture() const
Return if this is a fracture scvf.
Definition: porousmediumflow/boxdfm/subcontrolvolumeface.hh:210
bool boundary() const
returns true if the sub control volume face is on the boundary
Definition: porousmediumflow/boxdfm/subcontrolvolumeface.hh:198
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:99
T Traits
State the traits public and thus export all types.
Definition: porousmediumflow/boxdfm/subcontrolvolumeface.hh:92
LocalIndexType outsideScvIdx(int i=0) const
Index of the i-th outside sub control volume or boundary scv index.
Definition: porousmediumflow/boxdfm/subcontrolvolumeface.hh:227
Geometry geometry() const
The geometry of the sub control volume face.
Definition: porousmediumflow/boxdfm/subcontrolvolumeface.hh:247
GridIndexType index() const
The global index of this sub control volume face.
Definition: porousmediumflow/boxdfm/subcontrolvolumeface.hh:206
Scalar area() const
The area of the sub control volume face.
Definition: porousmediumflow/boxdfm/subcontrolvolumeface.hh:194
Helper class constructing the dual grid finite volume geometries for the box discrete fracture model.