3.4
DUNE for Multi-{Phase, Component, Scale, Physics, ...} flow and transport in porous media
extrusion.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 *****************************************************************************/
27#ifndef DUMUX_DISCRETIZATION_EXTRUSION_HH
28#define DUMUX_DISCRETIZATION_EXTRUSION_HH
29
30#include <dune/common/std/type_traits.hh>
31
32namespace Dumux {
33
39{
40 template<class SCVF>
41 static constexpr auto area(const SCVF& scvf)
42 { return scvf.area(); }
43
44 template<class SCV>
45 static constexpr auto volume(const SCV& scv)
46 { return scv.volume(); }
47
48 template<class Geometry>
49 static constexpr auto integrationElement(const Geometry& geo, const typename Geometry::LocalCoordinate& x)
50 { return geo.integrationElement(x); }
51};
52
58template<int radAx = 0>
60{
61 static constexpr int radialAxis = radAx;
62
67 template<class SCVF>
68 static constexpr auto area(const SCVF& scvf)
69 {
70 static_assert(int(SCVF::Traits::Geometry::mydimension) == int(SCVF::Traits::Geometry::coorddimension-1), "Area element to be called with a codim-1-entity!");
71 static_assert(SCVF::Traits::Geometry::coorddimension <= 2, "Axis rotation only makes sense for geometries up to 2D!");
72 static_assert(radialAxis < int(SCVF::Traits::Geometry::coorddimension), "Illegal radial axis!");
73
74 // Guldinus theorem
75 return scvf.area()*2.0*M_PI*scvf.center()[radialAxis];
76 }
77
82 template<class SCV>
83 static constexpr auto volume(const SCV& scv)
84 {
85 static_assert(int(SCV::Traits::Geometry::mydimension) == int(SCV::Traits::Geometry::coorddimension), "Volume element to be called with a codim-0-entity!");
86 static_assert(SCV::Traits::Geometry::coorddimension <= 2, "Axis rotation only makes sense for geometries up to 2D!");
87 static_assert(radialAxis < int(SCV::Traits::Geometry::coorddimension), "Illegal radial axis!");
88
89 // Guldinus theorem
90 return scv.volume()*2.0*M_PI*scv.center()[radialAxis];
91 }
92
96 template<class Geometry>
97 static constexpr auto integrationElement(const Geometry& geo, const typename Geometry::LocalCoordinate& x)
98 {
99 static_assert(Geometry::coorddimension <= 2, "Axis rotation only makes sense for geometries up to 2D!");
100 static_assert(radialAxis < int(Geometry::coorddimension), "Illegal radial axis!");
101
102 // Multiply with the polar extrusion factor (2*pi) and the determinant of the transformation Jacobian (radius)
103 return geo.integrationElement(x)*2.0*M_PI*geo.global(x)[radialAxis];
104 }
105};
106
112{
117 template<class SCVF>
118 static constexpr auto area(const SCVF& scvf)
119 {
120 static_assert(int(SCVF::Traits::Geometry::mydimension) == int(SCVF::Traits::Geometry::coorddimension-1), "Area element to be called with a codim-1-entity!");
121 static_assert(SCVF::Traits::Geometry::coorddimension == 1, "Spherical rotation only makes sense for 1D geometries!");
122
123 // sphere surface area
124 const auto radius = scvf.center()[0];
125 return 4.0*M_PI*radius*radius;
126 }
127
132 template<class SCV>
133 static constexpr auto volume(const SCV& scv)
134 {
135 static_assert(int(SCV::Traits::Geometry::mydimension) == int(SCV::Traits::Geometry::coorddimension), "Volume element to be called with a codim-0-entity!");
136 static_assert(SCV::Traits::Geometry::coorddimension == 1, "Spherical rotation only makes sense for 1D geometries!");
137
138 // subtract two balls
139 const auto radius0 = scv.corner(0)[0];
140 const auto radius1 = scv.corner(1)[0];
141 using std::abs;
142 return 4.0/3.0*M_PI*abs(radius1*radius1*radius1 - radius0*radius0*radius0);
143 }
144
148 template<class Geometry>
149 static constexpr auto integrationElement(const Geometry& geo, const typename Geometry::LocalCoordinate& x)
150 {
151 static_assert(Geometry::coorddimension == 1, "Spherical rotation only makes sense for 1D geometries!");
152
153 // Multiply with the constant spherical extrusion factor (int_0^2pi int_0^pi sin(phi) dphi dtheta = 4pi)
154 // and the remaining (radius-dependent) part of determinant of the transformation Jacobian (radius*radius)
155 const auto radius = geo.global(x)[0];
156 return geo.integrationElement(x)*4.0*M_PI*radius*radius;
157 }
158};
159
164template<class T>
166{
167 template<class G>
168 using E = typename G::Extrusion;
169public:
170 using type = typename Dune::Std::detected_or<NoExtrusion, E, T>::type;
171};
172
176template<class T>
178
179} // end namespace Dumux
180
181#endif
Definition: adapt.hh:29
typename Extrusion< T >::type Extrusion_t
Convenience alias for obtaining the extrusion type.
Definition: extrusion.hh:177
Default implementation that performs no extrusion (extrusion with identity)
Definition: extrusion.hh:39
static constexpr auto volume(const SCV &scv)
Definition: extrusion.hh:45
static constexpr auto integrationElement(const Geometry &geo, const typename Geometry::LocalCoordinate &x)
Definition: extrusion.hh:49
static constexpr auto area(const SCVF &scvf)
Definition: extrusion.hh:41
Rotation symmetric extrusion policy for rotating about an external axis.
Definition: extrusion.hh:60
static constexpr auto volume(const SCV &scv)
Transformed sub-control-volume volume.
Definition: extrusion.hh:83
static constexpr int radialAxis
Definition: extrusion.hh:61
static constexpr auto area(const SCVF &scvf)
Transformed sub-control-volume face area.
Definition: extrusion.hh:68
static constexpr auto integrationElement(const Geometry &geo, const typename Geometry::LocalCoordinate &x)
Integration element for quadrature rules on the reference element.
Definition: extrusion.hh:97
Rotation symmetric extrusion policy for spherical rotation.
Definition: extrusion.hh:112
static constexpr auto area(const SCVF &scvf)
Transformed sub-control-volume face area.
Definition: extrusion.hh:118
static constexpr auto integrationElement(const Geometry &geo, const typename Geometry::LocalCoordinate &x)
Integration element for quadrature rules on the reference element.
Definition: extrusion.hh:149
static constexpr auto volume(const SCV &scv)
Transformed sub-control-volume volume.
Definition: extrusion.hh:133
Traits extracting the public Extrusion type from T Defaults to NoExtrusion if no such type is found.
Definition: extrusion.hh:166
typename Dune::Std::detected_or< NoExtrusion, E, T >::type type
Definition: extrusion.hh:170