DUNE-FEM (unstable)

geogridpart.hh
1#ifndef DUNE_FEM_GRIDPART_GEOGRIDPART_HH
2#define DUNE_FEM_GRIDPART_GEOGRIDPART_HH
3
4#include <cassert>
5
6#include <dune/grid/common/gridview.hh>
7
8#include <dune/fem/gridpart/common/deaditerator.hh>
9#include <dune/fem/gridpart/common/entitysearch.hh>
10#include <dune/fem/gridpart/common/extendedentity.hh>
11#include <dune/fem/gridpart/common/gridpart.hh>
12#include <dune/fem/gridpart/common/metatwistutility.hh>
13#include <dune/fem/gridpart/geogridpart/capabilities.hh>
14#include <dune/fem/gridpart/geogridpart/datahandle.hh>
15#include <dune/fem/gridpart/geogridpart/entity.hh>
16#include <dune/fem/gridpart/geogridpart/geometry.hh>
17#include <dune/fem/gridpart/geogridpart/intersection.hh>
18#include <dune/fem/gridpart/geogridpart/intersectioniterator.hh>
19#include <dune/fem/gridpart/idgridpart/indexset.hh>
20#include <dune/fem/gridpart/idgridpart/iterator.hh>
21
22namespace Dune
23{
24
25 namespace Fem
26 {
27
28 // Internal Forward Declarations
29 // -----------------------------
30
31 template< class CoordFunction >
32 class GeoGridPart;
33
34 template< class CoordFunction >
35 struct GeoGridPartFamily;
36
37
38
39 // GeoGridPartData
40 // ---------------
41
42 template< class CoordFunction >
43 struct GeoGridPartData
44 {
45 typedef CoordFunction CoordFunctionType;
46
47 GeoGridPartData () = default;
48 GeoGridPartData ( const CoordFunctionType &coordFunction ) : coordFunction_( &coordFunction ) {}
49
50 operator const CoordFunctionType & () const { assert( coordFunction_ ); return *coordFunction_; }
51
52 private:
53 const CoordFunctionType *coordFunction_ = nullptr;
54 };
55
56
57
58 // GeoGridPartFamily
59 // -----------------
60
61 // Traits for dune-grid facades ("Gen-Gurke!")
62 template< class CoordFunction >
63 struct GeoGridPartFamily
64 {
65 typedef typename CoordFunction::RangeFieldType ctype;
66
67 static const int dimension = CoordFunction::GridPartType::dimension;
68 static const int dimensionworld = CoordFunction::FunctionSpaceType::dimRange;
69
70 typedef GeoGridPartFamily< CoordFunction > GridPartFamily;
71
72 struct Traits
73 {
74 typedef GeoGridPartData< CoordFunction > ExtraData;
75 typedef CoordFunction CoordFunctionType;
76
77 typedef typename CoordFunctionType::GridPartType HostGridPartType;
78
79 template< int codim >
80 struct Codim
81 {
82 typedef Dune::Geometry< dimension - codim, dimensionworld, const GridPartFamily, GeoGeometry > Geometry;
83 typedef typename HostGridPartType::template Codim< codim >::LocalGeometryType LocalGeometry;
84
86 typedef typename HostGridPartType::GridType::template Codim< codim >::EntitySeed EntitySeed;
87 };
88
89 typedef DeadIntersection< const GridPartFamily > IntersectionImplType;
90 typedef DeadIntersectionIterator< const GridPartFamily > IntersectionIteratorImplType;
91
94
97
99 };
100
101 template< int codim >
102 struct Codim
103 : public Traits::template Codim< codim >
104 {};
105
106 typedef typename Traits::LeafIntersectionIterator LeafIntersectionIterator;
107 typedef typename Traits::LevelIntersectionIterator LevelIntersectionIterator;
108
109 typedef typename Traits::HierarchicIterator HierarchicIterator;
110 };
111
112
113
114 template< class CoordFunction >
115 struct GeoGridPartTraits
116 {
117 typedef GeoGridPart< CoordFunction > GridPartType;
118 typedef GeoGridPartFamily< CoordFunction > GridPartFamily;
119 typedef GeoGridPartFamily< CoordFunction > GridFamily;
120
121 typedef typename GridPartFamily::Traits::HostGridPartType HostGridPartType;
122
123 typedef typename HostGridPartType::GridType GridType;
124
126 typedef MetaTwistUtility< typename HostGridPartType :: TwistUtilityType > TwistUtilityType;
127
128 typedef IdIndexSet< const GridPartFamily > IndexSetType;
129
130 static const PartitionIteratorType indexSetPartitionType = HostGridPartType::indexSetPartitionType;
131 static const InterfaceType indexSetInterfaceType = HostGridPartType::indexSetInterfaceType;
132
133 typedef GeoIntersection< const GridPartFamily > IntersectionImplType;
134 typedef GeoIntersectionIterator< const GridPartFamily > IntersectionIteratorImplType;
135
136 typedef IntersectionIterator< const GridPartFamily, IntersectionIteratorImplType, IntersectionImplType > IntersectionIteratorType;
137
138 template< int codim >
139 struct Codim
140 {
141 typedef typename GridPartFamily::Traits::template Codim< codim >::Geometry GeometryType;
142 typedef typename GridPartFamily::Traits::template Codim< codim >::LocalGeometry LocalGeometryType;
143
144 typedef typename GridPartFamily::Traits::template Codim< codim >::Entity EntityType;
145
146 typedef typename GridPartFamily::Traits::template Codim< codim >::EntitySeed EntitySeedType;
147
148 template< PartitionIteratorType pitype >
149 struct Partition
150 {
151 typedef EntityIterator< codim, const GridPartFamily, IdIterator< codim, pitype, const GridPartFamily > > IteratorType;
152 };
153 };
154
155 typedef typename HostGridPartType::CommunicationType CommunicationType;
156
157 static const bool conforming = HostGridPartType::Traits::conforming;
158 };
159
160
161
162 // GeoGridPart
163 // -----------
164
165 template< class CoordFunction >
166 class GeoGridPart
167 : public GridPartDefault< GeoGridPartTraits< CoordFunction > >
168 {
169 typedef GeoGridPart< CoordFunction > ThisType;
170 typedef GridPartDefault< GeoGridPartTraits< CoordFunction > > BaseType;
171
172 typedef typename GeoGridPartTraits< CoordFunction >::GridPartFamily GridPartFamily;
173
174 public:
175 typedef typename GridPartFamily::Traits::HostGridPartType HostGridPartType;
176
177 typedef CoordFunction CoordFunctionType;
178
179 typedef typename BaseType::GridType GridType;
180 typedef typename BaseType::IndexSetType IndexSetType;
181 typedef typename BaseType::IntersectionIteratorType IntersectionIteratorType;
182 typedef typename BaseType::IntersectionType IntersectionType;
183 typedef typename BaseType::CommunicationType CommunicationType;
184
185 template< int codim >
186 struct Codim
187 : public BaseType::template Codim< codim >
188 {};
189
190 explicit GeoGridPart ( const CoordFunctionType &coordFunction )
191 : BaseType( const_cast< GridType& > (coordFunction.gridPart().grid() ) ),
192 coordFunction_( &coordFunction ),
193 indexSet_( hostGridPart().indexSet() )
194 {}
195
196 const IndexSetType &indexSet () const
197 {
198 return indexSet_;
199 }
200
201 template< int codim >
202 typename Codim< codim >::IteratorType
203 begin () const
204 {
205 return begin< codim, InteriorBorder_Partition >();
206 }
207
208 template< int codim, PartitionIteratorType pitype >
209 typename Codim< codim >::template Partition< pitype >::IteratorType
210 begin () const
211 {
212 return IdIterator< codim, pitype, const GridPartFamily >( coordFunction(), hostGridPart().template begin< codim, pitype >() );
213 }
214
215 template< int codim >
216 typename Codim< codim >::IteratorType
217 end () const
218 {
219 return end< codim, InteriorBorder_Partition >();
220 }
221
222 template< int codim, PartitionIteratorType pitype >
223 typename Codim< codim >::template Partition< pitype >::IteratorType
224 end () const
225 {
226 return IdIterator< codim, pitype, const GridPartFamily >( coordFunction(), hostGridPart().template end< codim, pitype >() );
227 }
228
229 int level () const
230 {
231 return hostGridPart().level();
232 }
233
234 IntersectionIteratorType ibegin ( const typename Codim< 0 >::EntityType &entity ) const
235 {
236 return GeoIntersectionIterator< const GridPartFamily >( entity, hostGridPart().ibegin( entity.impl().hostEntity() ) );
237 }
238
239 IntersectionIteratorType iend ( const typename Codim< 0 >::EntityType &entity ) const
240 {
241 return GeoIntersectionIterator< const GridPartFamily >( entity, hostGridPart().iend( entity.impl().hostEntity() ) );
242 }
243
244 template< class DataHandle, class Data >
245 void communicate ( CommDataHandleIF< DataHandle, Data > &handle,
246 InterfaceType iftype, CommunicationDirection dir ) const
247 {
248 typedef CommDataHandleIF< DataHandle, Data > HostHandleType;
249 GeoDataHandle< GridPartFamily, HostHandleType > handleWrapper( coordFunction(), handle );
250 hostGridPart().communicate( handleWrapper, iftype, dir );
251 }
252
253 template< class LocalFunction >
254 typename Codim< 0 >::EntityType
255 exchangeGeometry ( const typename Codim< 0 >::EntityType &entity,
256 const LocalFunction &localCoordFunction ) const
257 {
258 return typename Codim< 0 >::EntityType::Implementation( entity.impl(), localCoordFunction );
259 }
260
261 template < class EntitySeed >
262 typename Codim< EntitySeed::codimension >::EntityType
263 entity ( const EntitySeed &seed ) const
264 {
265 return typename Codim< EntitySeed::codimension >::EntityType
266 ::Implementation( coordFunction(), hostGridPart().entity( seed ) );
267 }
268
269 // convert a grid entity to a grid part entity ("Gurke!")
270 template< class Entity >
271 MakeableInterfaceObject< typename Codim< Entity::codimension >::EntityType >
272 convert ( const Entity &entity ) const
273 {
274 // make sure we have a grid entity
275 const auto& gridEntity = Fem::gridEntity( entity );
276
277 // create a grid part entity from a given grid entity
278 typedef typename Codim< Entity::codimension >::EntityType EntityType;
279 typedef typename EntityType::Implementation Implementation;
280 typedef MakeableInterfaceObject< EntityType > EntityObj;
281
282 // here, grid part information can be passed, if necessary
283 return EntityObj( Implementation( coordFunction(), hostGridPart().convert( gridEntity ) ) );
284 }
285
286 // return reference to the coordfunction
287 const CoordFunctionType &coordFunction () const
288 {
289 assert( coordFunction_);
290 return *coordFunction_;
291 }
292
293 // return reference to the host grid part
294 const HostGridPartType &hostGridPart () const
295 {
296 return coordFunction().gridPart();
297 }
298
299 // return reference to the host grid part
300 HostGridPartType &hostGridPart ()
301 {
302 return const_cast< HostGridPartType & >( coordFunction().gridPart() );
303 }
304
305 protected:
306 const CoordFunctionType *coordFunction_;
307 IndexSetType indexSet_;
308 };
309
310
311
312 // GridEntityAccess for GeoEntity
313 // ------------------------------
314
315 template< int codim, int dim, class GridFamily >
316 struct GridEntityAccess< Dune::ExtendedEntity< codim, dim, GridFamily, GeoEntity > >
317 {
319 typedef GridEntityAccess< typename EntityType::Implementation::HostEntityType > HostAccessType;
320 typedef typename HostAccessType::GridEntityType GridEntityType;
321
322 static const GridEntityType &gridEntity ( const EntityType &entity )
323 {
324 return HostAccessType::gridEntity( entity.impl().hostEntity() );
325 }
326 };
327
328
329
330 // EntitySearch for GeoGridPart
331 // ----------------------------
332
333 template< class CoordFunction, int codim, PartitionIteratorType partition >
334 class EntitySearch< GeoGridPart< CoordFunction >, codim, partition >
335 : public DefaultEntitySearch< GeoGridPart< CoordFunction >, codim, partition >
336 {
337 typedef EntitySearch< GeoGridPart< CoordFunction >, codim, partition > ThisType;
338 typedef DefaultEntitySearch< GeoGridPart< CoordFunction >, codim, partition > BaseType;
339
340 public:
341 typedef typename BaseType::GridPartType GridPartType;
342
343 explicit EntitySearch ( const GridPartType &gridPart )
344 : BaseType( gridPart )
345 {}
346 };
347
348 } // namespace Fem
349
350} // namespace Dune
351
352#endif // #ifndef DUNE_FEM_GRIDPART_GEOGRIDPART_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 (Nov 12, 23:30, 2024)