DUNE-FEM (unstable)

gridpart2gridview.hh
1#ifndef DUNE_FEM_GRIDPART_COMMON_GRIDPART2GRIDVIEW_HH
2#define DUNE_FEM_GRIDPART_COMMON_GRIDPART2GRIDVIEW_HH
3
4#warning "This header should not be needed anymore. Remove it from the include list!"
5
6#include <cassert>
7
9
10#include <dune/grid/common/gridenums.hh>
11#include <dune/grid/common/gridview.hh>
12
13namespace Dune
14{
15
16#ifdef USING_DUNE_PYTHON
17 namespace FemPy
18 {
19 namespace detail
20 {
21 template< class Grid >
22 inline static void addGridModificationListener ( const Grid &grid );
23 }
24 }
25#endif
26 namespace Fem
27 {
28
29 template< class GridPart >
30 class GridPart2GridViewImpl;
31
32
33 template< class GridPart >
34 struct GridPart2GridViewTraits
35 {
36 typedef GridPart2GridViewImpl< GridPart > GridViewImp;
37
38 typedef typename GridPart::GridType Grid;
39 typedef typename GridPart::IndexSetType IndexSet;
40 typedef typename GridPart::IntersectionIteratorType IntersectionIterator;
41
42 typedef typename IntersectionIterator::Intersection Intersection;
43
44 typedef typename GridPart::CommunicationType Communication;
45
46 template< int codim >
47 struct Codim
48 : public Grid::Traits::template Codim< codim >
49 {
50 typedef typename GridPart::template Codim< codim >::EntityType Entity;
51
52 typedef typename GridPart::template Codim< codim >::GeometryType Geometry;
53 typedef typename GridPart::template Codim< codim >::LocalGeometryType LocalGeometry;
54
55 template< PartitionIteratorType pitype >
56 struct Partition
57 {
58 typedef typename GridPart::template Codim< codim >::template Partition< pitype >::IteratorType Iterator;
59 };
60
61 typedef typename Partition< All_Partition >::Iterator Iterator;
62 };
63
64 static const bool conforming = GridPart::Traits::conforming;
65 };
66
67
68 template< class GridPart >
69 class GridPart2GridViewImpl
70 {
71 typedef GridPart2GridViewImpl< GridPart > ThisType;
72
73 public:
74 typedef typename GridPart::ctype ctype;
75
76 typedef GridPart GridPartType;
77
78 typedef GridPart2GridViewTraits< GridPartType > Traits;
79
81 typedef typename Traits::Grid Grid;
82
84 typedef typename Traits::IndexSet IndexSet;
85
87 typedef typename Traits::Intersection Intersection;
88
90 typedef typename Traits::IntersectionIterator IntersectionIterator;
91
93 typedef typename Traits::Communication Communication;
94
96 template< int codim >
97 struct Codim
98 : public Traits::template Codim< codim >
99 {};
100
101 enum { conforming = Traits::conforming };
102
103 enum { dimension = GridPartType::dimension };
104 enum { dimensionworld = GridPartType::dimensionworld };
105
106 explicit GridPart2GridViewImpl ( const GridPartType &gridPart )
107 : gridPartStorage_(nullptr)
108 , gridPart_( &gridPart )
109 {}
110 template< class... Args,
111 std::enable_if_t< std::is_constructible< GridPartType, Args..., ThisType* >::value, int > = 0 >
112 GridPart2GridViewImpl( Args &&... args )
113 : gridPartStorage_(new GridPartType( std::forward< Args >( args )..., this) )
114 , gridPart_(gridPartStorage_.get())
115 {
116#ifdef USING_DUNE_PYTHON
117 // add grid modification listener (if not registered)
118 FemPy::detail::addGridModificationListener( gridPart().grid() );
119#endif
120 }
121
122 ~GridPart2GridViewImpl()
123 {}
124
125 const Grid &grid () const
126 {
127 return gridPart().grid();
128 }
129
130 const IndexSet &indexSet () const
131 {
132 return gridPart().indexSet();
133 }
134
135 int size ( int codim ) const
136 {
137 return indexSet().size( codim );
138 }
139
140 int size ( const GeometryType &type ) const
141 {
142 return indexSet().size( type );
143 }
144
145 template<class EntityType>
146 bool contains (const EntityType& e) const
147 {
148 return indexSet().contains(e);
149 }
150
151 template< int codim >
152 typename Codim< codim >::Iterator begin () const
153 {
154 return begin< codim, All_Partition >();
155 }
156
157 template< int codim, PartitionIteratorType pitype >
158 typename Codim< codim >::template Partition< pitype >::Iterator begin () const
159 {
160 return gridPart().template begin< codim, pitype >();
161 }
162
163 template< int codim >
164 typename Codim< codim >::Iterator end () const
165 {
166 return end< codim, All_Partition >();
167 }
168
169 template< int codim, PartitionIteratorType pitype >
170 typename Codim< codim >::template Partition< pitype >::Iterator end () const
171 {
172 return gridPart().template end< codim, pitype >();
173 }
174
175 IntersectionIterator ibegin ( const typename Codim< 0 >::Entity &entity ) const
176 {
177 return gridPart().ibegin( entity );
178 }
179
180 IntersectionIterator iend ( const typename Codim< 0 >::Entity &entity ) const
181 {
182 return gridPart().iend( entity );
183 }
184
185 const Communication &comm () const
186 {
187 return gridPart().comm();
188 }
189
190 int overlapSize ( int codim ) const
191 {
192 DUNE_THROW( NotImplemented, "Method ghostSize() not implemented yet" );
193 }
194
195 int ghostSize( int codim ) const
196 {
197 DUNE_THROW( NotImplemented, "Method ghostSize() not implemented yet" );
198 }
199
200 template< class DataHandleImp, class DataType >
201 void communicate ( CommDataHandleIF< DataHandleImp, DataType > &data,
202 InterfaceType iftype,
203 CommunicationDirection dir ) const
204 {
205 gridPart().communicate( data, iftype, dir );
206 }
207
208 const GridPartType &gridPart () const {
209 assert( gridPart_ );
210 return *gridPart_;
211 }
212
213 private:
214 std::shared_ptr<GridPartType> gridPartStorage_;
215 const GridPartType *gridPart_;
216 };
217
218
219
220 template< class GridPart >
221 class GridPart2GridView
222 : public GridView< GridPart2GridViewTraits< GridPart > >
223 {
224 typedef GridPart2GridView< GridPart > ThisType;
225 typedef GridView< GridPart2GridViewTraits< GridPart > > BaseType;
226
227 typedef typename BaseType::GridViewImp GridViewImp;
228
229 public:
230 explicit GridPart2GridView ( const GridPart &gridPart )
231 : BaseType( GridViewImp( gridPart ) )
232 {}
233 };
234
235 } // namespace Fem
236
237} // namespace Dune
238
239#endif // #ifndef DUNE_FEM_GRIDPART_COMMON_GRIDPART2GRIDVIEW_HH
Dune::Intersection< GridImp, IntersectionImp > Intersection
Type of Intersection this IntersectionIterator points to.
Definition: intersectioniterator.hh:111
A few common exception classes.
@ conforming
Output conforming data.
Definition: common.hh:73
#define DUNE_THROW(E, m)
Definition: exceptions.hh:218
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
constexpr std::integral_constant< std::size_t, sizeof...(II)> size(std::integer_sequence< T, II... >)
Return the size of the sequence.
Definition: integersequence.hh:75
constexpr std::bool_constant<((II==value)||...)> contains(std::integer_sequence< T, II... >, std::integral_constant< T, value >)
Checks whether or not a given sequence contains a value.
Definition: integersequence.hh:137
constexpr auto get(std::integer_sequence< T, II... >, std::integral_constant< std::size_t, pos >={})
Return the entry at position pos of the given sequence.
Definition: integersequence.hh:22
STL namespace.
Codim Structure.
Definition: gridpart2gridview.hh:99
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Nov 21, 23:30, 2024)