DUNE-FEM (unstable)

compositegeometry.hh
1#ifndef DUNE_FEM_GRIDPART_COMMON_COMPOSITEGEOMETRY_HH
2#define DUNE_FEM_GRIDPART_COMMON_COMPOSITEGEOMETRY_HH
3
4#include <type_traits>
5#include <utility>
6
9#include <dune/common/transpose.hh>
10
13#include <dune/geometry/type.hh>
14
16
17#include <dune/fem/common/fmatrixcol.hh>
18
19namespace Dune
20{
21
22 // CompositeGeometry
23 // -----------------
24
25 template< class Geometry, class Embedding >
26 struct CompositeGeometry
27 {
28 static const int mydimension = Embedding::mydimension;
29 static const int coorddimension = Geometry::coorddimension;
30
31 typedef typename Geometry::ctype ctype;
32 typedef FieldVector< ctype, mydimension > LocalCoordinate;
33 typedef FieldVector< ctype, coorddimension > GlobalCoordinate;
34
36 typedef FieldMatrix< ctype, coorddimension, mydimension > JacobianInverseTransposed;
37
38 typedef JacobianInverseTransposed Jacobian;
39 typedef JacobianTransposed JacobianInverse;
40
41 // Helper class to compute a matrix pseudo inverse
42 typedef Impl::FieldMatrixHelper< ctype > MatrixHelper;
43
44 CompositeGeometry ( Geometry geometry, Embedding embedding, int order )
45 : geometry_( std::move( geometry ) ), embedding_( std::move( embedding ) ), order_( order )
46 {}
47
48 GeometryType type () const { return embedding_.type(); }
49
50 int corners () const { return embedding_.corners(); }
51 GlobalCoordinate corner( int i ) const { return geometry_.global( embedding_.corner( i ) ); }
52
53 bool affine () const { return geometry_.affine() && embedding_.affine(); }
54
55 GlobalCoordinate global ( const LocalCoordinate &local ) const { return geometry_.global( embedding_.global( local ) ); }
56 LocalCoordinate local ( const GlobalCoordinate &global ) const { return embedding_.local( geometry_.local( global ) ); }
57
58 JacobianTransposed jacobianTransposed ( const LocalCoordinate &local ) const
59 {
60 const FieldMatrix< ctype, mydimension, Embedding::coorddimension > jacEmbedding( embedding_.jacobianTransposed( local ) );
61 const auto jacGeometry = geometry_.jacobianTransposed( embedding_.global( local ) );
62
63 JacobianTransposed jacTransposed( 0 );
64 for( int i = 0; i < mydimension; ++i )
65 jacGeometry.mtv( jacEmbedding[ i ], jacTransposed[ i ] );
66 return jacTransposed;
67 }
68
69 JacobianInverseTransposed jacobianInverseTransposed ( const LocalCoordinate &local ) const
70 {
71 JacobianInverseTransposed jacInverseTransposed( 0 );
72 MatrixHelper::template rightInvA< mydimension, coorddimension >( jacobianTransposed( local ), jacInverseTransposed );
73 return jacInverseTransposed;
74 }
75
76 Jacobian jacobian ( const LocalCoordinate &local ) const
77 {
78 return transpose( jacobianTransposed( local ) );
79 }
80
81 JacobianInverse jacobianInverse ( const LocalCoordinate &local ) const
82 {
83 return transpose( jacobianInverseTransposed( local ) );
84 }
85
86 ctype integrationElement ( const LocalCoordinate &local ) const
87 {
88 return MatrixHelper::template sqrtDetAAT< mydimension, coorddimension >( jacobianTransposed( local ) );
89 }
90
91 GlobalCoordinate center () const
92 {
93 GlobalCoordinate center( 0 );
94 ctype volume( 0 );
95 for( const auto &qp : QuadratureRules< ctype, mydimension >::rule( type(), order_+1 ) )
96 {
97 const ctype weight = qp.weight() * integrationElement( qp.position() );
98 center.axpy( weight, global( qp.position() ) );
99 volume += weight;
100 }
101 return center /= volume;
102 }
103
104 ctype volume () const
105 {
106 ctype volume( 0 );
107 for( const auto &qp : QuadratureRules< ctype, mydimension >::rule( type(), order_ ) )
108 volume += qp.weight() * integrationElement( qp.position() );
109 return volume;
110 }
111
112 private:
113 Geometry geometry_;
114 Embedding embedding_;
115 int order_;
116 };
117
118} // namespace Dune
119
120#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:183
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  |  generated with Hugo v0.111.3 (Jul 27, 22:29, 2024)