DUNE-FEM (unstable)

compositegeometry.hh
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
15#include <dune/common/transpose.hh>
16
19#include <dune/geometry/type.hh>
20
22
23#include <dune/fem/common/fmatrixcol.hh>
24
25namespace Dune
26{
27
28 // CompositeGeometry
29 // -----------------
30
31 template< class Geometry, class Embedding >
32 struct CompositeGeometry
33 {
34 static const int mydimension = Embedding::mydimension;
35 static const int coorddimension = Geometry::coorddimension;
36
37 typedef typename Geometry::ctype ctype;
38 typedef FieldVector< ctype, mydimension > LocalCoordinate;
39 typedef FieldVector< ctype, coorddimension > GlobalCoordinate;
40
42 typedef FieldMatrix< ctype, coorddimension, mydimension > JacobianInverseTransposed;
43
44 typedef JacobianInverseTransposed Jacobian;
45 typedef JacobianTransposed JacobianInverse;
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
64 JacobianTransposed jacobianTransposed ( const LocalCoordinate &local ) const
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
75 JacobianInverseTransposed jacobianInverseTransposed ( const LocalCoordinate &local ) const
76 {
77 JacobianInverseTransposed jacInverseTransposed( 0 );
78 MatrixHelper::template rightInvA< mydimension, coorddimension >( jacobianTransposed( local ), jacInverseTransposed );
79 return jacInverseTransposed;
80 }
81
82 Jacobian jacobian ( const LocalCoordinate &local ) const
83 {
84 return transpose( jacobianTransposed( local ) );
85 }
86
87 JacobianInverse jacobianInverse ( const LocalCoordinate &local ) const
88 {
89 return transpose( jacobianInverseTransposed( local ) );
90 }
91
92 ctype integrationElement ( const LocalCoordinate &local ) const
93 {
94 return MatrixHelper::template sqrtDetAAT< mydimension, coorddimension >( jacobianTransposed( local ) );
95 }
96
97 GlobalCoordinate center () const
98 {
99 GlobalCoordinate center( 0 );
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
An implementation of the Geometry interface for affine geometries.
static constexpr int coorddimension
dimension of embedding coordinate system
Definition: geometry.hh:97
GridImp::ctype ctype
define type used for coordinates in grid module
Definition: geometry.hh:100
static const QuadratureRule & rule(const GeometryType &t, int p, QuadratureType::Enum qt=QuadratureType::GaussLegendre)
select the appropriate QuadratureRule for GeometryType t and order p
Definition: quadraturerules.hh:326
Wrapper and interface classes for element geometries.
GeometryType
Type representing VTK's entity geometry types.
Definition: common.hh:132
Implements a matrix constructed from a given type representing a field and compile-time given number ...
Implements a vector constructed from a given type representing a field and a compile-time given size.
Dune namespace.
Definition: alignedallocator.hh:13
auto transpose(const Matrix &matrix)
Return the transposed of the given matrix.
Definition: transpose.hh:234
STL namespace.
A unique label for each type of element that can occur in a grid.
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden & Uni Heidelberg  |  generated with Hugo v0.111.3 (Apr 23, 22:35, 2025)