DUNE-FEM (unstable)

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