DUNE-FEM (unstable)

gridview2gridpart.hh
1#ifndef DUNE_FEM_GRIDPART_COMMON_GRIDVIEW2GRIDPART_HH
2#define DUNE_FEM_GRIDPART_COMMON_GRIDVIEW2GRIDPART_HH
3
4#include <utility>
5#include <functional>
6
8
9#include <dune/grid/common/gridenums.hh>
10
11#include <dune/fem/gridpart/common/gridpart.hh>
12#include <dune/fem/quadrature/caching/twistutility.hh>
13#include <dune/fem/space/common/dofmanager.hh>
14
15namespace Dune
16{
17
18 namespace Fem
19 {
20
21 // Internal forward declaration
22 // ----------------------------
23
24 template< class GridView, class Implementation, bool storeCopy=true >
25 class GridView2GridPart;
26
27
28
29#ifndef DOXYGEN
30
31 // GridView2GridPartTraits
32 // -----------------------
33
34 template< class GridView, class Implementation, bool storeCopy >
35 struct GridView2GridPartTraits
36 {
37 typedef Implementation GridPartType;
38
39 typedef GridView GridViewType;
40 static const bool conforming = GridView::conforming;
41
42 typedef typename GridViewType::Grid GridType;
43 typedef typename GridViewType::Communication CommunicationType;
44
45 typedef typename GridView::IndexSet IndexSetType;
46
47 template< int codim >
48 struct Codim
49 {
50 typedef typename GridViewType::template Codim< codim >::Entity EntityType;
51 typedef typename GridType::template Codim< codim >::EntitySeed EntitySeedType;
52
53 typedef typename GridViewType::template Codim< codim >::Geometry GeometryType;
54 typedef typename GridViewType::template Codim< codim >::LocalGeometry LocalGeometryType;
55
56 template< PartitionIteratorType pitype >
57 struct Partition
58 {
59 typedef typename GridViewType::template Codim< codim >::template Partition< pitype >::Iterator IteratorType;
60 };
61 };
62
63 typedef typename GridViewType::IntersectionIterator IntersectionIteratorType;
64
65 typedef TwistUtility< GridType > TwistUtilityType;
66
67 // partition on which indices are defined
68 static const PartitionIteratorType indexSetPartitionType = All_Partition;
69 // partition identifiers for default communication
70 static const InterfaceType indexSetInterfaceType = InteriorBorder_All_Interface;
71 };
72
73#endif // #ifndef DOXYGEN
74
75
76
77 // GridView2GridPart
78 // -----------------
79
80 template< class GridView, class Implementation, bool storeCopy >
81 class GridView2GridPart
82 : public GridPartInterface< GridView2GridPartTraits< GridView, Implementation, storeCopy > >
83 {
84 typedef GridView2GridPart< GridView, Implementation, storeCopy > ThisType;
85 typedef GridView2GridPartTraits< GridView, Implementation, storeCopy > TraitsType;
86 typedef GridPartInterface< TraitsType > BaseType;
87
88 public:
90 typedef typename BaseType::GridType GridType;
91
93 typedef typename BaseType::GridViewType GridViewType;
94
95 template< int codim >
96 struct Codim
97 : public BaseType::template Codim< codim >
98 {};
99
101 typedef typename BaseType::IntersectionIteratorType IntersectionIteratorType;
102
104 typedef typename BaseType::IndexSetType IndexSetType;
105
107 typedef typename BaseType::CommunicationType CommunicationType;
108
109 private:
110 typedef DofManager< GridType > DofManagerType;
111
112 auto initGv( const GridView &gridView )
113 {
114 if constexpr ( storeCopy )
115 return gridView;
116 else
117 return &gridView;
118 }
119 public:
120 using BaseType::grid;
122
127 explicit GridView2GridPart ( const GridView &gridView )
128 : gridView_( initGv( gridView ) ),
129 indexSet_( &this->gridView().indexSet() )
130 {}
131
132 explicit GridView2GridPart ( GridView &&gridView )
133 : gridView_( std::move( gridView ) ),
134 indexSet_( &this->gridView().indexSet() )
135 {
136 // this should not be called if we only store a pointer
137 assert( storeCopy );
138 }
139
140 GridView2GridPart& operator= (const GridView2GridPart& other ) = default;
141
142 GridView2GridPart ( const ThisType &rhs )
143 : gridView_( rhs.gridView_ ),
144 indexSet_( &gridView().indexSet() )
145 {}
146
154 const GridType &grid () const { return gridView().grid(); }
155 GridType &grid () { return const_cast< GridType & >( gridView().grid() ); }
156
158 bool isConforming() const
159 {
160 return gridView().isConforming();
161 }
162
164 const IndexSetType &indexSet () const { assert( indexSet_ ); return *indexSet_; }
165
167 template< int codim >
168 typename Codim< codim >::IteratorType begin () const
169 {
170 return begin< codim, InteriorBorder_Partition >();
171 }
172
174 template< int codim, PartitionIteratorType pitype >
175 typename Codim< codim >::template Partition< pitype >::IteratorType begin () const
176 {
177 return gridView().template begin< codim, pitype >();
178 }
179
181 template< int codim >
182 typename Codim< codim >::IteratorType end () const
183 {
184 return end< codim, InteriorBorder_Partition >();
185 }
186
188 template< int codim, PartitionIteratorType pitype >
189 typename Codim< codim >::template Partition< pitype >::IteratorType end () const
190 {
191 return gridView().template end< codim, pitype >();
192 }
193
195 IntersectionIteratorType ibegin ( const typename Codim< 0 >::EntityType &entity ) const
196 {
197 return gridView().ibegin( entity );
198 }
199
201 IntersectionIteratorType iend ( const typename Codim< 0 >::EntityType &entity ) const
202 {
203 return gridView().iend( entity );
204 }
205
207 const CommunicationType &comm () const { return gridView().comm(); }
208
210 template< class DataHandle, class DataType >
211 void communicate ( CommDataHandleIF< DataHandle, DataType > &dataHandle,
212 InterfaceType interface, CommunicationDirection direction ) const
213 {
214 gridView().communicate( dataHandle, interface, direction );
215 }
216
218 [[deprecated("Use DofManager::sequence instead!")]]
219 int sequence () const { return -1; }
220
222 template < class EntitySeed >
223 typename Codim< EntitySeed::codimension >::EntityType
224 entity ( const EntitySeed &seed ) const
225 {
226 return grid().entity( seed );
227 }
228
230 template <class Entity>
231 const Entity &convert( const Entity& entity ) const
232 {
233 return convert< Entity::codimension >( entity );
234 }
235
237 operator const GridView& () const { return gridView(); }
238
240 const GridView& gridView() const
241 {
242 if constexpr ( storeCopy )
243 {
244 return gridView_;
245 }
246 else
247 {
248 assert( gridView_ );
249 return *gridView_;
250 }
251 }
252
255 protected:
256 template< int codim >
257 const typename Codim< codim >::EntityType &
258 convert( const typename Codim< codim >::EntityType &entity ) const
259 {
260 return entity;
261 }
262
263 std::conditional_t<storeCopy, GridView, const GridView* > gridView_;
264 const IndexSetType* indexSet_;
265 };
266
267
268 // Capabilities
269 // ------------
270
271 namespace GridPartCapabilities
272 {
273
274 // Capabilities for GridView2GridPart
275 // -------------------------------------
276
277 template< class GridView, class Implementation, bool storeCopy >
278 struct hasGrid< GridView2GridPart< GridView, Implementation, storeCopy > >
279 {
280 static const bool v = true;
281 };
282
283 template< class GridView, class Implementation, bool storeCopy >
284 struct hasSingleGeometryType< GridView2GridPart< GridView, Implementation, storeCopy > >
285 {
287 static const unsigned int topologyId
289 };
290
291 template< class GridView, class Implementation, bool storeCopy >
292 struct isCartesian< GridView2GridPart< GridView, Implementation, storeCopy > >
293 {
295 };
296
297 template< class GridView, class Implementation, bool storeCopy, int codim >
298 struct hasEntity< GridView2GridPart< GridView, Implementation, storeCopy >, codim >
299 {
301 };
302
303 template< class GridView, class Implementation, bool storeCopy, int codim >
304 struct canCommunicate< GridView2GridPart< GridView, Implementation, storeCopy >, codim >
305 {
307 };
308
309 template< class GridView, class Implementation, bool storeCopy >
310 struct isConforming< GridView2GridPart< GridView, Implementation, storeCopy > >
311 {
313 };
314
315 }
316
317 } // namespace Fem
318
319} // namespace Dune
320
321#endif // #ifndef DUNE_FEM_GRIDPART_COMMON_GRIDVIEW2GRIDPART_HH
void communicate(CommDataHandleIF< DataHandleImp, DataType > &data, InterfaceType iftype, CommunicationDirection dir) const
corresponding communication method for grid part
Definition: gridpart.hh:292
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
int boundaryId(const IntersectionType &intersection) const
return boundary if given an intersection
Definition: gridpart.hh:277
Traits::IntersectionIteratorType IntersectionIteratorType
type of IntersectionIterator
Definition: gridpart.hh:111
Traits::IndexSetType IndexSetType
Index set implementation.
Definition: gridpart.hh:92
A few common exception classes.
@ conforming
Output conforming data.
Definition: common.hh:73
GeometryType
Type representing VTK's entity geometry types.
Definition: common.hh:132
static constexpr bool conforming
Export if this grid view is guaranteed conforming.
Definition: gridview.hh:128
Traits::IndexSet IndexSet
type of the index set
Definition: gridview.hh:86
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
@ All_Partition
all entities
Definition: gridenums.hh:141
@ InteriorBorder_All_Interface
send interior and border, receive all entities
Definition: gridenums.hh:88
Dune namespace.
Definition: alignedallocator.hh:13
STL namespace.
specialize with 'true' for all codims that a grid can communicate data on (default=false)
Definition: capabilities.hh:97
Specialize with 'true' for all codims that a grid implements entities for. (default=false)
Definition: capabilities.hh:58
Specialize with 'true' for if the codimension 0 entity of the grid has only one possible geometry typ...
Definition: capabilities.hh:27
Specialize with 'true' if the grid is a Cartesian grid. Cartesian grids satisfy the following propert...
Definition: capabilities.hh:48
Specialize with 'true' if implementation guarantees a conforming leaf grid. (default=false)
Definition: capabilities.hh:115
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Nov 21, 23:30, 2024)