dune-grid 2.10
Loading...
Searching...
No Matches
entity.cc
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright © DUNE Project contributors, see file LICENSE.md in module root
2// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception
3// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
4// vi: set et ts=4 sw=2 sts=2:
5#ifndef DUNE_ALBERTA_ENTITY_CC
6#define DUNE_ALBERTA_ENTITY_CC
7
8namespace Dune
9{
10
11 // AlbertaGridEntity (for codim > 0)
12 // ---------------------------------
13
14 template<int codim, int dim, class Grid>
15 inline AlbertaGridEntity< codim, dim, Grid >
16 ::AlbertaGridEntity ( const Grid &grid, const ElementInfo &elementInfo, int subEntity )
17 : grid_( &grid ),
18 elementInfo_( elementInfo ),
19 subEntity_( subEntity )
20 {}
21
22 template<int codim, int dim, class Grid>
25 : grid_( &grid ),
26 elementInfo_(),
27 subEntity_( -1 )
28 {}
29
30 template<int codim, int dim, class Grid>
33 : grid_( NULL ),
34 elementInfo_(),
35 subEntity_( -1 )
36 {}
37
38 template< int codim, int dim, class Grid >
39 inline PartitionType
44
45
46 template< int codim, int dim, class Grid >
47 inline bool
49 {
50 const Alberta::Element *e1 = elementInfo().el();
51 const Alberta::Element *e2 = other.elementInfo().el();
52
53 // if both element null then they are equal
54 if( (e1 == NULL) && (e2 == NULL) )
55 return true;
56 return ((e1 == e2) && (subEntity_ == other.subEntity_));
57 }
58
59
60 template< int codim, int dim, class Grid >
61 inline ALBERTA EL_INFO *
63 {
64 return &(elementInfo_.elInfo());
65 }
66
67
68 template< int codim, int dim, class Grid >
69 inline void
74
75
76 template< int codim, int dim, class Grid >
78 ::setElement ( const ElementInfo &elementInfo, int subEntity )
79 {
80 elementInfo_ = elementInfo;
81 subEntity_ = subEntity;
82 }
83
84
85 template< int codim, int dim, class Grid >
86 inline void
88 {
89 setElement( other.elementInfo_, other.subEntity_ );
90 }
91
92
93 template< int codim, int dim, class Grid >
95 {
96 assert( elementInfo_.level() == grid().levelProvider() ( elementInfo_ ) );
97 return elementInfo_.level();
98 }
99
100
101 template< int codim, int dim, class Grid >
104 {
106
107 assert( elementInfo_ );
108 const CoordReader coordReader( grid(), elementInfo_, subEntity_ );
109 return Geometry( GeometryImpl( coordReader ) );
110 }
111
112
113 template< int codim, int dim, class Grid >
115 {
116 return GeometryTypes::simplex( mydimension );
117 }
118
119
120
121 // AlbertaGridEntity (for codim = 0)
122 // ---------------------------------
123
124 template< int dim, class Grid >
126 ::AlbertaGridEntity ( const Grid &grid, const ElementInfo &elementInfo, int subEntity )
127 : grid_( &grid ),
128 elementInfo_( elementInfo )
129 {
130 assert( subEntity == 0 );
131 }
132
133 template< int dim, class Grid >
136 : grid_( &grid ),
137 elementInfo_()
138 {}
139
140 template< int dim, class Grid >
143 : grid_( NULL ),
144 elementInfo_()
145 {}
146
147
148 template< int dim, class Grid >
150 {
151 // elements are always inside of our Domain
152 return 0;
153 }
154
155
156 template< int dim, class Grid >
158 {
159 return grid().levelProvider().isNew( elementInfo_ );
160 }
161
162
163 template< int dim, class Grid >
165 {
166 return elementInfo_.mightVanish();
167 }
168
169
170 template< int dim, class Grid >
171 inline bool
173 {
174 assert( elementInfo_ );
175 bool isBoundary = false;
176 for( int i = 0; i < dim+1; ++i )
177 isBoundary |= elementInfo_.isBoundary( i );
178 return isBoundary;
179 }
180
181
182 template< int dim, class Grid >
183 inline PartitionType
188
189
190 template< int dim, class Grid >
192 {
193 return elementInfo_.isLeaf();
194 }
195
196
197 template< int dim, class Grid >
198 inline bool
200 {
201 // element pointers are unique
202 return (elementInfo().el() == other.elementInfo().el());
203 }
204
205
206 template< int dim, class Grid >
207 template< int codim >
208 inline typename Grid::template Codim< codim >::Entity
210 {
211 typedef AlbertaGridEntity< codim, dim, Grid > EntityImpl;
212 return EntityImpl( grid(), elementInfo_, grid().generic2alberta( codim, i ) );
213 }
214
215
216 template< int dim, class Grid >
217 inline ALBERTA EL_INFO *
219 {
220 return &(elementInfo_.elInfo());
221 }
222
223
224 template< int dim, class Grid >
226 {
227 assert( elementInfo_.level() == grid().levelProvider() ( elementInfo_ ) );
228 return elementInfo_.level();
229 }
230
231
232 template< int dim, class Grid >
233 inline void
238
239
240 template< int dim, class Grid >
242 ::setElement ( const ElementInfo &elementInfo, int /* subEntity */ )
243 {
244 elementInfo_ = elementInfo;
245 }
246
247
248 template< int dim, class Grid >
249 inline void
251 {
252 setElement( other.elementInfo_, 0 );
253 }
254
255
256 template< int dim, class Grid >
259 {
260 typedef AlbertaGridCoordinateReader< 0, Grid > CoordReader;
261
262 assert( elementInfo_ );
263 const CoordReader coordReader( grid(), elementInfo_, 0 );
264 return Geometry( GeometryImpl( coordReader ) );
265 }
266
267
268 template< int dim, class Grid >
269 inline GeometryType AlbertaGridEntity< 0, dim, Grid>::type () const
270 {
271 return GeometryTypes::simplex( mydimension );
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 {
299 typedef AlbertaGridLocalGeometryProvider< Grid > LocalGeoProvider;
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:29
PartitionType
Attributes used in the generic overlap model.
Definition gridenums.hh:30
@ InteriorEntity
all interior entities
Definition gridenums.hh:31
Include standard header files.
Definition agrid.hh:60
ALBERTA EL Element
Definition misc.hh:54
int level() const
Definition elementinfo.hh:533
bool mightVanish() const
Definition elementinfo.hh:526
ElementInfo father() const
Definition elementinfo.hh:449
int type() const
Definition elementinfo.hh:540
bool isBoundary(int face) const
Definition elementinfo.hh:620
int indexInFather() const
Definition elementinfo.hh:457
ALBERTA EL_INFO & elInfo() const
Definition elementinfo.hh:744
Definition hierarchiciterator.hh:29
Definition albertagrid/intersectioniterator.hh:27
Definition albertagrid/entity.hh:46
void clearElement()
Definition entity.cc:70
ALBERTA EL_INFO * getElInfo() const
needed for the LevelIterator and LeafIterator
Definition entity.cc:62
int level() const
level of this element
Definition entity.cc:94
void setElement(const ElementInfo &elementInfo, int subEntity)
Definition entity.cc:78
PartitionType partitionType() const
return partition type of this entity
Definition entity.cc:40
Grid::template Codim< codim >::Geometry Geometry
Definition albertagrid/entity.hh:69
void setEntity(const This &other)
Definition entity.cc:87
const ElementInfo & elementInfo() const
Definition albertagrid/entity.hh:130
Geometry geometry() const
geometry of this entity
Definition entity.cc:103
static const int dimension
Definition albertagrid/entity.hh:57
const Grid & grid() const
obtain a reference to the grid
Definition albertagrid/entity.hh:142
int subEntity() const
obtain number of the subentity within the element (in ALBERTA numbering)
Definition albertagrid/entity.hh:148
Alberta::ElementInfo< dimension > ElementInfo
Definition albertagrid/entity.hh:71
GeometryType type() const
type of geometry of this entity
Definition entity.cc:114
bool equals(const This &other) const
equality of entities
Definition entity.cc:48
Definition albertagrid/entity.hh:63
Definition albertagrid/entity.hh:185
Grid::Traits::template Codim< 0 >::GeometryImpl GeometryImpl
Definition albertagrid/entity.hh:211
const ElementInfo & elementInfo() const
Definition albertagrid/entity.hh:355
Grid::template Codim< 0 >::LocalGeometry LocalGeometry
Definition albertagrid/entity.hh:210
Definition albertagrid/geometry.hh:30
Definition albertagrid/geometry.hh:504
Definition albertagrid/intersectioniterator.hh:35
Definition albertagrid/intersectioniterator.hh:36
Grid abstract base class.
Definition common/grid.hh:375
A Traits struct that collects all associated types of one implementation.
Definition common/grid.hh:411