dune-grid 3.0-git
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 typedef typename GenericGeometry::SimplexTopology< mydimension >::type Topology;
115 return GeometryType( Topology() );
116 }
117
118
119
120 // AlbertaGridEntity (for codim = 0)
121 // ---------------------------------
122
123 template< int dim, class Grid >
125 ::AlbertaGridEntity ( const Grid &grid, const ElementInfo &elementInfo, int subEntity )
126 : grid_( &grid ),
127 elementInfo_( elementInfo )
128 {
129 assert( subEntity == 0 );
130 }
131
132 template< int dim, class Grid >
135 : grid_( &grid ),
136 elementInfo_()
137 {}
138
139 template< int dim, class Grid >
142 : grid_( NULL ),
143 elementInfo_()
144 {}
145
146
147 template< int dim, class Grid >
149 {
150 // elements are always inside of our Domain
151 return 0;
152 }
153
154
155 template< int dim, class Grid >
157 {
158 return grid().levelProvider().isNew( elementInfo_ );
159 }
160
161
162 template< int dim, class Grid >
164 {
165 return elementInfo_.mightVanish();
166 }
167
168
169 template< int dim, class Grid >
170 inline bool
172 {
173 assert( elementInfo_ );
174 bool isBoundary = false;
175 for( int i = 0; i < dim+1; ++i )
176 isBoundary |= elementInfo_.isBoundary( i );
177 return isBoundary;
178 }
179
180
181 template< int dim, class Grid >
182 inline PartitionType
187
188
189 template< int dim, class Grid >
191 {
192 return elementInfo_.isLeaf();
193 }
194
195
196 template< int dim, class Grid >
197 inline bool
199 {
200 // element pointers are unique
201 return (elementInfo().el() == other.elementInfo().el());
202 }
203
204
205 template< int dim, class Grid >
206 template< int codim >
207 inline typename Grid::template Codim< codim >::Entity
209 {
210 typedef AlbertaGridEntity< codim, dim, Grid > EntityImpl;
211 return EntityImpl( grid(), elementInfo_, grid().generic2alberta( codim, i ) );
212 }
213
214
215 template< int dim, class Grid >
216 inline ALBERTA EL_INFO *
218 {
219 return &(elementInfo_.elInfo());
220 }
221
222
223 template< int dim, class Grid >
225 {
226 assert( elementInfo_.level() == grid().levelProvider() ( elementInfo_ ) );
227 return elementInfo_.level();
228 }
229
230
231 template< int dim, class Grid >
232 inline void
237
238
239 template< int dim, class Grid >
241 ::setElement ( const ElementInfo &elementInfo, int subEntity )
242 {
243 elementInfo_ = elementInfo;
244 }
245
246
247 template< int dim, class Grid >
248 inline void
250 {
251 setElement( other.elementInfo_, 0 );
252 }
253
254
255 template< int dim, class Grid >
258 {
260
261 assert( elementInfo_ );
262 const CoordReader coordReader( grid(), elementInfo_, 0 );
263 return Geometry( GeometryImpl( coordReader ) );
264 }
265
266
267 template< int dim, class Grid >
268 inline GeometryType AlbertaGridEntity< 0, dim, Grid>::type () const
269 {
270 typedef typename GenericGeometry::SimplexTopology< mydimension >::type Topology;
271 return GeometryType( Topology() );
272 }
273
274
275 template< int dim, class Grid >
276 inline typename Grid::template Codim< 0 >::Entity
278 {
279 typedef AlbertaGridEntity< 0, dim, Grid > EntityImpl;
280
281 assert( elementInfo_ );
282 const ElementInfo fatherInfo = elementInfo_.father();
283
284 return EntityImpl( grid(), fatherInfo, 0 );
285 }
286
287
288 template< int dim, class Grid >
290 {
291 return elementInfo_.indexInFather();
292 }
293
294
295 template< int dim, class Grid >
296 inline typename AlbertaGridEntity< 0, dim, Grid >::LocalGeometry
298 {
300 const int indexInFather = elementInfo_.indexInFather();
301 const int orientation = (elementInfo_.type() == 1 ? -1 : 1);
302 return LocalGeometry( LocalGeoProvider::instance().geometryInFather( indexInFather, orientation ) );
303 }
304
305
306 template< int dim, class Grid >
309 {
310 assert( elementInfo_ );
311 typedef AlbertaGridHierarchicIterator< Grid > IteratorImp;
312 return IteratorImp( grid(), elementInfo_, maxlevel );
313 }
314
315
316 template< int dim, class Grid >
319 {
320 assert( elementInfo_ );
321 typedef AlbertaGridHierarchicIterator< Grid > IteratorImp;
322 return IteratorImp( grid(), level(), maxlevel );
323 }
324
325
326 template< int dim, class Grid >
329 {
330 assert( elementInfo_ );
331
332#ifndef NDEBUG
333 for( int i = 0; i <= dimension; ++i )
334 {
335 // std::cout << "Opposite vertex " << i << ": "
336 // << (int)(getElInfo()->opp_vertex[ i ]) << std::endl;
337 if( getElInfo()->opp_vertex[ i ] == 127 )
338 {
339 assert( false );
340 DUNE_THROW( NotImplemented, "AlbertaGrid: Intersections on outside "
341 "entities are not fully implemented, yet." );
342 }
343 }
344#endif // #ifndef NDEBUG
345
347 return AlbertaGridLeafIntersectionIterator( *this, begin );
348 }
349
350
351 template< int dim, class Grid >
354 {
355 assert( elementInfo_ );
357 return AlbertaGridLeafIntersectionIterator( *this, end );
358 }
359
360} // namespace Dune
361
362#endif // #ifndef DUNE_ALBERTA_ENTITY_CC
#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
Include standard header files.
Definition agrid.hh:60
ALBERTA EL Element
Definition misc.hh:51
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:29
Definition albertagrid/intersectioniterator.hh:25
Definition albertagrid/entity.hh:47
void clearElement()
Definition entity.cc:68
int twist() const
obtain twist
Definition albertagrid/entity.hh:132
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:70
void setEntity(const This &other)
Definition entity.cc:85
const ElementInfo & elementInfo() const
Definition albertagrid/entity.hh:108
Geometry geometry() const
geometry of this entity
Definition entity.cc:101
static const int dimension
Definition albertagrid/entity.hh:58
const Grid & grid() const
obtain a reference to the grid
Definition albertagrid/entity.hh:120
int subEntity() const
obtain number of the subentity within the element (in ALBERTA numbering)
Definition albertagrid/entity.hh:126
Alberta::ElementInfo< dimension > ElementInfo
Definition albertagrid/entity.hh:72
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:163
Grid::Traits::template Codim< 0 >::GeometryImpl GeometryImpl
Definition albertagrid/entity.hh:190
Grid::template Codim< 0 >::LocalGeometry LocalGeometry
Definition albertagrid/entity.hh:189
Definition albertagrid/geometry.hh:28
Definition albertagrid/geometry.hh:474
Definition albertagrid/intersectioniterator.hh:33
Definition albertagrid/intersectioniterator.hh:34
Grid abstract base class.
Definition common/grid.hh:373