version 3.10-dev
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// SPDX-FileCopyrightInfo: Copyright © DuMux Project contributors, see AUTHORS.md in root folder
5// SPDX-License-Identifier: GPL-3.0-or-later
6//
15#ifndef DUMUX_DISCRETIZATION_EXTRUSION_HH
16#define DUMUX_DISCRETIZATION_EXTRUSION_HH
17
18#include <dune/common/std/type_traits.hh>
19
20namespace Dumux {
21
27{
28 template<class FVGeo, class SCVF>
29 static constexpr auto area(const FVGeo&, const SCVF& scvf)
30 { return scvf.area(); }
31
32 template<class FVGeo, class SCV>
33 static constexpr auto volume(const FVGeo&, const SCV& scv)
34 { return scv.volume(); }
35
36 template<class Geometry>
37 static constexpr auto integrationElement(const Geometry& geo, const typename Geometry::LocalCoordinate& x)
38 { return geo.integrationElement(x); }
39};
40
46template<int radAx = 0>
48{
49 static constexpr int radialAxis = radAx;
50
55 template<class FVGeo, class SCVF>
56 static constexpr auto area(const FVGeo&, const SCVF& scvf)
57 {
58 static_assert(int(SCVF::Traits::Geometry::mydimension) == int(SCVF::Traits::Geometry::coorddimension-1), "Area element to be called with a codim-1-entity!");
59 static_assert(SCVF::Traits::Geometry::coorddimension <= 2, "Axis rotation only makes sense for geometries up to 2D!");
60 static_assert(radialAxis < int(SCVF::Traits::Geometry::coorddimension), "Illegal radial axis!");
61
62 // Guldinus theorem
63 return scvf.area()*2.0*M_PI*scvf.center()[radialAxis];
64 }
65
70 template<class FVGeo, class SCV>
71 static constexpr auto volume(const FVGeo&, const SCV& scv)
72 {
73 static_assert(int(SCV::Traits::Geometry::mydimension) == int(SCV::Traits::Geometry::coorddimension), "Volume element to be called with a codim-0-entity!");
74 static_assert(SCV::Traits::Geometry::coorddimension <= 2, "Axis rotation only makes sense for geometries up to 2D!");
75 static_assert(radialAxis < int(SCV::Traits::Geometry::coorddimension), "Illegal radial axis!");
76
77 // Guldinus theorem
78 return scv.volume()*2.0*M_PI*scv.center()[radialAxis];
79 }
80
84 template<class Geometry>
85 static constexpr auto integrationElement(const Geometry& geo, const typename Geometry::LocalCoordinate& x)
86 {
87 static_assert(Geometry::coorddimension <= 2, "Axis rotation only makes sense for geometries up to 2D!");
88 static_assert(radialAxis < int(Geometry::coorddimension), "Illegal radial axis!");
89
90 // Multiply with the polar extrusion factor (2*pi) and the determinant of the transformation Jacobian (radius)
91 return geo.integrationElement(x)*2.0*M_PI*geo.global(x)[radialAxis];
92 }
93};
94
100{
105 template<class FVGeo, class SCVF>
106 static constexpr auto area(const FVGeo&, const SCVF& scvf)
107 {
108 static_assert(int(SCVF::Traits::Geometry::mydimension) == int(SCVF::Traits::Geometry::coorddimension-1), "Area element to be called with a codim-1-entity!");
109 static_assert(SCVF::Traits::Geometry::coorddimension == 1, "Spherical rotation only makes sense for 1D geometries!");
110
111 // sphere surface area
112 const auto radius = scvf.center()[0];
113 return 4.0*M_PI*radius*radius;
114 }
115
120 template<class FVGeo, class SCV>
121 static constexpr auto volume(const FVGeo& fvGeometry, const SCV& scv)
122 {
123 static_assert(int(SCV::Traits::Geometry::mydimension) == int(SCV::Traits::Geometry::coorddimension), "Volume element to be called with a codim-0-entity!");
124 static_assert(SCV::Traits::Geometry::coorddimension == 1, "Spherical rotation only makes sense for 1D geometries!");
125
126 // subtract two balls
127 const auto geo = fvGeometry.geometry(scv);
128 const auto radius0 = geo.corner(0)[0];
129 const auto radius1 = geo.corner(1)[0];
130 using std::abs;
131 return 4.0/3.0*M_PI*abs(radius1*radius1*radius1 - radius0*radius0*radius0);
132 }
133
137 template<class Geometry>
138 static constexpr auto integrationElement(const Geometry& geo, const typename Geometry::LocalCoordinate& x)
139 {
140 static_assert(Geometry::coorddimension == 1, "Spherical rotation only makes sense for 1D geometries!");
141
142 // Multiply with the constant spherical extrusion factor (int_0^2pi int_0^pi sin(phi) dphi dtheta = 4pi)
143 // and the remaining (radius-dependent) part of determinant of the transformation Jacobian (radius*radius)
144 const auto radius = geo.global(x)[0];
145 return geo.integrationElement(x)*4.0*M_PI*radius*radius;
146 }
147};
148
153template<class T>
155{
156 template<class G>
157 using E = typename G::Extrusion;
158public:
159 using type = typename Dune::Std::detected_or<NoExtrusion, E, T>::type;
160};
161
165template<class T>
167
171template<class T>
172inline constexpr bool isRotationalExtrusion = false;
173
177template<int radialAxis>
178inline constexpr bool isRotationalExtrusion<RotationalExtrusion<radialAxis>> = true;
179
180} // end namespace Dumux
181
182#endif
Traits extracting the public Extrusion type from T Defaults to NoExtrusion if no such type is found.
Definition: extrusion.hh:155
typename Dune::Std::detected_or< NoExtrusion, E, T >::type type
Definition: extrusion.hh:159
Definition: adapt.hh:17
typename Extrusion< T >::type Extrusion_t
Convenience alias for obtaining the extrusion type.
Definition: extrusion.hh:166
constexpr bool isRotationalExtrusion
Convenience trait to check whether the extrusion is rotational.
Definition: extrusion.hh:172
Default implementation that performs no extrusion (extrusion with identity)
Definition: extrusion.hh:27
static constexpr auto area(const FVGeo &, const SCVF &scvf)
Definition: extrusion.hh:29
static constexpr auto integrationElement(const Geometry &geo, const typename Geometry::LocalCoordinate &x)
Definition: extrusion.hh:37
static constexpr auto volume(const FVGeo &, const SCV &scv)
Definition: extrusion.hh:33
Rotation symmetric extrusion policy for rotating about an external axis.
Definition: extrusion.hh:48
static constexpr auto volume(const FVGeo &, const SCV &scv)
Transformed sub-control-volume volume.
Definition: extrusion.hh:71
static constexpr int radialAxis
Definition: extrusion.hh:49
static constexpr auto integrationElement(const Geometry &geo, const typename Geometry::LocalCoordinate &x)
Integration element for quadrature rules on the reference element.
Definition: extrusion.hh:85
static constexpr auto area(const FVGeo &, const SCVF &scvf)
Transformed sub-control-volume face area.
Definition: extrusion.hh:56
Rotation symmetric extrusion policy for spherical rotation.
Definition: extrusion.hh:100
static constexpr auto area(const FVGeo &, const SCVF &scvf)
Transformed sub-control-volume face area.
Definition: extrusion.hh:106
static constexpr auto integrationElement(const Geometry &geo, const typename Geometry::LocalCoordinate &x)
Integration element for quadrature rules on the reference element.
Definition: extrusion.hh:138
static constexpr auto volume(const FVGeo &fvGeometry, const SCV &scv)
Transformed sub-control-volume volume.
Definition: extrusion.hh:121