DUNE-ACFEM (unstable)

geometry.hh
1#ifndef __DUNE_ACFEM_COMMON_GEOMETRY_HH__
2#define __DUNE_ACFEM_COMMON_GEOMETRY_HH__
3
4#include <cmath>
5
6#include <dune/geometry/referenceelements.hh>
7
8namespace Dune {
9
10 namespace ACFem {
11
19 template<class Geometry>
20 typename Geometry::ctype h2Estimate(const Geometry& geometry)
21 {
22 const int dimension = Geometry::mydimension;
23 typename Geometry::ctype volume = geometry.volume();
24
25 switch(dimension) {
26 case 1:
27 return volume*volume;
28 case 2:
29 return volume;
30 case 3:
31 return std::pow(volume, 2.0/(double)dimension);
32 default:
33 return -1.0;
34 }
35 }
36
40 template<class Geometry>
41 typename Geometry::ctype hEstimate(const Geometry& geometry)
42 {
43 typedef typename Geometry::ctype ctype;
44 const int dimension = Geometry::mydimension;
45 const ctype volume = geometry.volume();
46
47 switch(dimension) {
48 case 1:
49 return volume;
50 case 2:
51 return std::sqrt(volume);
52 case 3:
53 return std::pow(volume, 1.0/(double)dimension);
54 default:
55 return -1.0;
56 }
57 }
58
62 template<class GridPart, int codim = 0>
64 {
66 public:
68 using GridPartType = GridPart;
69
71 static constexpr int dim = GridPartType::dimension - codim;
72
74 using ctype = typename GridPartType::ctype;
75
76 protected:
77 using ReferenceElementsType = Dune::ReferenceElements<ctype, dim>;
78
79 public:
81 using ReferenceElementType = std::decay_t<decltype(ReferenceElementsType::general(std::declval<const GeometryType&>()))>;
82
84 using DomainType = FieldVector<ctype, dim>;
85
86 public:
88 static const DomainType localCenter(const GeometryType &type)
89 {
90 return type.isNone() ? DomainType(0) : referenceElement(type).position(0, 0);
91 }
92
94 static ctype referenceVolume (const GeometryType &type)
95 {
96 return type.isNone() ? ctype(1.0) : referenceElement(type).volume();
97 }
98
100 static auto referenceElement(const GeometryType &type)
101 {
102 assert(!type.isNone());
103 return ReferenceElementsType::general( type );
104 }
105 };
106
109 } // namespace ACFem
110
111} // namespace Dune
112
113#endif // __DUNE_ACFEM_COMMON_GEOMETRY_HH__
Export some hard-to-get-at things for geometries.
Definition: geometry.hh:64
static const DomainType localCenter(const GeometryType &type)
return local bary center for geometry of type type
Definition: geometry.hh:88
typename GridPartType::ctype ctype
coordinate type
Definition: geometry.hh:74
static constexpr int dim
dimension
Definition: geometry.hh:71
std::decay_t< decltype(ReferenceElementsType::general(std::declval< const GeometryType & >()))> ReferenceElementType
type of reference element
Definition: geometry.hh:81
static auto referenceElement(const GeometryType &type)
return reference element for type
Definition: geometry.hh:100
GridPart GridPartType
grid type
Definition: geometry.hh:68
FieldVector< ctype, dim > DomainType
type of domain vector, local coordinates.
Definition: geometry.hh:84
static ctype referenceVolume(const GeometryType &type)
return volume of reference element for geometry of type type
Definition: geometry.hh:94
Geometry::ctype h2Estimate(const Geometry &geometry)
Compute a rough estimate of the square of the diameter of the element's Geometry.
Definition: geometry.hh:20
Geometry::ctype hEstimate(const Geometry &geometry)
Compute a rough estimate of the diameter of the element's Geometry.
Definition: geometry.hh:41
auto pow(T1 &&t1, T2 &&t2)
Power operations with scalar exponents are promoted to component-wise power operations by multiplying...
Definition: expressions.hh:525
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Jul 15, 22:36, 2024)