DUNE-FEM (unstable)

gridpart.hh
1#ifndef DUNE_FEM_GRIDPART_COMMON_GRIDPART_HH
2#define DUNE_FEM_GRIDPART_COMMON_GRIDPART_HH
3
4//- dune-common includes
7
8//- dune-grid includes
10#include <dune/grid/common/entity.hh>
12
13//- dune-fem includes
14#include <dune/fem/space/common/dofmanager.hh>
15#include <dune/fem/gridpart/common/capabilities.hh>
16#include <dune/fem/quadrature/caching/twistutility.hh>
17#include <dune/fem/misc/boundaryidprovider.hh>
18
19namespace Dune
20{
21
22 namespace Fem
23 {
24
74 template< class GridPartTraits >
76 {
78
79 public:
81 typedef GridPartTraits Traits;
82
84 typedef typename Traits::GridPartType GridPartType;
85
87 typedef typename Traits::GridType GridType;
89 typedef GridType Grid;
90
92 typedef typename Traits::IndexSetType IndexSetType;
95
97 typedef typename Traits::CommunicationType CommunicationType;
100
102 typedef typename Traits::TwistUtilityType TwistUtilityType;
103
106 = Traits::indexSetPartitionType;
107 static const InterfaceType indexSetInterfaceType
108 = Traits::indexSetInterfaceType;
109
111 typedef typename Traits::IntersectionIteratorType IntersectionIteratorType;
114
116 typedef typename IntersectionIteratorType::Intersection IntersectionType;
119
120 typedef GridPartType GridViewType;
121
122 typedef typename GridType::ctype ctype;
123
124 // static const int dimension = GridType::dimension;
125 // static const int dimensionworld = GridType::dimensionworld;
126 // static const bool conforming = Traits::conforming ;
127
128 static constexpr int dimension = GridType::dimension;
129 static constexpr int dimensionworld = GridType::dimensionworld;
130 static constexpr bool conforming = Traits::conforming ;
131
132 template< int codim >
133 struct Codim
134 {
135 typedef typename Traits::template Codim< codim >::GeometryType GeometryType;
136 typedef typename Traits::template Codim< codim >::LocalGeometryType LocalGeometryType;
137
138 typedef typename Traits::template Codim< codim >::EntityType EntityType;
139 typedef typename Traits::template Codim< codim >::EntitySeedType EntitySeedType;
140
141 // GridView typedefs interface
142 typedef GeometryType Geometry;
143 typedef LocalGeometryType LocalGeometry;
144 typedef EntityType Entity;
145 typedef EntitySeedType EntitySeed;
146
147 template< PartitionIteratorType pitype >
148 struct Partition
149 {
150 typedef typename Traits::template Codim< codim >::template Partition< pitype >::IteratorType
151 IteratorType;
152 // GridView typedef
153 typedef IteratorType Iterator;
154 };
155
156 typedef typename Partition< InteriorBorder_Partition >::IteratorType IteratorType;
157 // GridView typedef
158 typedef IteratorType Iterator;
159 };
160
162 const GridType &grid () const
163 {
164 CHECK_INTERFACE_IMPLEMENTATION((asImp().grid()));
165 return asImp().grid();
166 }
169 {
170 CHECK_INTERFACE_IMPLEMENTATION((asImp().grid()));
171 return asImp().grid();
172 }
173
175 const IndexSetType& indexSet() const
176 {
177 CHECK_INTERFACE_IMPLEMENTATION((asImp().indexSet()));
178 return asImp().indexSet();
179 }
180
182 bool isConforming() const
183 {
184 CHECK_INTERFACE_IMPLEMENTATION( (asImp().isConforming()) );
185 return asImp().isConforming();
186 }
187
189 int size ( int codim ) const
190 {
191 CHECK_INTERFACE_IMPLEMENTATION( (asImp().size( codim )) );
192 return asImp().size( codim );
193 }
194
196 int size ( const GeometryType &type ) const
197 {
198 CHECK_INTERFACE_IMPLEMENTATION( (asImp().size( type )) );
199 return asImp().size( type );
200 }
201
206 template< int codim >
208 begin () const
209 {
210 CHECK_INTERFACE_IMPLEMENTATION( (asImp().template begin< codim >()) );
211 return asImp().template begin< codim >();
212 }
213
219 template< int codim, PartitionIteratorType pitype >
220 typename Codim< codim >::template Partition< pitype >::IteratorType
221 begin () const
222 {
223 CHECK_INTERFACE_IMPLEMENTATION( (asImp().template begin< codim, pitype >()) );
224 return asImp().template begin< codim, pitype >();
225 }
226
231 template< int codim >
233 end () const
234 {
235 CHECK_INTERFACE_IMPLEMENTATION( (asImp().template end< codim >()) );
236 return asImp().template end< codim >();
237 }
238
244 template< int codim, PartitionIteratorType pitype >
245 typename Codim< codim >::template Partition< pitype >::IteratorType
246 end () const
247 {
248 CHECK_INTERFACE_IMPLEMENTATION( (asImp().template end< codim, pitype >()) );
249 return asImp().template end< codim, pitype >();
250 }
251
253 [[deprecated("Do not use this since it is no longer part of the interface")]]
254 int level () const
255 {
256 DUNE_THROW(NotImplemented,"GridPart::level has been removed!");
257 return -1;
258 }
259
262 ibegin ( const typename Codim< 0 >::EntityType &entity ) const
263 {
264 CHECK_INTERFACE_IMPLEMENTATION( (asImp().ibegin( entity )) );
265 return asImp().ibegin( entity );
266 }
267
269 IntersectionIteratorType iend ( const typename Codim< 0 >::EntityType &entity ) const
270 {
271 CHECK_INTERFACE_IMPLEMENTATION( (asImp().iend( entity )) );
272 return asImp().iend( entity );
273 }
274
276 [[deprecated("Use BoundaryIdProvider::boundaryId directly!")]]
277 int boundaryId ( const IntersectionType &intersection ) const
278 {
279 CHECK_INTERFACE_IMPLEMENTATION( asImp().boundaryId( intersection ) );
280 return asImp().boundaryId( intersection );
281 }
282
284 const CommunicationType &comm () const
285 {
286 CHECK_INTERFACE_IMPLEMENTATION( asImp().comm() );
287 return asImp().comm();
288 }
289
291 template< class DataHandleImp, class DataType >
293 InterfaceType iftype, CommunicationDirection dir ) const
294 {
295 CHECK_AND_CALL_INTERFACE_IMPLEMENTATION( (asImp().communicate( data, iftype, dir )) );
296 }
297
299 template < class EntitySeed >
301 entity ( const EntitySeed &seed ) const
302 {
303 CHECK_INTERFACE_IMPLEMENTATION( asImp().entity( seed ) );
304 return asImp().entity( seed );
305 }
306
313 template <class Entity>
314 const Entity& convert( const Entity& entity ) const
315 {
316 CHECK_INTERFACE_IMPLEMENTATION( asImp().convert( entity ) );
317 return asImp().convert( entity );
318 }
319
326 template<class EntityType>
327 bool contains (const EntityType& e) const
328 {
329 return asImp().contains(e);
330 }
331
332 int overlapSize ( int codim ) const
333 {
334 DUNE_THROW( NotImplemented, "Method overlapSize() not implemented yet" );
335 }
336
337 int ghostSize( int codim ) const
338 {
339 DUNE_THROW( NotImplemented, "Method ghostSize() not implemented yet" );
340 }
341
345 [[deprecated("Use DofManager::sequence instead!")]]
346 int sequence () const
347 {
348 DUNE_THROW(NotImplemented,"GridPart::sequence is not part of the interface, use DofManager::sequence instead!");
349 return -1;
350 }
351
352 const auto& gridView() const
353 {
354 return asImp();
355 }
356
357 protected:
359 GridPartInterface () = default;
360
361 private:
362 GridPartType &asImp () { return static_cast< GridPartType & >( *this ); }
363 const GridPartType &asImp () const { return static_cast< const GridPartType & >( *this ); }
364 };
365
366
367
369 template< class GridPartTraits >
371 : public GridPartInterface< GridPartTraits >
372 {
375
376 public:
378 typedef GridPartTraits Traits;
380 typedef typename Traits::GridType GridType;
382 typedef typename Traits::IndexSetType IndexSetType;
383
385 typedef typename Traits::IntersectionIteratorType IntersectionIteratorType;
386
388 typedef typename IntersectionIteratorType::Intersection IntersectionType;
389
391 typedef typename Traits::CommunicationType CommunicationType;
392
395
397 typedef BoundaryIdProvider< GridType > BoundaryIdProviderType;
398
399 protected:
400 GridType *grid_;
401 DofManagerType *dofManager_;
402
405 : grid_( &grid ),
406 dofManager_( &DofManagerType :: instance( this->grid() ) )
407 {}
408
409 GridPartDefault ( const ThisType &other )
410 : grid_( other.grid_ ),
411 dofManager_( &DofManagerType :: instance( this->grid() ) )
412 {}
413
414 GridPartDefault& operator= ( const ThisType &other )
415 {
416 grid_ = other.grid_;
417 dofManager_ = &DofManagerType :: instance( grid() );
418 return *this;
419 }
420
421 public:
423 const GridType &grid () const { assert( grid_ ); return *grid_; }
424
426 GridType &grid () { assert( grid_ ); return *grid_; }
427
429 bool isConforming() const
430 {
431 // default is to return the static variant
432 return bool(BaseType::conforming);
433 }
434
436 int size ( int codim ) const
437 {
438 return BaseType::indexSet().size( codim );
439 }
440
442 int size ( const GeometryType &type ) const
443 {
444 return BaseType::indexSet().size( type );
445 }
446
447 template<class EntityType>
448 bool contains (const EntityType& e) const
449 {
450 return BaseType::indexSet().contains(e);
451 }
452
454 const CommunicationType &comm () const
455 {
456 return grid().comm();
457 }
458
466 template < class EntitySeed >
467 typename Traits::template Codim< EntitySeed::codimension >::EntityType
468 entity ( const EntitySeed &seed ) const
469 {
470 return grid().entity( seed );
471 }
472
477 template <class Entity>
478 const Entity& convert( const Entity& entity ) const
479 {
480 return entity;
481 }
482
484 [[deprecated("Use BoundaryIdProvider::boundaryId directly!")]]
485 int boundaryId ( const IntersectionType &intersection ) const
486 {
487 return BoundaryIdProviderType::boundaryId( intersection );
488 }
489 };
490
493 template< class Entity >
494 struct GridEntityAccess;
495
496 template< int codim, int dim, class Grid, template< int, int, class > class EntityImpl >
497 struct GridEntityAccess< Dune::Entity< codim, dim, Grid, EntityImpl > >
498 {
501
502 static const GridEntityType &gridEntity ( const EntityType &entity )
503 {
504 return entity;
505 }
506 };
507
508 template< class Entity >
509 const typename GridEntityAccess< Entity >::GridEntityType &
510 gridEntity ( const Entity &entity )
511 {
512 return GridEntityAccess< Entity >::gridEntity( entity );
513 }
514
515 } // namespace Fem
516
517} // namespace Dune
518
519#endif // #define DUNE_FEM_GRIDPART_COMMON_GRIDPART_HH
Provides check for implementation of interface methods when using static polymorphism,...
#define CHECK_AND_CALL_INTERFACE_IMPLEMENTATION(__interface_method_to_call__)
Definition: bartonnackmanifcheck.hh:61
CommDataHandleIF describes the features of a data handle for communication in parallel runs using the...
Definition: datahandleif.hh:78
Store a reference to an entity with a minimal memory footprint.
Definition: entityseed.hh:26
Wrapper class for entities.
Definition: entity.hh:66
Definition: dofmanager.hh:786
Default implementation for the GridPart classes.
Definition: gridpart.hh:372
GridPartTraits Traits
Type of the Traits.
Definition: gridpart.hh:378
Traits::template Codim< EntitySeed::codimension >::EntityType entity(const EntitySeed &seed) const
obtain entity pointer from entity seed
Definition: gridpart.hh:468
IntersectionIteratorType::Intersection IntersectionType
type of intersection
Definition: gridpart.hh:388
Traits::CommunicationType CommunicationType
Collective communication.
Definition: gridpart.hh:391
int boundaryId(const IntersectionType &intersection) const
obtain entity pointer from entity seed
Definition: gridpart.hh:485
int size(int codim) const
obtain number of entities in a given codimension
Definition: gridpart.hh:436
const GridType & grid() const
Returns const reference to the underlying grid.
Definition: gridpart.hh:423
const CommunicationType & comm() const
obtain collective communication object
Definition: gridpart.hh:454
const Entity & convert(const Entity &entity) const
convert the grid's entity to a grid part entity Usually the parameter is GridType :: Codim< codim > :...
Definition: gridpart.hh:478
GridPartDefault(GridType &grid)
constructor
Definition: gridpart.hh:404
GridType & grid()
Returns reference to the underlying grid.
Definition: gridpart.hh:426
bool isConforming() const
returns true if current grid part represents a conforming grid
Definition: gridpart.hh:429
Traits::IndexSetType IndexSetType
Index set implementation.
Definition: gridpart.hh:382
BoundaryIdProvider< GridType > BoundaryIdProviderType
type of boundary id provider specialized for each grid type
Definition: gridpart.hh:397
DofManager< GridType > DofManagerType
type of DofManager
Definition: gridpart.hh:394
int size(const GeometryType &type) const
obtain number of entities with a given geometry type
Definition: gridpart.hh:442
Traits::IntersectionIteratorType IntersectionIteratorType
type of intersection iterator
Definition: gridpart.hh:385
Traits::GridType GridType
Grid implementation.
Definition: gridpart.hh:380
Interface for the GridPart classes A GridPart class allows to access only a specific subset of a grid...
Definition: gridpart.hh:76
void communicate(CommDataHandleIF< DataHandleImp, DataType > &data, InterfaceType iftype, CommunicationDirection dir) const
corresponding communication method for grid part
Definition: gridpart.hh:292
int sequence() const
return sequence number to update structures depending on the grid part
Definition: gridpart.hh:346
IndexSetType IndexSet
Index set implementation.
Definition: gridpart.hh:94
bool contains(const EntityType &e) const
Return true if the given entity is contained in this grid view.
Definition: gridpart.hh:327
GridType & grid()
Returns reference to the underlying grid.
Definition: gridpart.hh:168
GridPartTraits Traits
Type of the Traits.
Definition: gridpart.hh:81
Codim< codim >::IteratorType end() const
obtain end iterator for the interior-border partition
Definition: gridpart.hh:233
CommunicationType Communication
Collective communication.
Definition: gridpart.hh:99
int size(int codim) const
obtain number of entities in a given codimension
Definition: gridpart.hh:189
Codim< EntitySeed::codimension >::EntityType entity(const EntitySeed &seed) const
obtain entity pointer from entity seed
Definition: gridpart.hh:301
const GridType & grid() const
Returns const reference to the underlying grid.
Definition: gridpart.hh:162
Traits::CommunicationType CommunicationType
Collective communication.
Definition: gridpart.hh:97
Traits::GridType GridType
type of Grid implementation
Definition: gridpart.hh:87
Codim< codim >::IteratorType begin() const
obtain begin iterator for the interior-border partition
Definition: gridpart.hh:208
GridPartInterface()=default
do not create explicit instances of this class
Traits::TwistUtilityType TwistUtilityType
Twist utility type.
Definition: gridpart.hh:102
bool isConforming() const
returns true if current grid part represents a conforming grid
Definition: gridpart.hh:182
IntersectionIteratorType::Intersection IntersectionType
type of Intersection
Definition: gridpart.hh:116
Codim< codim >::template Partition< pitype >::IteratorType end() const
obtain end iterator for the given partition
Definition: gridpart.hh:246
const Entity & convert(const Entity &entity) const
convert the grid's entity to a grid part entity Usually the parameter is GridType :: Codim< codim > :...
Definition: gridpart.hh:314
Codim< codim >::template Partition< pitype >::IteratorType begin() const
obtain begin iterator for the given partition
Definition: gridpart.hh:221
IntersectionIteratorType IntersectionIterator
type of IntersectionIterator
Definition: gridpart.hh:113
int boundaryId(const IntersectionType &intersection) const
return boundary if given an intersection
Definition: gridpart.hh:277
IntersectionIteratorType iend(const typename Codim< 0 >::EntityType &entity) const
iend of corresponding intersection iterator for given entity
Definition: gridpart.hh:269
int size(const GeometryType &type) const
obtain number of entities with a given geometry type
Definition: gridpart.hh:196
const CommunicationType & comm() const
obtain collective communication object
Definition: gridpart.hh:284
const IndexSetType & indexSet() const
Returns reference to index set of the underlying grid.
Definition: gridpart.hh:175
static const PartitionIteratorType indexSetPartitionType
Maximum Partition type, the index set provides indices for.
Definition: gridpart.hh:106
Traits::IntersectionIteratorType IntersectionIteratorType
type of IntersectionIterator
Definition: gridpart.hh:111
Traits::GridPartType GridPartType
Type of the implementation.
Definition: gridpart.hh:84
IntersectionIteratorType ibegin(const typename Codim< 0 >::EntityType &entity) const
ibegin of corresponding intersection iterator for given entity
Definition: gridpart.hh:262
GridType Grid
type of Grid implementation
Definition: gridpart.hh:89
Traits::IndexSetType IndexSetType
Index set implementation.
Definition: gridpart.hh:92
int level() const
Level of the grid part.
Definition: gridpart.hh:254
IntersectionType Intersection
type of Intersection
Definition: gridpart.hh:118
Unique label for each type of entities that can occur in DUNE grids.
Definition: type.hh:114
Wrapper class for geometries.
Definition: geometry.hh:71
Default exception for dummy implementations.
Definition: exceptions.hh:263
Different resources needed by all grid implementations.
Describes the parallel communication interface class for MessageBuffers and DataHandles.
A few common exception classes.
static ThisType & instance(const GridType &grid)
obtain a reference to the DofManager for a given grid
Definition: dofmanager.hh:1251
#define DUNE_THROW(E, m)
Definition: exceptions.hh:218
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
Static tag representing a codimension.
Definition: dimension.hh:24
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Nov 24, 23:30, 2024)