3.6-git
DUNE for Multi-{Phase, Component, Scale, Physics, ...} flow and transport in porous media
porousmediumflow/boxdfm/geometryhelper.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_GEOMETRY_HELPER_HH
26#define DUMUX_POROUSMEDIUMFLOW_BOXDFM_GEOMETRY_HELPER_HH
27
28#include <dune/common/fvector.hh>
29#include <dune/common/reservedvector.hh>
30#include <dune/geometry/multilineargeometry.hh>
31
33
34namespace Dumux {
35
36template <class ct>
37struct BoxDfmMLGeometryTraits : public Dune::MultiLinearGeometryTraits<ct>
38{
39 // we use static vectors to store the corners as we know
40 // the number of corners in advance (2^(mydim) corners (1<<(mydim))
41 // However, on fracture scvs the number might be smaller (use ReservedVector)
42 template< int mydim, int cdim >
44 {
45 using Type = Dune::ReservedVector< Dune::FieldVector< ct, cdim >, (1<<(mydim)) >;
46 };
47
48 // we know all scvfs will have the same geometry type
49 template< int mydim >
51 {
52 static const bool v = true;
53 static const unsigned int topologyId = Dune::GeometryTypes::cube(mydim).id();
54 };
55};
56
58template<class GridView, int dim, class ScvType, class ScvfType>
60
62template <class GridView, class ScvType, class ScvfType>
63class BoxDfmGeometryHelper<GridView, 2, ScvType, ScvfType> : public BoxGeometryHelper<GridView, 2, ScvType, ScvfType>
64{
66
67 using Intersection = typename GridView::Intersection;
68 using ScvfCornerStorage = typename ScvfType::Traits::CornerStorage;
69
70 static constexpr auto dim = GridView::dimension;
71 using Scalar = typename GridView::ctype;
72
73public:
74
76 using ParentType::ParentType;
77
79 ScvfCornerStorage getFractureScvfCorners(unsigned int localFacetIndex,
80 unsigned int) const
81 {
82 const auto& geo = this->elementGeometry();
83 const auto ref = referenceElement(geo);
84 return ScvfCornerStorage({ geo.global(ref.position(localFacetIndex, 1)) });
85 }
86
88 [[deprecated("Will be removed after release 3.6. Use other signature.")]]
89 ScvfCornerStorage getFractureScvfCorners(const Intersection& is,
90 const typename Intersection::Geometry& isGeom,
91 unsigned int idxOnIntersection = 0) const
92 {
93 return getFractureScvfCorners(is.indexInInside(), idxOnIntersection);
94 }
95
98 typename ScvfType::Traits::GlobalPosition
99 fractureNormal(const ScvfCornerStorage& p,
100 const Intersection& is,
101 unsigned int edgeIndexInIntersection) const
102 {
103 const auto& geo = this->elementGeometry();
104 const auto ref = referenceElement(geo);
105 const auto v0 = ref.subEntity(is.indexInInside(), 1, 0, dim);
106 const auto v1 = ref.subEntity(is.indexInInside(), 1, 1, dim);
107 auto normal = geo.corner(v1) - geo.corner(v0);
108 normal /= normal.two_norm();
109 return normal;
110 }
111};
112
114template <class GridView, class ScvType, class ScvfType>
115class BoxDfmGeometryHelper<GridView, 3, ScvType, ScvfType> : public BoxGeometryHelper<GridView, 3, ScvType, ScvfType>
116{
118
119 using Intersection = typename GridView::Intersection;
120 using ScvfCornerStorage = typename ScvfType::Traits::CornerStorage;
121
122 static constexpr auto dim = GridView::dimension;
123 static constexpr auto dimWorld = GridView::dimensionworld;
124 using Scalar = typename GridView::ctype;
125
126public:
127
129 using ParentType::ParentType;
130
132 ScvfCornerStorage getFractureScvfCorners(unsigned int localFacetIndex,
133 unsigned int indexInFacet) const
134 {
135 constexpr int facetCodim = 1;
136
137 // we have to use the corresponding facet geometry as the intersection geometry
138 // might be rotated or flipped. This makes sure that the corners (dof location)
139 // and corresponding scvfs are sorted in the same way
140 using Dune::referenceElement;
141 const auto& geo = this->elementGeometry();
142 const auto type = referenceElement(geo).type(localFacetIndex, facetCodim);
143 if (type == Dune::GeometryTypes::triangle)
144 {
146 return Detail::Box::subEntityKeyToCornerStorage<ScvfCornerStorage>(geo, localFacetIndex, facetCodim, Corners::keys[indexInFacet]);
147 }
148 else if (type == Dune::GeometryTypes::quadrilateral)
149 {
151 return Detail::Box::subEntityKeyToCornerStorage<ScvfCornerStorage>(geo, localFacetIndex, facetCodim, Corners::keys[indexInFacet]);
152 }
153 else
154 DUNE_THROW(Dune::NotImplemented, "Box fracture scvf geometries for dim=" << dim
155 << " dimWorld=" << dimWorld
156 << " type=" << type);
157 }
158
160 [[deprecated("Will be removed after release 3.6. Use other signature.")]]
161 ScvfCornerStorage getFractureScvfCorners(const Intersection& is,
162 const typename Intersection::Geometry& isGeom,
163 unsigned int edgeIndexInIntersection) const
164 {
165 return getFractureScvfCorners(is.indexInInside(), edgeIndexInIntersection);
166 }
167
169 typename ScvfType::Traits::GlobalPosition
170 fractureNormal(const ScvfCornerStorage& scvfCorners,
171 const Intersection& is,
172 unsigned int edgeIndexInIntersection) const
173 {
174 const auto& geo = this->elementGeometry();
175 const auto refElement = referenceElement(geo);
176
177 // first get the intersection corners (maximum "4" is for quadrilateral face)
178 typename ScvfType::Traits::GlobalPosition c[4];
179
180 const auto corners = refElement.size(is.indexInInside(), 1, dim);
181 for (int i = 0; i < corners; ++i)
182 {
183 const auto vIdxLocal = refElement.subEntity(is.indexInInside(), 1, i, dim);
184 c[i] = geo.corner(vIdxLocal);
185 }
186
187 // compute edge vector depending on number of corners
188 const auto gridEdge = [&] ()
189 {
190 // triangles
191 if (corners == 3)
192 {
193 if (edgeIndexInIntersection == 0) return c[1]-c[0];
194 else if (edgeIndexInIntersection == 1) return c[2]-c[0];
195 else if (edgeIndexInIntersection == 2) return c[2]-c[1];
196 else DUNE_THROW(Dune::InvalidStateException, "Invalid edge index");
197 }
198 else if (corners == 4)
199 {
200 if (edgeIndexInIntersection == 0) return c[2]-c[0];
201 else if (edgeIndexInIntersection == 1) return c[3]-c[1];
202 else if (edgeIndexInIntersection == 2) return c[1]-c[0];
203 else if (edgeIndexInIntersection == 3) return c[3]-c[2];
204 else DUNE_THROW(Dune::InvalidStateException, "Invalid edge index");
205 }
206 else
207 DUNE_THROW(Dune::InvalidStateException, "Invalid face geometry");
208 } ();
209
210 // compute lower edge of the scvf
211 assert(scvfCorners.size() == 2);
212 const auto scvfEdge = scvfCorners[1]-scvfCorners[0];
213
214 // compute scvf normal via 2 cross products
215 const auto faceN = crossProduct(gridEdge, scvfEdge);
216 auto n = crossProduct(scvfEdge, faceN);
217 n /= n.two_norm();
218 return n;
219 }
220};
221
222} // end namespace Dumux
223
224#endif
Helper class constructing the dual grid finite volume geometries for the box discretizazion method.
Vector normal(const Vector &v)
Create a vector normal to the given one (v is expected to be non-zero)
Definition: normal.hh:38
Dune::FieldVector< Scalar, 3 > crossProduct(const Dune::FieldVector< Scalar, 3 > &vec1, const Dune::FieldVector< Scalar, 3 > &vec2)
Cross product of two vectors in three-dimensional Euclidean space.
Definition: math.hh:654
Adaption of the non-isothermal two-phase two-component flow model to problems with CO2.
Definition: adapt.hh:29
Create sub control volumes and sub control volume face geometries.
Definition: boxgeometryhelper.hh:269
A class to create sub control volume and sub control volume face geometries per element.
Definition: boxgeometryhelper.hh:374
A class to create sub control volume and sub control volume face geometries per element.
Definition: boxgeometryhelper.hh:547
Definition: porousmediumflow/boxdfm/geometryhelper.hh:38
Definition: porousmediumflow/boxdfm/geometryhelper.hh:44
Dune::ReservedVector< Dune::FieldVector< ct, cdim >,(1<<(mydim)) > Type
Definition: porousmediumflow/boxdfm/geometryhelper.hh:45
Definition: porousmediumflow/boxdfm/geometryhelper.hh:51
static const bool v
Definition: porousmediumflow/boxdfm/geometryhelper.hh:52
static const unsigned int topologyId
Definition: porousmediumflow/boxdfm/geometryhelper.hh:53
Create sub control volumes and sub control volume face geometries.
Definition: porousmediumflow/boxdfm/geometryhelper.hh:59
ScvfCornerStorage getFractureScvfCorners(unsigned int localFacetIndex, unsigned int) const
Get the corners of the (d-1)-dimensional fracture scvf.
Definition: porousmediumflow/boxdfm/geometryhelper.hh:79
ScvfCornerStorage getFractureScvfCorners(const Intersection &is, const typename Intersection::Geometry &isGeom, unsigned int idxOnIntersection=0) const
Get the corners of the (d-1)-dimensional fracture scvf.
Definition: porousmediumflow/boxdfm/geometryhelper.hh:89
ScvfType::Traits::GlobalPosition fractureNormal(const ScvfCornerStorage &p, const Intersection &is, unsigned int edgeIndexInIntersection) const
Definition: porousmediumflow/boxdfm/geometryhelper.hh:99
ScvfCornerStorage getFractureScvfCorners(unsigned int localFacetIndex, unsigned int indexInFacet) const
Create the sub control volume face geometries on an intersection marked as fracture.
Definition: porousmediumflow/boxdfm/geometryhelper.hh:132
ScvfType::Traits::GlobalPosition fractureNormal(const ScvfCornerStorage &scvfCorners, const Intersection &is, unsigned int edgeIndexInIntersection) const
get fracture scvf normal vector
Definition: porousmediumflow/boxdfm/geometryhelper.hh:170
ScvfCornerStorage getFractureScvfCorners(const Intersection &is, const typename Intersection::Geometry &isGeom, unsigned int edgeIndexInIntersection) const
Create the sub control volume face geometries on an intersection marked as fracture.
Definition: porousmediumflow/boxdfm/geometryhelper.hh:161