Dune Core Modules (2.9.0)

entity_inline.hh
1 #ifndef ALUGRID_ENTITY_INLINE_HH
2 #define ALUGRID_ENTITY_INLINE_HH
4 
5 #include "geometry.hh"
6 #include "grid.hh"
7 
8 
9 namespace Dune {
10 
12  //
13  // --Entity0
14  // --Codim0Entity
15  //
17  /*
18  template<int dim, class GridImp>
19  inline void ALU3dGridEntity<0,dim,GridImp> ::
20  removeElement ()
21  {
22  item_ = 0;
23  ghost_ = 0;
24  geo_.invalidate();
25  }
26 
27  template<int dim, class GridImp>
28  inline void ALU3dGridEntity<0,dim,GridImp> ::
29  reset (int walkLevel )
30  {
31  item_ = 0;
32  ghost_ = 0;
33 
34  // reset geometry information
35  geo_.invalidate();
36  }
37 
38  // works like assignment
39  template<int dim, class GridImp>
40  inline void
41  ALU3dGridEntity<0,dim,GridImp> :: setEntity(const ALU3dGridEntity<0,dim,GridImp> & org)
42  {
43  item_ = org.item_;
44  ghost_ = org.ghost_;
45 
46  // reset geometry information
47  geo_.invalidate();
48  }
49 
50  template<int dim, class GridImp>
51  inline void
52  ALU3dGridEntity<0,dim,GridImp>::
53  setElement(const EntitySeed& key )
54  {
55  if( ! key.isGhost() )
56  setElement( *key.interior() );
57  else
58  setGhost( *key.ghost() );
59  }
60 
61  template<int dim, class GridImp>
62  inline void
63  ALU3dGridEntity<0,dim,GridImp>::
64  setElement(HElementType & element)
65  {
66  item_ = static_cast<IMPLElementType *> (&element);
67  alugrid_assert ( item_ );
68  // make sure this method is not called for ghosts
69  alugrid_assert ( ! item_->isGhost() );
70  ghost_ = 0;
71 
72  // reset geometry information
73  geo_.invalidate();
74  }
75 
76  template<int dim, class GridImp>
77  inline void
78  ALU3dGridEntity<0,dim,GridImp> :: setGhost(HBndSegType & ghost)
79  {
80  // use element as ghost
81  item_ = static_cast<IMPLElementType *> ( ghost.getGhost().first );
82 
83  // method getGhost can return 0, but then is something wrong
84  alugrid_assert (item_);
85  alugrid_assert (item_->isGhost());
86 
87  // remember pointer to ghost face
88  ghost_ = static_cast<BNDFaceType *> (&ghost);
89  alugrid_assert ( ghost_ );
90 
91  // check wether ghost is leaf or not, ghost leaf means
92  // that this is the ghost that we want in the leaf iterator
93  // not necessarily is real leaf element
94  // see Intersection Iterator, same story
95 
96  // reset geometry information
97  geo_.invalidate();
98  }
99 
100  template<int dim, class GridImp>
101  inline int
102  ALU3dGridEntity<0,dim,GridImp> :: level() const
103  {
104  alugrid_assert( item_ );
105  return item_->level();
106  }
107 
108  template<int dim, class GridImp>
109  inline bool ALU3dGridEntity<0,dim,GridImp> ::
110  equals (const ALU3dGridEntity<0,dim,GridImp> &org ) const
111  {
112  return (item_ == org.item_);
113  }
114 
115  template<int dim, class GridImp>
116  inline GeometryType
117  ALU3dGridEntity<0,dim,GridImp> :: type () const
118  {
119  return geo_.type();
120  }
121 
122  template<int dim, class GridImp>
123  inline int ALU3dGridEntity<0,dim,GridImp> :: getIndex() const
124  {
125  alugrid_assert ( item_ );
126  return (*item_).getIndex();
127  }
128 
129  template<int dim, class GridImp>
130  template<int cc>
131  inline int ALU3dGridEntity<0,dim,GridImp> :: count () const
132  {
133  return subEntities( cc );
134  }
135 
136  template<int dim, class GridImp>
137  inline unsigned int ALU3dGridEntity<0,dim,GridImp> :: subEntities (unsigned int codim) const
138  {
139  return GridImp::referenceElement().size( codim );
140  }
141 
142  template<int dim, class GridImp>
143  inline PartitionType ALU3dGridEntity<0,dim,GridImp> ::
144  partitionType () const
145  {
146  alugrid_assert ( item_ );
147  // make sure we really got a ghost
148  alugrid_assert ( (isGhost()) ? item_->isGhost() : true );
149  return (isGhost() ? GhostEntity : InteriorEntity);
150  }
151 
152  template<int dim, class GridImp>
153  inline bool ALU3dGridEntity<0,dim,GridImp> :: isLeaf() const
154  {
155  alugrid_assert( item_ );
156  if( isGhost() )
157  {
158  alugrid_assert( ghost_ );
159  // for ghost elements the situation is more complicated
160  // we have to compare the ghost level with our current level
161  BNDFaceType * dwn = static_cast<BNDFaceType *> (ghost_->down());
162  return ( dwn ) ? (dwn->ghostLevel() == level()) : true;
163  }
164  else
165  {
166  // no children means leaf entity
167  return ! item_->down();
168  }
169  }
170 
171  template<int dim, class GridImp>
172  inline ALU3dGridHierarchicIterator<GridImp>
173  ALU3dGridEntity<0,dim,GridImp> :: hbegin (int maxlevel) const
174  {
175  alugrid_assert (item_ != 0);
176  // if isGhost is true the end iterator will be returned
177  if( isGhost() )
178  {
179  return ALU3dGridHierarchicIterator<GridImp>( *ghost_, maxlevel, isLeaf() );
180  }
181  else
182  return ALU3dGridHierarchicIterator<GridImp>( *item_, maxlevel, isLeaf() );
183  }
184 
185  template<int dim, class GridImp>
186  inline ALU3dGridHierarchicIterator<GridImp> ALU3dGridEntity<0,dim,GridImp> :: hend (int maxlevel) const
187  {
188  alugrid_assert (item_ != 0);
189  return ALU3dGridHierarchicIterator<GridImp> ( *item_, maxlevel, true);
190  }
191 
192  // Adaptation methods
193  template<int dim, class GridImp>
194  inline bool ALU3dGridEntity<0,dim,GridImp> :: isNew () const
195  {
196  alugrid_assert ( item_ );
197  return item_->hasBeenRefined();
198  }
199 
200  template<int dim, class GridImp>
201  inline bool ALU3dGridEntity<0,dim,GridImp> :: mightVanish () const
202  {
203  alugrid_assert ( item_ );
204  return ((*item_).requestrule() == coarse_element_t);
205  }
206  */
207 
208  //*******************************************************************
209  //
210  // --EntityPointer
211  // --EnPointer
212  //
213  //*******************************************************************
214  template<int codim, class GridImp >
216  ALU3dGridEntityPointerBase( const HElementType &item )
217  : seed_( item )
218  , entity_( EntityImp( item ) )
219  {
220  }
221 
222  template<int codim, class GridImp >
224  ALU3dGridEntityPointerBase( const HBndSegType & ghostFace )
225  : seed_( ghostFace )
226  , entity_ ( EntityImp( ghostFace ) )
227  {
228  }
229 
230  template<int codim, class GridImp >
233  : seed_( key )
234  , entity_( EntityImp( seed_ ) )
235  {
236  }
237 
238  // constructor Level,Leaf and HierarchicIterator
239  template<int codim, class GridImp >
242  : seed_()
243  , entity_ ( EntityImp() )
244  {
245  }
246 
247  template<int codim, class GridImp >
250  : seed_( org.seed_ )
251  , entity_( org.entity_.impl() )
252  {
253  alugrid_assert( seed_ == org.seed_ );
254  alugrid_assert( entity_ == org.entity_ );
255  }
256 
257  template<int codim, class GridImp >
261  {
262  clone( org );
263  return *this;
264  }
265 
266  template<int codim, class GridImp >
267  inline void
269  clone (const ALU3dGridEntityPointerType & org)
270  {
271  // copy seed
272  seed_ = org.seed_;
273 
274  if( seed_.isValid() )
275  {
276  // update entity if seed is valid
277  entityImp().setEntity( org.entityImp() );
278  }
279  else // otherwise mark as finished (iterators)
280  {
281  this->done();
282  }
283  }
284 
285  template<int codim, class GridImp >
287  {
288  seed_.clear();
289  }
290 
291  template<int codim, class GridImp >
294  {
295  // check equality of underlying items
296  return (seed_.equals( i.seed_ ));
297  }
298 
299  template<int codim, class GridImp >
301  updateGhostPointer( HBndSegType & ghostFace )
302  {
303  seed_.set( ghostFace );
304  if( seed_.isValid() )
305  {
306  entityImp().setGhost( ghostFace );
307  }
308  }
309 
310  template<int codim, class GridImp >
311  inline void ALU3dGridEntityPointerBase<codim,GridImp>::
312  updateEntityPointer( HElementType * item , int )
313  {
314  seed_.set( *item );
315  if( seed_.isValid() )
316  {
317  entityImp().setElement( *item );
318  }
319  }
320 
322  //
323  // specialisation for higher codims
324  //
326 
327  template<int codim, class GridImp >
328  inline void ALU3dGridEntityPointer<codim,GridImp>::
329  updateEntityPointer( HElementType * item, int level)
330  {
331  seed_.set( *item, level );
332  if( seed_.isValid() )
333  {
334  entityImp().setElement( seed_ );
335  }
336  }
337 
338 } // end namespace Dune
339 #endif
Definition: entity.hh:449
ALU3dGridEntityPointerBase()
default empty constructor
Definition: entity_inline.hh:241
bool equals(const ALU3dGridEntityPointerType &i) const
equality
Definition: entity_inline.hh:293
ALU3dGridEntitySeed< codimension, GridImp > ALU3dGridEntitySeedType
type of entity seed
Definition: entity.hh:480
ThisType & operator=(const ThisType &org)
assignment operator
Definition: entity_inline.hh:260
void done()
has to be called when iterator is finished
Definition: entity_inline.hh:286
Definition: entity.hh:48
A few common exception classes.
Dune namespace.
Definition: alignedallocator.hh:13
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.80.0 (May 2, 22:35, 2024)