dune-fem 2.12-git
Loading...
Searching...
No Matches
compositegeometry.hh
Go to the documentation of this file.
1#ifndef DUNE_FEM_GRIDPART_COMMON_COMPOSITEGEOMETRY_HH
2#define DUNE_FEM_GRIDPART_COMMON_COMPOSITEGEOMETRY_HH
3
4#if __GNUC__ >= 13
5#pragma GCC diagnostic push
6#pragma GCC diagnostic ignored "-Wdangling-reference"
7#endif
8
9
10#include <type_traits>
11#include <utility>
12
16
19#include <dune/geometry/type.hh>
20
21#include <dune/grid/common/geometry.hh>
22
24
25namespace Dune
26{
27
28 // CompositeGeometry
29 // -----------------
30
31 template< class Geometry, class Embedding >
33 {
34 static const int mydimension = Embedding::mydimension;
36
37 typedef typename Geometry::ctype ctype;
40
43
46
47 // Helper class to compute a matrix pseudo inverse
48 typedef Impl::FieldMatrixHelper< ctype > MatrixHelper;
49
50 CompositeGeometry ( Geometry geometry, Embedding embedding, int order )
51 : geometry_( std::move( geometry ) ), embedding_( std::move( embedding ) ), order_( order )
52 {}
53
54 GeometryType type () const { return embedding_.type(); }
55
56 int corners () const { return embedding_.corners(); }
57 GlobalCoordinate corner( int i ) const { return geometry_.global( embedding_.corner( i ) ); }
58
59 bool affine () const { return geometry_.affine() && embedding_.affine(); }
60
61 GlobalCoordinate global ( const LocalCoordinate &local ) const { return geometry_.global( embedding_.global( local ) ); }
62 LocalCoordinate local ( const GlobalCoordinate &global ) const { return embedding_.local( geometry_.local( global ) ); }
63
65 {
66 const FieldMatrix< ctype, mydimension, Embedding::coorddimension > jacEmbedding( embedding_.jacobianTransposed( local ) );
67 const auto jacGeometry = geometry_.jacobianTransposed( embedding_.global( local ) );
68
69 JacobianTransposed jacTransposed( 0 );
70 for( int i = 0; i < mydimension; ++i )
71 jacGeometry.mtv( jacEmbedding[ i ], jacTransposed[ i ] );
72 return jacTransposed;
73 }
74
76 {
77 JacobianInverseTransposed jacInverseTransposed( 0 );
78 MatrixHelper::template rightInvA< mydimension, coorddimension >( jacobianTransposed( local ), jacInverseTransposed );
79 return jacInverseTransposed;
80 }
81
83 {
85 }
86
91
93 {
94 return MatrixHelper::template sqrtDetAAT< mydimension, coorddimension >( jacobianTransposed( local ) );
95 }
96
98 {
100 ctype volume( 0 );
101 auto quadrule = QuadratureRules< ctype, mydimension >::rule( type(), order_+1 );
102 for( const auto &qp : quadrule )
103 {
104 const ctype weight = qp.weight() * integrationElement( qp.position() );
105 center.axpy( weight, global( qp.position() ) );
106 volume += weight;
107 }
108 return center /= volume;
109 }
110
111 ctype volume () const
112 {
113 ctype volume( 0 );
114 for( const auto &qp : QuadratureRules< ctype, mydimension >::rule( type(), order_ ) )
115 volume += qp.weight() * integrationElement( qp.position() );
116 return volume;
117 }
118
119 private:
120 Geometry geometry_;
121 Embedding embedding_;
122 int order_;
123 };
124
125} // namespace Dune
126
127
128#if __GNUC__ >= 13
129#pragma GCC diagnostic pop
130#endif
131
132#endif // #ifndef DUNE_FEM_GRIDPART_GEOMETRYGRIDPART_GEOMETRY_HH
const GlobalIndex & global() const
LocalIndex & local()
auto transpose(const Matrix &matrix)
STL namespace.
constexpr derived_type & axpy(const field_type &a, const DenseVector< Other > &x)
static const QuadratureRule & rule(const GeometryType &t, int p, QuadratureType::Enum qt=QuadratureType::GaussLegendre)
JacobianTransposed jacobianTransposed(const LocalCoordinate &local) const
GlobalCoordinate global(const LocalCoordinate &local) const
static constexpr int coorddimension
GridImp::ctype ctype
LocalCoordinate local(const GlobalCoordinate &global) const
bool affine() const
Definition compositegeometry.hh:33
Geometry::ctype ctype
Definition compositegeometry.hh:37
GlobalCoordinate corner(int i) const
Definition compositegeometry.hh:57
Jacobian jacobian(const LocalCoordinate &local) const
Definition compositegeometry.hh:82
int corners() const
Definition compositegeometry.hh:56
FieldVector< ctype, mydimension > LocalCoordinate
Definition compositegeometry.hh:38
JacobianTransposed jacobianTransposed(const LocalCoordinate &local) const
Definition compositegeometry.hh:64
bool affine() const
Definition compositegeometry.hh:59
GlobalCoordinate global(const LocalCoordinate &local) const
Definition compositegeometry.hh:61
ctype volume() const
Definition compositegeometry.hh:111
LocalCoordinate local(const GlobalCoordinate &global) const
Definition compositegeometry.hh:62
JacobianInverse jacobianInverse(const LocalCoordinate &local) const
Definition compositegeometry.hh:87
CompositeGeometry(Geometry geometry, Embedding embedding, int order)
Definition compositegeometry.hh:50
ctype integrationElement(const LocalCoordinate &local) const
Definition compositegeometry.hh:92
JacobianInverseTransposed jacobianInverseTransposed(const LocalCoordinate &local) const
Definition compositegeometry.hh:75
JacobianTransposed JacobianInverse
Definition compositegeometry.hh:45
JacobianInverseTransposed Jacobian
Definition compositegeometry.hh:44
GlobalCoordinate center() const
Definition compositegeometry.hh:97
static const int mydimension
Definition compositegeometry.hh:34
FieldMatrix< ctype, mydimension, coorddimension > JacobianTransposed
Definition compositegeometry.hh:41
FieldVector< ctype, coorddimension > GlobalCoordinate
Definition compositegeometry.hh:39
static const int coorddimension
Definition compositegeometry.hh:35
GeometryType type() const
Definition compositegeometry.hh:54
Impl::FieldMatrixHelper< ctype > MatrixHelper
Definition compositegeometry.hh:48
FieldMatrix< ctype, coorddimension, mydimension > JacobianInverseTransposed
Definition compositegeometry.hh:42