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 ( const ThisType &rhs )
141 : gridView_( rhs.gridView_ ),
142 indexSet_( &gridView().indexSet() )
143 {}
144
152 const GridType &grid () const { return gridView().grid(); }
153 GridType &grid () { return const_cast< GridType & >( gridView().grid() ); }
154
156 bool isConforming() const
157 {
158 return gridView().isConforming();
159 }
160
162 const IndexSetType &indexSet () const { assert( indexSet_ ); return *indexSet_; }
163
165 template< int codim >
166 typename Codim< codim >::IteratorType begin () const
167 {
168 return begin< codim, InteriorBorder_Partition >();
169 }
170
172 template< int codim, PartitionIteratorType pitype >
173 typename Codim< codim >::template Partition< pitype >::IteratorType begin () const
174 {
175 return gridView().template begin< codim, pitype >();
176 }
177
179 template< int codim >
180 typename Codim< codim >::IteratorType end () const
181 {
182 return end< codim, InteriorBorder_Partition >();
183 }
184
186 template< int codim, PartitionIteratorType pitype >
187 typename Codim< codim >::template Partition< pitype >::IteratorType end () const
188 {
189 return gridView().template end< codim, pitype >();
190 }
191
193 IntersectionIteratorType ibegin ( const typename Codim< 0 >::EntityType &entity ) const
194 {
195 return gridView().ibegin( entity );
196 }
197
199 IntersectionIteratorType iend ( const typename Codim< 0 >::EntityType &entity ) const
200 {
201 return gridView().iend( entity );
202 }
203
205 const CommunicationType &comm () const { return gridView().comm(); }
206
208 template< class DataHandle, class DataType >
209 void communicate ( CommDataHandleIF< DataHandle, DataType > &dataHandle,
210 InterfaceType interface, CommunicationDirection direction ) const
211 {
212 gridView().communicate( dataHandle, interface, direction );
213 }
214
216 [[deprecated("Use DofManager::sequence instead!")]]
217 int sequence () const { return -1; }
218
220 template < class EntitySeed >
221 typename Codim< EntitySeed::codimension >::EntityType
222 entity ( const EntitySeed &seed ) const
223 {
224 return grid().entity( seed );
225 }
226
228 template <class Entity>
229 const Entity &convert( const Entity& entity ) const
230 {
231 return convert< Entity::codimension >( entity );
232 }
233
235 operator const GridView& () const { return gridView(); }
236
238 const GridView& gridView() const
239 {
240 if constexpr ( storeCopy )
241 {
242 return gridView_;
243 }
244 else
245 {
246 assert( gridView_ );
247 return *gridView_;
248 }
249 }
250
253 protected:
254 template< int codim >
255 const typename Codim< codim >::EntityType &
256 convert( const typename Codim< codim >::EntityType &entity ) const
257 {
258 return entity;
259 }
260
261 std::conditional_t<storeCopy, GridView, const GridView* > gridView_;
262 const IndexSetType* indexSet_;
263 };
264
265
266 // Capabilities
267 // ------------
268
269 namespace GridPartCapabilities
270 {
271
272 // Capabilities for GridView2GridPart
273 // -------------------------------------
274
275 template< class GridView, class Implementation, bool storeCopy >
276 struct hasGrid< GridView2GridPart< GridView, Implementation, storeCopy > >
277 {
278 static const bool v = true;
279 };
280
281 template< class GridView, class Implementation, bool storeCopy >
282 struct hasSingleGeometryType< GridView2GridPart< GridView, Implementation, storeCopy > >
283 {
285 static const unsigned int topologyId
287 };
288
289 template< class GridView, class Implementation, bool storeCopy >
290 struct isCartesian< GridView2GridPart< GridView, Implementation, storeCopy > >
291 {
293 };
294
295 template< class GridView, class Implementation, bool storeCopy, int codim >
296 struct hasEntity< GridView2GridPart< GridView, Implementation, storeCopy >, codim >
297 {
299 };
300
301 template< class GridView, class Implementation, bool storeCopy, int codim >
302 struct canCommunicate< GridView2GridPart< GridView, Implementation, storeCopy >, codim >
303 {
305 };
306
307 template< class GridView, class Implementation, bool storeCopy >
308 struct isConforming< GridView2GridPart< GridView, Implementation, storeCopy > >
309 {
311 };
312
313 }
314
315 } // namespace Fem
316
317} // namespace Dune
318
319#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 (Jul 27, 22:29, 2024)