DUNE-FEM (unstable)

idgridpart.hh
1#ifndef DUNE_FEM_GRIDPART_IDGRIDPART_HH
2#define DUNE_FEM_GRIDPART_IDGRIDPART_HH
3
4#include <dune/grid/common/gridview.hh>
5
6#include <dune/fem/gridpart/common/deaditerator.hh>
7#include <dune/fem/gridpart/common/entitysearch.hh>
8#include <dune/fem/gridpart/common/extendedentity.hh>
9#include <dune/fem/gridpart/common/gridpart.hh>
10#include <dune/fem/gridpart/common/metatwistutility.hh>
11#include <dune/fem/gridpart/idgridpart/capabilities.hh>
12#include <dune/fem/gridpart/idgridpart/datahandle.hh>
13#include <dune/fem/gridpart/idgridpart/entity.hh>
14#include <dune/fem/gridpart/idgridpart/geometry.hh>
15#include <dune/fem/gridpart/idgridpart/indexset.hh>
16#include <dune/fem/gridpart/idgridpart/intersection.hh>
17#include <dune/fem/gridpart/idgridpart/intersectioniterator.hh>
18#include <dune/fem/gridpart/idgridpart/iterator.hh>
19
20namespace Dune
21{
22
23 namespace Fem
24 {
25
26 // Internal Forward Declarations
27 // -----------------------------
28
29 template< class HostGridPartImp >
30 class IdGridPart;
31
32
33 // IdGridPartTraits
34 // ----------------
35
36 template< class HostGridPartImp >
37 struct IdGridPartTraits
38 {
39 typedef IdGridPart< HostGridPartImp > GridPartType;
40
42 typedef MetaTwistUtility< typename HostGridPartImp :: TwistUtilityType > TwistUtilityType;
43
44 // Traits for dune-grid facades ("Gen-Gurke!")
45 struct GridFamily
46 {
47 typedef typename HostGridPartImp::ctype ctype;
48
49 static const int dimension = HostGridPartImp::dimension;
50 static const int dimensionworld = HostGridPartImp::dimensionworld;
51
52 struct Traits
53 {
54 typedef HostGridPartImp HostGridPartType;
55
56 struct EmptyData {};
57
58 // type of data passed to entities, intersections, and iterators
59 // for IdGridPart this is just an empty place holder
60 typedef EmptyData ExtraData;
61
62 template< int codim >
63 struct Codim
64 {
65 typedef Dune::Geometry< dimension - codim, dimensionworld, const GridFamily, IdGeometry > Geometry;
66 typedef Dune::Geometry< dimension - codim, dimension, const GridFamily, IdLocalGeometry > LocalGeometry;
67
69 typedef typename HostGridPartType::GridType::template Codim< codim >::EntitySeed EntitySeed;
70 };
71
72 typedef DeadIntersection< const GridFamily > IntersectionImplType;
73 typedef DeadIntersectionIterator< const GridFamily > IntersectionIteratorImplType;
74
77
80
82 };
83
84 template< int codim >
85 struct Codim
86 : public Traits::template Codim< codim >
87 {};
88
89 typedef typename Traits::LeafIntersectionIterator LeafIntersectionIterator;
90 typedef typename Traits::LevelIntersectionIterator LevelIntersectionIterator;
91
92 typedef typename Traits::HierarchicIterator HierarchicIterator;
93 };
94 typedef typename GridFamily::Traits::HostGridPartType HostGridPartType;
95
96 typedef typename HostGridPartType::GridType GridType;
97
98 typedef IdIndexSet< const GridFamily > IndexSetType;
99
100 static const PartitionIteratorType indexSetPartitionType = HostGridPartType::indexSetPartitionType;
101 static const InterfaceType indexSetInterfaceType = HostGridPartType::indexSetInterfaceType;
102
103 typedef IdIntersectionIterator < const GridFamily > IntersectionIteratorImplType;
104 typedef IdIntersection< const GridFamily > IntersectionImplType;
105 typedef IntersectionIterator< const GridFamily, IntersectionIteratorImplType, IntersectionImplType > IntersectionIteratorType;
106
107 template< int codim >
108 struct Codim
109 {
110 typedef typename GridFamily::Traits::template Codim< codim >::Geometry GeometryType;
111 typedef typename GridFamily::Traits::template Codim< codim >::LocalGeometry LocalGeometryType;
112
113 typedef typename GridFamily::Traits::template Codim< codim >::Entity EntityType;
114 typedef typename GridFamily::Traits::template Codim< codim >::EntitySeed EntitySeedType;
115
116 template< PartitionIteratorType pitype >
117 struct Partition
118 {
119 typedef EntityIterator< codim, const GridFamily, IdIterator< codim, pitype, const GridFamily > > IteratorType;
120 };
121 };
122
123 typedef typename HostGridPartType::CommunicationType CommunicationType;
124
125 static const bool conforming = HostGridPartType::Traits::conforming;
126 };
127
128
129
130 // IdGridPart
131 // ----------
132
133 template< class HostGridPartImp >
134 class IdGridPart
135 : public GridPartDefault< IdGridPartTraits< HostGridPartImp > >
136 {
137 typedef IdGridPart< HostGridPartImp > ThisType;
138 typedef GridPartDefault< IdGridPartTraits< HostGridPartImp > > BaseType;
139
140 typedef typename IdGridPartTraits< HostGridPartImp >::GridFamily GridFamily;
141
142 public:
143 typedef typename GridFamily::Traits::HostGridPartType HostGridPartType;
144
145 typedef typename BaseType::GridType GridType;
146 typedef typename BaseType::IndexSetType IndexSetType;
147 typedef typename BaseType::IntersectionIteratorType IntersectionIteratorType;
148 typedef typename BaseType::IntersectionType IntersectionType;
149 typedef typename BaseType::CommunicationType CommunicationType;
150
151 template< int codim >
152 struct Codim
153 : public BaseType::template Codim< codim >
154 {};
155
156 explicit IdGridPart ( GridType &grid )
157 : BaseType( grid ),
158 hostGridPart_( grid ),
159 indexSet_( hostGridPart_.indexSet() )
160 {}
161
162 explicit IdGridPart ( const IdGridPart &other )
163 : BaseType( other ),
164 hostGridPart_( other.hostGridPart() ),
165 indexSet_( hostGridPart_.indexSet() )
166 {}
167
168 explicit IdGridPart ( const HostGridPartType &hostGridPart )
169 : BaseType( const_cast< GridType& > ( hostGridPart.grid() ) ),
170 hostGridPart_( hostGridPart ),
171 indexSet_( hostGridPart_.indexSet() )
172 {}
173
174 const IndexSetType &indexSet () const
175 {
176 return indexSet_;
177 }
178
179 template< int codim >
180 typename Codim< codim >::IteratorType
181 begin () const
182 {
183 return begin< codim, InteriorBorder_Partition >();
184 }
185
186 template< int codim, PartitionIteratorType pitype >
187 typename Codim< codim >::template Partition< pitype >::IteratorType
188 begin () const
189 {
190 return IdIterator< codim, pitype, const GridFamily >( data(), hostGridPart().template begin< codim, pitype >() );
191 }
192
193 template< int codim >
194 typename Codim< codim >::IteratorType
195 end () const
196 {
197 return end< codim, InteriorBorder_Partition >();
198 }
199
200 template< int codim, PartitionIteratorType pitype >
201 typename Codim< codim >::template Partition< pitype >::IteratorType
202 end () const
203 {
204 return IdIterator< codim, pitype, const GridFamily >( data(), hostGridPart().template end< codim, pitype >() );
205 }
206
207 int level () const
208 {
209 return hostGridPart().level();
210 }
211
212 IntersectionIteratorType ibegin ( const typename Codim< 0 >::EntityType &entity ) const
213 {
214 return IdIntersectionIterator< const GridFamily >( data(), hostGridPart().ibegin( entity.impl().hostEntity() ) );
215 }
216
217 IntersectionIteratorType iend ( const typename Codim< 0 >::EntityType &entity ) const
218 {
219 return IdIntersectionIterator< const GridFamily >( data(), hostGridPart().iend( entity.impl().hostEntity() ) );
220 }
221
222 template< class DataHandle, class Data >
223 void communicate ( CommDataHandleIF< DataHandle, Data > &handle,
224 InterfaceType iftype, CommunicationDirection dir ) const
225 {
226 typedef CommDataHandleIF< DataHandle, Data > HostHandleType;
227 IdDataHandle< HostHandleType, GridFamily > handleWrapper( data(), handle );
228 hostGridPart().communicate( handleWrapper, iftype, dir );
229 }
230
231 template < class EntitySeed >
232 typename Codim< EntitySeed::codimension >::EntityType
233 entity ( const EntitySeed &seed ) const
234 {
235 typedef typename Codim< EntitySeed::codimension >::EntityType::Implementation EntityImp;
236 return EntityImp( data(), hostGridPart().entity( seed ) );
237 }
238
239 // convert a grid entity to a grid part entity ("Gurke!")
240 template< class Entity >
241 MakeableInterfaceObject< typename Codim< Entity::codimension >::EntityType >
242 convert ( const Entity &entity ) const
243 {
244 // make sure we have a grid entity
245 const auto& gridEntity = Fem::gridEntity( entity );
246
247 // create a grid part entity from a given grid entity
248 typedef typename Codim< Entity::codimension >::EntityType EntityType;
249 typedef typename EntityType::Implementation Implementation;
250 typedef MakeableInterfaceObject< EntityType > EntityObj;
251 // here, grid part information can be passed, if necessary
252 return EntityObj( Implementation( data(), hostGridPart().convert( gridEntity ) ) );
253 }
254
255 const HostGridPartType &hostGridPart () const { return hostGridPart_; }
256
257 HostGridPartType &hostGridPart () { return hostGridPart_; }
258
259 typedef typename GridFamily::Traits::ExtraData ExtraData;
260 ExtraData data () const { return ExtraData(); }
261
262 protected:
263 HostGridPartType hostGridPart_;
264 IndexSetType indexSet_;
265 };
266
267
268
269 // GridEntityAccess for IdEntity
270 // -----------------------------
271
272 template< int codim, int dim, class GridFamily >
273 struct GridEntityAccess< Dune::ExtendedEntity< codim, dim, GridFamily, IdEntity > >
274 {
276 typedef GridEntityAccess< typename EntityType::Implementation::HostEntityType > HostAccessType;
277 typedef typename HostAccessType::GridEntityType GridEntityType;
278
279 static const GridEntityType &gridEntity ( const EntityType &entity )
280 {
281 return HostAccessType::gridEntity( entity.impl().hostEntity() );
282 }
283 };
284
285
286
287 // EntitySearch for IdGridPart
288 // ---------------------------
289
290 template< class HostGridPart, int codim, PartitionIteratorType partition >
291 class EntitySearch< IdGridPart< HostGridPart >, codim, partition >
292 {
293 typedef EntitySearch< IdGridPart< HostGridPart >, codim, partition > ThisType;
294
295 public:
296 typedef IdGridPart< HostGridPart > GridPartType;
297 typedef typename GridPartType::ExtraData ExtraData;
298
299 typedef typename GridPartType::template Codim< codim >::EntityType EntityType;
300
301 typedef typename EntityType::Geometry::GlobalCoordinate GlobalCoordinateType;
302
303 explicit EntitySearch ( const GridPartType &gridPart )
304 : hostEntitySearch_( gridPart.hostGridPart() ),
305 data_( gridPart.data() )
306 {}
307
308 EntityType operator() ( const GlobalCoordinateType &x ) const
309 {
310 typedef typename EntityType::Implementation EntityImpl;
311 return EntityImpl( data_, hostEntitySearch_( x ) );
312 }
313
314 protected:
315 const EntitySearch< HostGridPart > hostEntitySearch_;
316 ExtraData data_;
317 };
318
319 } // namespace Fem
320
321} // namespace Dune
322
323#endif // #ifndef DUNE_FEM_GRIDPART_IDGRIDPART_HH
interface class for an iterator over grid entities
Definition: entityiterator.hh:32
Wrapper class for wrapped entities added a cast operator to the host entity.
Definition: extendedentity.hh:23
IntersectionIteratorType::Intersection IntersectionType
type of intersection
Definition: gridpart.hh:388
Traits::CommunicationType CommunicationType
Collective communication.
Definition: gridpart.hh:391
const GridType & grid() const
Returns const reference to the underlying grid.
Definition: gridpart.hh:423
Traits::IndexSetType IndexSetType
Index set implementation.
Definition: gridpart.hh:382
Traits::IntersectionIteratorType IntersectionIteratorType
type of intersection iterator
Definition: gridpart.hh:385
Traits::GridType GridType
Grid implementation.
Definition: gridpart.hh:380
void communicate(CommDataHandleIF< DataHandleImp, DataType > &data, InterfaceType iftype, CommunicationDirection dir) const
corresponding communication method for grid part
Definition: gridpart.hh:292
Wrapper class for geometries.
Definition: geometry.hh:71
Mesh entities of codimension 0 ("elements") allow to visit all intersections with "neighboring" eleme...
Definition: intersectioniterator.hh:83
Intersection of a mesh entity of codimension 0 ("element") with a "neighboring" element or with the d...
Definition: intersection.hh:164
@ conforming
Output conforming data.
Definition: common.hh:73
GeometryType
Type representing VTK's entity geometry types.
Definition: common.hh:132
PartitionIteratorType
Parameter to be used for the parallel level- and leaf iterators.
Definition: gridenums.hh:136
CommunicationDirection
Define a type for communication direction parameter.
Definition: gridenums.hh:170
InterfaceType
Parameter to be used for the communication functions.
Definition: gridenums.hh:86
Dune namespace.
Definition: alignedallocator.hh:13
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Jul 27, 22:29, 2024)