Dune Core Modules (2.4.1)

projection.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_ALBERTA_NODEPROJECTION_HH
4#define DUNE_ALBERTA_NODEPROJECTION_HH
5
7
8#include <dune/grid/common/boundaryprojection.hh>
9
10#include <dune/grid/albertagrid/misc.hh>
12
13#if HAVE_ALBERTA
14
15namespace Dune
16{
17
18 namespace Alberta
19 {
20
21 // Internal Forward Declarations
22 // -----------------------------
23
24 template< class Proj, class Impl >
25 class ProjectionFactory;
26
27
28
29 // DuneBoundaryProjection
30 // ----------------------
31
32 template< int dim >
33 class DuneBoundaryProjection
34 {
35 typedef DuneBoundaryProjection< dim > This;
36
37 public:
38 static const int dimension = dim;
39
40 typedef Alberta::ElementInfo< dimension > ElementInfo;
41 typedef FieldVector< Real, dimWorld > GlobalCoordinate;
42
44 typedef Dune::shared_ptr< const Projection > ProjectionPtr;
45
46 explicit DuneBoundaryProjection ( const ProjectionPtr &projection )
47 : projection_( projection )
48 {}
49
50 // note: GlobalVector is an array type; global is the return value
51 void operator() ( const ElementInfo &elementInfo, const LocalVector local,
52 GlobalVector global ) const
53 {
54 GlobalCoordinate x;
55 for( int i = 0; i < dimWorld; ++i )
56 x[ i ] = global[ i ];
57 GlobalCoordinate y = projection() ( x );
58 for( int i = 0; i < dimWorld; ++i )
59 global[ i ] = y[ i ];
60 }
61
62 const Projection &projection () const
63 {
64 return *projection_;
65 }
66
67 private:
68 ProjectionPtr projection_;
69 };
70
71
72
73 // ProjectionFactoryInterface
74 // --------------------------
75
76 template< class Proj, class Impl >
77 class ProjectionFactoryInterface
78 {
79 typedef ProjectionFactoryInterface< Proj, Impl > This;
80
81 friend class ProjectionFactory< Proj, Impl >;
82
83 public:
84 typedef Proj Projection;
85
86 static const int dimension = Projection::dimension;
87
88 typedef Alberta::ElementInfo< dimension > ElementInfo;
89
90 private:
91 ProjectionFactoryInterface ()
92 {}
93
94 ProjectionFactoryInterface ( const This &other );
95 This &operator= ( const This &other );
96
97 public:
98 bool hasProjection ( const ElementInfo &elementInfo, const int face ) const
99 {
100 return asImpl().hasProjection( elementInfo, face );
101 }
102
103 bool hasProjection ( const ElementInfo &elementInfo ) const
104 {
105 return asImpl().hasProjection( elementInfo );
106 }
107
108 Projection projection ( const ElementInfo &elementInfo, const int face ) const
109 {
110 return asImpl().projection( elementInfo, face );
111 };
112
113 Projection projection ( const ElementInfo &elementInfo ) const
114 {
115 return asImpl().projection( elementInfo );
116 };
117
118 protected:
119 const Impl &asImpl () const
120 {
121 return static_cast< const Impl & >( *this );
122 }
123 };
124
125
126
127 // ProjectionFactory
128 // -----------------
129
130 template< class Proj, class Impl >
131 class ProjectionFactory
132 : public ProjectionFactoryInterface< Proj, Impl >
133 {
134 typedef ProjectionFactory< Proj, Impl > This;
135 typedef ProjectionFactoryInterface< Proj, Impl > Base;
136
137 public:
138 typedef typename Base::Projection Projection;
139 typedef typename Base::ElementInfo ElementInfo;
140
141 protected:
142 ProjectionFactory ()
143 {}
144
145 private:
146 bool hasProjection ( const ElementInfo &elementInfo, const int face ) const;
147 bool hasProjection ( const ElementInfo &elementInfo ) const;
148
149 Projection projection ( const ElementInfo &elementInfo, const int face ) const;
150 Projection projection ( const ElementInfo &elementInfo ) const;
151 };
152
153
154
155 // DuneGlobalBoundaryProjectionFactory
156 // -----------------------------------
157
158 template< int dim >
159 class DuneGlobalBoundaryProjectionFactory
160 : public ProjectionFactory< DuneBoundaryProjection< dim >, DuneGlobalBoundaryProjectionFactory< dim > >
161 {
162 typedef DuneGlobalBoundaryProjectionFactory< dim > This;
163 typedef ProjectionFactory< DuneBoundaryProjection< dim >, This > Base;
164
165 public:
166 typedef typename Base::Projection Projection;
167 typedef typename Base::ElementInfo ElementInfo;
168
169 typedef typename Projection::ProjectionPtr DuneProjectionPtr;
170
171 DuneGlobalBoundaryProjectionFactory ( const DuneProjectionPtr &projection )
172 : projection_( projection )
173 {}
174
175 bool hasProjection ( const ElementInfo &elementInfo, const int face ) const
176 {
177 return true;
178 }
179
180 bool hasProjection ( const ElementInfo &elementInfo ) const
181 {
182 return true;
183 }
184
185 Projection projection ( const ElementInfo &elementInfo, const int face ) const
186 {
187 return projection_;
188 };
189
190 Projection projection ( const ElementInfo &elementInfo ) const
191 {
192 return projection_;
193 };
194
195 private:
196 const Projection projection_;
197 };
198
199
200
201 // BasicNodeProjection
202 // -------------------
203
204 struct BasicNodeProjection
205 : public ALBERTA NODE_PROJECTION
206 {
207 explicit BasicNodeProjection ( unsigned int boundaryIndex )
208 : boundaryIndex_( boundaryIndex )
209 {
210 func = 0;
211 }
212
213 virtual ~BasicNodeProjection ()
214 {}
215
216 unsigned int boundaryIndex () const
217 {
218 return boundaryIndex_;
219 }
220
221 private:
222 unsigned int boundaryIndex_;
223 };
224
225
226
227 // NodeProjection
228 // --------------
229
230 template< int dim, class Projection >
231 class NodeProjection
232 : public BasicNodeProjection
233 {
234 typedef NodeProjection< dim, Projection > This;
235 typedef BasicNodeProjection Base;
236
237 public:
238 static const int dimension = dim;
239
240 typedef Alberta::ElementInfo< dimension > ElementInfo;
241
242 private:
243 Projection projection_;
244
245 public:
246 NodeProjection ( unsigned int boundaryIndex, const Projection &projection )
247 : Base( boundaryIndex ),
248 projection_( projection )
249 {
250 func = apply;
251 }
252
253 private:
254 // note: global is the return type (it is an array type and hence no
255 // reference is needed)
256 static void apply ( GlobalVector global, const EL_INFO *info, const LocalVector local )
257 {
258 const ElementInfo elementInfo = ElementInfo::createFake( *info );
259
260 assert( (info->fill_flag & FillFlags< dimension >::projection) != 0 );
261 const This *nodeProjection = static_cast< const This * >( info->active_projection );
262
263 assert( nodeProjection != NULL );
264 nodeProjection->projection_( elementInfo, local, global );
265 }
266 };
267
268 }
269
270}
271
272#endif // #if HAVE_ALBERTA
273
274#endif // #ifndef DUNE_ALBERTA_NODEPROJECTION_HH
provides a wrapper for ALBERTA's el_info structure
Dune namespace.
Definition: alignment.hh:10
This file implements the class shared_ptr (a reference counting pointer), for those systems that don'...
Interface class for vertex projection at the boundary.
Definition: boundaryprojection.hh:24
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Nov 22, 23:33, 2024)