Dune Core Modules (2.3.1)

mapping.hh
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_GEOMETRY_GENERICGEOMETRY_MAPPING_HH
4 #define DUNE_GEOMETRY_GENERICGEOMETRY_MAPPING_HH
5 
6 #include <dune/geometry/genericgeometry/topologytypes.hh>
8 #include <dune/geometry/genericgeometry/matrixhelper.hh>
9 #include <dune/geometry/genericgeometry/geometrytraits.hh>
10 
11 namespace Dune
12 {
13 
14  namespace GenericGeometry
15  {
16 
17  // Mapping
18  // -------
19 
29  template< class CoordTraits, class Topo, int dimW, class Impl >
30  class Mapping
31  {
33 
34  typedef Impl Implementation;
35 
36  public:
37  typedef Topo Topology;
39 
40  static const unsigned int dimension = Traits :: dimension;
41  static const unsigned int dimWorld = Traits :: dimWorld;
42 
43  typedef typename Traits :: FieldType FieldType;
44  typedef typename Traits :: LocalCoordinate LocalCoordinate;
45  typedef typename Traits :: GlobalCoordinate GlobalCoordinate;
46  typedef typename Traits :: JacobianType JacobianType;
47  typedef typename Traits :: JacobianTransposedType JacobianTransposedType;
48 
49  typedef typename Traits :: MatrixHelper MatrixHelper;
50 
51  typedef GenericGeometry :: ReferenceElement< Topology, FieldType > ReferenceElement;
52 
53  template< unsigned int codim, unsigned int i >
54  struct SubTopology
55  {
56  typedef typename GenericGeometry :: SubTopology< Topo, codim, i > :: type Topology;
57  typedef typename Implementation :: template SubTopology< codim, i > :: Trace TraceImpl;
59  };
60 
61  static const bool alwaysAffine = Implementation :: alwaysAffine;
62 
63  protected:
64  Implementation impl_;
65 
66  public:
67  template< class CoordVector >
68  explicit Mapping ( const CoordVector &coords )
69  : impl_( coords )
70  {}
71 
72  Mapping ( const Implementation &implementation )
73  : impl_( implementation )
74  {}
75 
76  const GlobalCoordinate &corner ( int i ) const
77  {
78  return implementation().corner( i );
79  }
80 
81  void global ( const LocalCoordinate &x, GlobalCoordinate &y ) const
82  {
83  implementation().global( x, y );
84  }
85 
86  void local ( const GlobalCoordinate &y, LocalCoordinate &x ) const
87  {
88  const FieldType epsilon = CoordTraits::epsilon();
89  x = ReferenceElement::baryCenter();
90  LocalCoordinate dx;
91  do
92  {
93  // DF^n dx^n = F^n, x^{n+1} -= dx^n
94  JacobianTransposedType JT;
95  jacobianTransposed( x, JT );
96  GlobalCoordinate z;
97  global( x, z );
98  z -= y;
99  MatrixHelper::template xTRightInvA< dimension, dimWorld >( JT, z, dx );
100  x -= dx;
101  } while( dx.two_norm2() > epsilon*epsilon );
102  }
103 
104  bool jacobianTransposed ( const LocalCoordinate &x,
105  JacobianTransposedType &JT ) const
106  {
107  return implementation().jacobianTransposed( x, JT );
108  }
109 
110  FieldType
111  jacobianInverseTransposed ( const LocalCoordinate &x, JacobianType &JTInv ) const
112  {
113  JacobianTransposedType JT;
114  jacobianTransposed( x, JT );
115  return MatrixHelper :: template rightInvA< dimension, dimWorld >( JT, JTInv );
116  }
117 
118  FieldType integrationElement ( const LocalCoordinate &x ) const
119  {
120  JacobianTransposedType JT;
121  jacobianTransposed( x, JT );
122  return MatrixHelper :: template sqrtDetAAT< dimension, dimWorld >( JT );
123  }
124 
125  const Implementation &implementation () const
126  {
127  return impl_;
128  }
129 
130  template< unsigned int codim, unsigned int i >
131  typename SubTopology< codim, i > :: Trace trace () const
132  {
133  return impl_.template trace< codim, i >();
134  }
135  };
136 
137  }
138 
139 }
140 
141 #endif // #ifndef DUNE_GEOMETRY_GENERICGEOMETRY_MAPPING_HH
interface for a mapping
Definition: mapping.hh:31
Implements some reference element functionality needed by the generic geometries.
Dune namespace.
Definition: alignment.hh:14
Default mapping traits using Dune::FieldVector and Dune::FieldMatrix.
Definition: geometrytraits.hh:53
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.80.0 (May 8, 22:30, 2024)