dune-grid 2.8.0
Loading...
Searching...
No Matches
geometrycache.hh
Go to the documentation of this file.
1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2// vi: set et ts=4 sw=2 sts=2:
3#ifndef DUNE_ALBERTA_GEOMETRYCACHE_HH
4#define DUNE_ALBERTA_GEOMETRYCACHE_HH
5
8
9#if HAVE_ALBERTA
10
11namespace Dune
12{
13
14 namespace Alberta
15 {
16
17 // GeometryCache
18 // -------------
19
20 template< int dim >
22 {
23 static const unsigned int flagIntegrationElement = (1 << 0);
24 static const unsigned int flagJacobianTransposed = (1 << 1);
25 static const unsigned int flagJacobianInverseTransposed = (1 << 2);
26
27 public:
28 typedef FieldMatrix< Real, dimWorld, dim > JacobianInverseTransposed;
29 typedef FieldMatrix< Real, dim, dimWorld > JacobianTransposed;
30
32 : flags_( 0 )
33 {}
34
35 const Real &integrationElement ( const ALBERTA EL_INFO &elInfo )
36 {
37 if( (flags_ & flagIntegrationElement) == 0 )
38 {
39 integrationElement_ = std::abs( determinant( jacobianTransposed( elInfo ) ) );
40 assert( integrationElement_ > 1e-14 );
41 flags_ |= flagIntegrationElement;
42 }
43 return integrationElement_;
44 }
45
46 const JacobianTransposed &jacobianTransposed ( const ALBERTA EL_INFO &elInfo )
47 {
48 if( (flags_ & flagJacobianTransposed) == 0 )
49 {
50 assert( (elInfo.fill_flag & FillFlags< dim >::coords) != 0 );
51 const GlobalVector &x = elInfo.coord[ 0 ];
52 for( int i = 0; i < dim; ++i )
53 {
54 const GlobalVector &y = elInfo.coord[ i+1 ];
55 for( int j = 0; j < dimWorld; ++j )
56 jacobianTransposed_[ i ][ j ] = y[ j ] - x[ j ];
57 }
58 flags_ |= flagJacobianTransposed;
59 }
60 return jacobianTransposed_;
61 }
62
64 jacobianInverseTransposed ( const ALBERTA EL_INFO &elInfo )
65 {
66 if( (flags_ & flagJacobianInverseTransposed) == 0 )
67 {
68 integrationElement_ = std::abs( invert( jacobianTransposed( elInfo ), jacobianInverseTransposed_ ) );
69 assert( integrationElement_ > 1e-14 );
70 flags_ |= flagIntegrationElement | flagJacobianInverseTransposed;
71 }
72 return jacobianInverseTransposed_;
73 }
74
75 private:
76 unsigned int flags_;
77 Real integrationElement_;
78 FieldMatrix< Real, dim, dimWorld > jacobianTransposed_;
79 FieldMatrix< Real, dimWorld, dim > jacobianInverseTransposed_;
80 };
81
82
83
84 // GeometryCacheProxy
85 // ------------------
86
87 template< int dim >
89 {
90 typedef FieldMatrix< Real, dimWorld, dim > JacobianInverseTransposed;
91 typedef FieldMatrix< Real, dim, dimWorld > JacobianTransposed;
92
93 GeometryCacheProxy ( GeometryCache< dim > &geometryCache, const ALBERTA EL_INFO &elInfo )
94 : geometryCache_( geometryCache ),
95 elInfo_( elInfo )
96 {}
97
99 {
100 return geometryCache_.integrationElement( elInfo_ );
101 }
102
104 {
105 return geometryCache_.jacobianTransposed( elInfo_ );
106 }
107
109 {
110 return geometryCache_.jacobianInverseTransposed( elInfo_ );
111 }
112
113 private:
114 GeometryCache< dim > &geometryCache_;
115 const ALBERTA EL_INFO &elInfo_;
116 };
117
118 } // namespace Alberta
119
120} // namespace Dune
121
122#endif // #if HAVE_ALBERTA
123
124#endif // #ifndef DUNE_ALBERTA_GEOMETRYCACHE_HH
#define ALBERTA
Definition: albertaheader.hh:27
Include standard header files.
Definition: agrid.hh:58
ALBERTA REAL Real
Definition: misc.hh:46
static K determinant(const FieldMatrix< K, 0, m > &matrix)
Definition: algebra.hh:28
static K invert(const FieldMatrix< K, 0, m > &matrix, FieldMatrix< K, m, 0 > &inverse)
Definition: algebra.hh:79
static const int dimWorld
Definition: misc.hh:44
ALBERTA REAL_D GlobalVector
Definition: misc.hh:48
Definition: geometrycache.hh:22
GeometryCache()
Definition: geometrycache.hh:31
const Real & integrationElement(const ALBERTA EL_INFO &elInfo)
Definition: geometrycache.hh:35
FieldMatrix< Real, dim, dimWorld > JacobianTransposed
Definition: geometrycache.hh:29
const JacobianTransposed & jacobianTransposed(const ALBERTA EL_INFO &elInfo)
Definition: geometrycache.hh:46
const JacobianInverseTransposed & jacobianInverseTransposed(const ALBERTA EL_INFO &elInfo)
Definition: geometrycache.hh:64
FieldMatrix< Real, dimWorld, dim > JacobianInverseTransposed
Definition: geometrycache.hh:28
Definition: geometrycache.hh:89
const JacobianTransposed & jacobianTransposed()
Definition: geometrycache.hh:103
FieldMatrix< Real, dim, dimWorld > JacobianTransposed
Definition: geometrycache.hh:91
FieldMatrix< Real, dimWorld, dim > JacobianInverseTransposed
Definition: geometrycache.hh:90
const Real & integrationElement()
Definition: geometrycache.hh:98
GeometryCacheProxy(GeometryCache< dim > &geometryCache, const ALBERTA EL_INFO &elInfo)
Definition: geometrycache.hh:93
const JacobianInverseTransposed & jacobianInverseTransposed()
Definition: geometrycache.hh:108
Definition: misc.hh:229