dune-grid 2.8.0
Loading...
Searching...
No Matches
entity.cc
Go to the documentation of this file.
1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2// vi: set et ts=4 sw=2 sts=2:
3#ifndef DUNE_ALBERTA_ENTITY_CC
4#define DUNE_ALBERTA_ENTITY_CC
5
6namespace Dune
7{
8
9 // AlbertaGridEntity (for codim > 0)
10 // ---------------------------------
11
12 template<int codim, int dim, class Grid>
13 inline AlbertaGridEntity< codim, dim, Grid >
14 ::AlbertaGridEntity ( const Grid &grid, const ElementInfo &elementInfo, int subEntity )
15 : grid_( &grid ),
16 elementInfo_( elementInfo ),
17 subEntity_( subEntity )
18 {}
19
20 template<int codim, int dim, class Grid>
23 : grid_( &grid ),
24 elementInfo_(),
25 subEntity_( -1 )
26 {}
27
28 template<int codim, int dim, class Grid>
31 : grid_( NULL ),
32 elementInfo_(),
33 subEntity_( -1 )
34 {}
35
36 template< int codim, int dim, class Grid >
37 inline PartitionType
42
43
44 template< int codim, int dim, class Grid >
45 inline bool
47 {
48 const Alberta::Element *e1 = elementInfo().el();
49 const Alberta::Element *e2 = other.elementInfo().el();
50
51 // if both element null then they are equal
52 if( (e1 == NULL) && (e2 == NULL) )
53 return true;
54 return ((e1 == e2) && (subEntity_ == other.subEntity_));
55 }
56
57
58 template< int codim, int dim, class Grid >
59 inline ALBERTA EL_INFO *
61 {
62 return &(elementInfo_.elInfo());
63 }
64
65
66 template< int codim, int dim, class Grid >
67 inline void
72
73
74 template< int codim, int dim, class Grid >
76 ::setElement ( const ElementInfo &elementInfo, int subEntity )
77 {
78 elementInfo_ = elementInfo;
79 subEntity_ = subEntity;
80 }
81
82
83 template< int codim, int dim, class Grid >
84 inline void
86 {
87 setElement( other.elementInfo_, other.subEntity_ );
88 }
89
90
91 template< int codim, int dim, class Grid >
93 {
94 assert( elementInfo_.level() == grid().levelProvider() ( elementInfo_ ) );
95 return elementInfo_.level();
96 }
97
98
99 template< int codim, int dim, class Grid >
102 {
104
105 assert( elementInfo_ );
106 const CoordReader coordReader( grid(), elementInfo_, subEntity_ );
107 return Geometry( GeometryImpl( coordReader ) );
108 }
109
110
111 template< int codim, int dim, class Grid >
113 {
114 return GeometryTypes::simplex( mydimension );
115 }
116
117
118
119 // AlbertaGridEntity (for codim = 0)
120 // ---------------------------------
121
122 template< int dim, class Grid >
124 ::AlbertaGridEntity ( const Grid &grid, const ElementInfo &elementInfo, int subEntity )
125 : grid_( &grid ),
126 elementInfo_( elementInfo )
127 {
128 assert( subEntity == 0 );
129 }
130
131 template< int dim, class Grid >
134 : grid_( &grid ),
135 elementInfo_()
136 {}
137
138 template< int dim, class Grid >
141 : grid_( NULL ),
142 elementInfo_()
143 {}
144
145
146 template< int dim, class Grid >
148 {
149 // elements are always inside of our Domain
150 return 0;
151 }
152
153
154 template< int dim, class Grid >
156 {
157 return grid().levelProvider().isNew( elementInfo_ );
158 }
159
160
161 template< int dim, class Grid >
163 {
164 return elementInfo_.mightVanish();
165 }
166
167
168 template< int dim, class Grid >
169 inline bool
171 {
172 assert( elementInfo_ );
173 bool isBoundary = false;
174 for( int i = 0; i < dim+1; ++i )
175 isBoundary |= elementInfo_.isBoundary( i );
176 return isBoundary;
177 }
178
179
180 template< int dim, class Grid >
181 inline PartitionType
186
187
188 template< int dim, class Grid >
190 {
191 return elementInfo_.isLeaf();
192 }
193
194
195 template< int dim, class Grid >
196 inline bool
198 {
199 // element pointers are unique
200 return (elementInfo().el() == other.elementInfo().el());
201 }
202
203
204 template< int dim, class Grid >
205 template< int codim >
206 inline typename Grid::template Codim< codim >::Entity
208 {
209 typedef AlbertaGridEntity< codim, dim, Grid > EntityImpl;
210 return EntityImpl( grid(), elementInfo_, grid().generic2alberta( codim, i ) );
211 }
212
213
214 template< int dim, class Grid >
215 inline ALBERTA EL_INFO *
217 {
218 return &(elementInfo_.elInfo());
219 }
220
221
222 template< int dim, class Grid >
224 {
225 assert( elementInfo_.level() == grid().levelProvider() ( elementInfo_ ) );
226 return elementInfo_.level();
227 }
228
229
230 template< int dim, class Grid >
231 inline void
236
237
238 template< int dim, class Grid >
240 ::setElement ( const ElementInfo &elementInfo, int /* subEntity */ )
241 {
242 elementInfo_ = elementInfo;
243 }
244
245
246 template< int dim, class Grid >
247 inline void
249 {
250 setElement( other.elementInfo_, 0 );
251 }
252
253
254 template< int dim, class Grid >
257 {
259
260 assert( elementInfo_ );
261 const CoordReader coordReader( grid(), elementInfo_, 0 );
262 return Geometry( GeometryImpl( coordReader ) );
263 }
264
265
266 template< int dim, class Grid >
268 {
269 return GeometryTypes::simplex( mydimension );
270 }
271
272
273 template< int dim, class Grid >
274 inline typename Grid::template Codim< 0 >::Entity
276 {
277 typedef AlbertaGridEntity< 0, dim, Grid > EntityImpl;
278
279 assert( elementInfo_ );
280 const ElementInfo fatherInfo = elementInfo_.father();
281
282 return EntityImpl( grid(), fatherInfo, 0 );
283 }
284
285
286 template< int dim, class Grid >
288 {
289 return elementInfo_.indexInFather();
290 }
291
292
293 template< int dim, class Grid >
294 inline typename AlbertaGridEntity< 0, dim, Grid >::LocalGeometry
296 {
298 const int indexInFather = elementInfo_.indexInFather();
299 const int orientation = (elementInfo_.type() == 1 ? -1 : 1);
300 return LocalGeometry( LocalGeoProvider::instance().geometryInFather( indexInFather, orientation ) );
301 }
302
303
304 template< int dim, class Grid >
307 {
308 assert( elementInfo_ );
309 typedef AlbertaGridHierarchicIterator< Grid > IteratorImp;
310 return IteratorImp( grid(), elementInfo_, maxlevel );
311 }
312
313
314 template< int dim, class Grid >
317 {
318 assert( elementInfo_ );
319 typedef AlbertaGridHierarchicIterator< Grid > IteratorImp;
320 return IteratorImp( grid(), level(), maxlevel );
321 }
322
323
324 template< int dim, class Grid >
327 {
328 assert( elementInfo_ );
329
330#ifndef NDEBUG
331 for( int i = 0; i <= dimension; ++i )
332 {
333 // std::cout << "Opposite vertex " << i << ": "
334 // << (int)(getElInfo()->opp_vertex[ i ]) << std::endl;
335 if( getElInfo()->opp_vertex[ i ] == 127 )
336 {
337 assert( false );
338 DUNE_THROW( NotImplemented, "AlbertaGrid: Intersections on outside "
339 "entities are not fully implemented, yet." );
340 }
341 }
342#endif // #ifndef NDEBUG
343
346 }
347
348
349 template< int dim, class Grid >
357
358} // namespace Dune
359
360#endif // #ifndef DUNE_ALBERTA_ENTITY_CC
iterator end()
iterator begin()
size_type dim() const
#define DUNE_THROW(E, m)
#define ALBERTA
Definition albertaheader.hh:27
PartitionType
Attributes used in the generic overlap model.
Definition gridenums.hh:28
@ InteriorEntity
all interior entities
Definition gridenums.hh:29
ALBERTA EL Element
Definition misc.hh:52
Include standard header files.
int level() const
Definition elementinfo.hh:531
bool mightVanish() const
Definition elementinfo.hh:524
ElementInfo father() const
Definition elementinfo.hh:447
int type() const
Definition elementinfo.hh:538
bool isBoundary(int face) const
Definition elementinfo.hh:618
int indexInFather() const
Definition elementinfo.hh:455
Element * el() const
Definition elementinfo.hh:735
ALBERTA EL_INFO & elInfo() const
Definition elementinfo.hh:742
Definition hierarchiciterator.hh:27
Definition albertagrid/intersectioniterator.hh:25
Definition albertagrid/entity.hh:44
void clearElement()
Definition entity.cc:68
ALBERTA EL_INFO * getElInfo() const
needed for the LevelIterator and LeafIterator
Definition entity.cc:60
int level() const
level of this element
Definition entity.cc:92
void setElement(const ElementInfo &elementInfo, int subEntity)
Definition entity.cc:76
PartitionType partitionType() const
return partition type of this entity
Definition entity.cc:38
Grid::template Codim< codim >::Geometry Geometry
Definition albertagrid/entity.hh:67
void setEntity(const This &other)
Definition entity.cc:85
const ElementInfo & elementInfo() const
Definition albertagrid/entity.hh:128
Geometry geometry() const
geometry of this entity
Definition entity.cc:101
static const int dimension
Definition albertagrid/entity.hh:55
const Grid & grid() const
obtain a reference to the grid
Definition albertagrid/entity.hh:140
int subEntity() const
obtain number of the subentity within the element (in ALBERTA numbering)
Definition albertagrid/entity.hh:146
Alberta::ElementInfo< dimension > ElementInfo
Definition albertagrid/entity.hh:69
GeometryType type() const
type of geometry of this entity
Definition entity.cc:112
bool equals(const This &other) const
equality of entities
Definition entity.cc:46
Definition albertagrid/entity.hh:183
Grid::Traits::template Codim< 0 >::GeometryImpl GeometryImpl
Definition albertagrid/entity.hh:209
const ElementInfo & elementInfo() const
Definition albertagrid/entity.hh:353
Grid::template Codim< 0 >::LocalGeometry LocalGeometry
Definition albertagrid/entity.hh:208
Definition albertagrid/geometry.hh:28
Definition albertagrid/geometry.hh:472
Definition albertagrid/intersectioniterator.hh:33
Definition albertagrid/intersectioniterator.hh:34
Grid abstract base class.
Definition common/grid.hh:372