/usr/include/dune/grid/alugrid/3d/iterator_imp.cc is in libdune-grid-dev 2.4.1-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 | // -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
// vi: set et ts=4 sw=2 sts=2:
#ifndef DUNE_ALUGRID_ITERATOR_IMP_CC
#define DUNE_ALUGRID_ITERATOR_IMP_CC
#include <dune/geometry/genericgeometry/topologytypes.hh>
#include "alu3dinclude.hh"
#include "geometry.hh"
#include "entity.hh"
#include "grid.hh"
#include "faceutility.hh"
namespace Dune {
/************************************************************************************
###
# # # ##### ###### ##### #### ###### #### # #####
# ## # # # # # # # # # # #
# # # # # ##### # # #### ##### # # #
# # # # # # ##### # # # # #
# # ## # # # # # # # # # # #
### # # # ###### # # #### ###### #### # #
************************************************************************************/
// --IntersectionIterator
template<class GridImp>
inline ALU3dGridIntersectionIterator<GridImp> ::
ALU3dGridIntersectionIterator(const FactoryType& factory,
int wLevel) :
connector_( factory.grid().conformingRefinement(), factory.grid().ghostCellsEnabled() ),
geoProvider_(connector_),
factory_( factory ),
item_(0),
ghost_(0),
index_(-1)
{}
// --IntersectionIterator
template<class GridImp>
inline ALU3dGridIntersectionIterator<GridImp> ::
ALU3dGridIntersectionIterator(const FactoryType& factory,
HElementType *el,
int wLevel,bool end) :
connector_( factory.grid().conformingRefinement(), factory.grid().ghostCellsEnabled() ),
geoProvider_(connector_),
factory_( factory ),
item_(0),
ghost_(0),
index_(-1)
{
if( ! end )
{
setFirstItem(*el,wLevel);
}
else
{
done();
}
}
template<class GridImp>
inline void
ALU3dGridIntersectionIterator<GridImp> :: done ()
{
item_ = 0;
ghost_ = 0;
// index < 0 indicates end iterator
index_ = -1;
}
template<class GridImp>
inline void ALU3dGridIntersectionIterator<GridImp> ::
setFirstItem (const HElementType & elem, int wLevel)
{
ghost_ = 0;
item_ = static_cast<const IMPLElementType *> (&elem);
// Get first face
const GEOFaceType* firstFace = getFace(*item_, index_);
const GEOFaceType* childFace = firstFace->down();
if( childFace ) firstFace = childFace;
// Store the face in the connector
setNewFace(*firstFace);
}
template<class GridImp>
inline void ALU3dGridIntersectionIterator<GridImp> ::
setInteriorItem (const HElementType & elem, const BNDFaceType& ghost, int wLevel)
{
// get correct face number
index_ = ElementTopo::alu2duneFace( ghost.getGhost().second );
// store ghost for method inside
ghost_ = &ghost;
// Get first face
const GEOFaceType* firstFace = getFace( ghost, index_ );
item_ = static_cast<const IMPLElementType *> (&elem);
const GEOFaceType* childFace = firstFace->down();
if( childFace ) firstFace = childFace;
// Store the face in the connector
setGhostFace(*firstFace);
}
template<class GridImp>
template <class EntityType>
inline void ALU3dGridIntersectionIterator<GridImp> ::
first (const EntityType & en, int wLevel)
{
if( ! en.isLeaf() )
{
done();
return ;
}
innerLevel_ = en.level();
index_ = 0;
if( en.isGhost() )
{
setInteriorItem(en.getItem(), en.getGhost(), wLevel);
}
else
{
assert( numFaces == en.getItem().nFaces() );
setFirstItem(en.getItem(), wLevel);
}
}
// copy constructor
template<class GridImp>
inline ALU3dGridIntersectionIterator<GridImp> ::
ALU3dGridIntersectionIterator(const ALU3dGridIntersectionIterator<GridImp> & org) :
connector_(org.connector_),
geoProvider_(connector_),
factory_( org.factory_ ),
item_(org.item_),
ghost_(org.ghost_)
{
if(org.item_)
{ // else it's a end iterator
item_ = org.item_;
innerLevel_ = org.innerLevel_;
index_ = org.index_;
}
else
{
done();
}
}
// copy constructor
template<class GridImp>
inline void
ALU3dGridIntersectionIterator<GridImp> ::
assign(const ALU3dGridIntersectionIterator<GridImp> & org)
{
if(org.item_)
{
// else it's a end iterator
item_ = org.item_;
ghost_ = org.ghost_;
innerLevel_ = org.innerLevel_;
index_ = org.index_;
connector_.updateFaceInfo(org.connector_.face(),innerLevel_,
item_->twist(ElementTopo::dune2aluFace(index_)));
geoProvider_.resetFaceGeom();
}
else {
done();
}
assert( equals(org) );
}
// check whether entities are the same or whether iterator is done
template<class GridImp>
inline bool ALU3dGridIntersectionIterator<GridImp> ::
equals (const ALU3dGridIntersectionIterator<GridImp> & i ) const
{
// this method is only to check equality of real iterators and end
// iterators
return ((item_ == i.item_) &&
(index_ == i.index_ )
);
}
template<class GridImp>
inline void ALU3dGridIntersectionIterator<GridImp> :: increment ()
{
// leaf increment
assert(item_);
const GEOFaceType * nextFace = 0;
// When neighbour element is refined, try to get the next child on the face
if (connector_.conformanceState() == FaceInfoType::REFINED_OUTER)
{
nextFace = connector_.face().next();
// There was a next child face...
if (nextFace)
{
if( ImplTraits :: isGhost( ghost_ ) )
{
setGhostFace( *nextFace );
}
else
{
setNewFace(*nextFace);
}
return; // we found what we were looking for...
}
} // end if
// Next face number of starting element
++index_;
// When the face number is larger than the number of faces an element
// can have, we've reached the end...
// for ghost elements here is finito
if (index_ >= numFaces || ghost_ )
{
done();
return;
}
// ... else we can take the next face
nextFace = getFace(connector_.innerEntity(), index_);
assert(nextFace);
// Check whether we need to go down first
//if (nextFace has children which need to be visited)
const GEOFaceType * childFace = nextFace->down();
if( childFace ) nextFace = childFace;
assert(nextFace);
setNewFace(*nextFace);
return;
}
template<class GridImp>
inline typename ALU3dGridIntersectionIterator<GridImp>::EntityPointer
ALU3dGridIntersectionIterator<GridImp>::outside () const
{
assert( neighbor() );
// make sure that outside is not called for an end iterator
if( connector_.ghostBoundary() )
{
// create entity pointer with ghost boundary face
return EntityPointer(factory_, connector_.boundaryFace() );
}
assert( &connector_.outerEntity() );
return EntityPointer(factory_, connector_.outerEntity() );
}
template<class GridImp>
inline typename ALU3dGridIntersectionIterator<GridImp>::EntityPointer
ALU3dGridIntersectionIterator<GridImp>::inside () const
{
if( ImplTraits :: isGhost( ghost_ ) )
{
return EntityPointer(factory_, *ghost_ );
}
else
{
// make sure that inside is not called for an end iterator
return EntityPointer(factory_, connector_.innerEntity() );
}
}
template<class GridImp>
inline bool ALU3dGridIntersectionIterator<GridImp> :: boundary () const
{
return connector_.boundary();
}
template<class GridImp>
inline bool ALU3dGridIntersectionIterator<GridImp> :: neighbor () const
{
return connector_.neighbor();
}
template<class GridImp>
inline int
ALU3dGridIntersectionIterator< GridImp >::indexInInside () const
{
assert(ElementTopo::dune2aluFace(index_) == connector_.innerALUFaceIndex());
return index_;
}
template< class GridImp >
inline typename ALU3dGridIntersectionIterator< GridImp >::LocalGeometry
ALU3dGridIntersectionIterator< GridImp >::geometryInInside () const
{
buildLocalGeometries();
return LocalGeometry( intersectionSelfLocal_ );
}
template< class GridImp >
inline int
ALU3dGridIntersectionIterator< GridImp >::indexInOutside () const
{
return ElementTopo::alu2duneFace( connector_.outerALUFaceIndex() );
}
template< class GridImp >
inline int
ALU3dGridIntersectionIterator< GridImp >::
twistInInside () const
{
return connector_.duneTwist( indexInInside(), connector_.innerTwist() );
}
template< class GridImp >
inline int
ALU3dGridIntersectionIterator< GridImp >::
twistInOutside () const
{
return connector_.duneTwist( indexInOutside(), connector_.outerTwist() );
}
template< class GridImp >
inline typename ALU3dGridIntersectionIterator< GridImp >::LocalGeometry
ALU3dGridIntersectionIterator< GridImp >::geometryInOutside () const
{
assert(neighbor());
buildLocalGeometries();
return LocalGeometry( intersectionNeighborLocal_ );
}
template<class GridImp>
inline typename ALU3dGridIntersectionIterator<GridImp>::NormalType &
ALU3dGridIntersectionIterator<GridImp>::
integrationOuterNormal(const FieldVector<alu3d_ctype, dim-1>& local) const
{
return this->outerNormal(local);
}
template<class GridImp>
inline typename ALU3dGridIntersectionIterator<GridImp>::NormalType &
ALU3dGridIntersectionIterator<GridImp>::
outerNormal(const FieldVector<alu3d_ctype, dim-1>& local) const
{
assert(item_ != 0);
return geoProvider_.outerNormal(local);
}
template<class GridImp>
inline typename ALU3dGridIntersectionIterator<GridImp>::NormalType &
ALU3dGridIntersectionIterator<GridImp>::
unitOuterNormal(const FieldVector<alu3d_ctype, dim-1>& local) const
{
unitOuterNormal_ = this->outerNormal(local);
unitOuterNormal_ *= (1.0/unitOuterNormal_.two_norm());
return unitOuterNormal_;
}
template< class GridImp >
inline typename ALU3dGridIntersectionIterator< GridImp >::Geometry
ALU3dGridIntersectionIterator< GridImp >::geometry () const
{
geoProvider_.buildGlobalGeom( intersectionGlobal_ );
return Geometry( intersectionGlobal_ );
}
template<class GridImp>
inline GeometryType
ALU3dGridIntersectionIterator<GridImp>::
type () const
{
return GeometryType(
GridImp::elementType == tetra ?
GenericGeometry :: SimplexTopology< dim-1 > :: type :: id :
GenericGeometry :: CubeTopology < dim-1 > :: type :: id,
dim-1 );
}
template<class GridImp>
inline int
ALU3dGridIntersectionIterator<GridImp>::boundaryId () const
{
assert( item_ );
return ( boundary() ) ? connector_.boundaryId() : 0;
}
template<class GridImp>
inline size_t
ALU3dGridIntersectionIterator<GridImp>::boundarySegmentIndex() const
{
assert( item_ );
assert( boundary() );
return connector_.segmentIndex();
}
template< class GridImp >
inline void ALU3dGridIntersectionIterator< GridImp >::buildLocalGeometries() const
{
intersectionSelfLocal_.buildGeom( geoProvider_.intersectionSelfLocal() );
if ( !connector_.outerBoundary() )
intersectionNeighborLocal_.buildGeom( geoProvider_.intersectionNeighborLocal() );
}
template <class GridImp>
inline const typename ALU3dImplTraits< tetra, typename GridImp::MPICommunicatorType >::GEOFaceType *
ALU3dGridIntersectionIterator<GridImp>::
getFace(const GEOTriangleBndType & bnd, int index) const
{
return bnd.myhface3(0);
}
template <class GridImp>
inline const typename ALU3dImplTraits< hexa, typename GridImp::MPICommunicatorType >::GEOFaceType *
ALU3dGridIntersectionIterator<GridImp>::
getFace(const GEOQuadBndType & bnd, int index) const
{
return bnd.myhface4(0);
}
template <class GridImp>
inline const typename ALU3dImplTraits< tetra, typename GridImp::MPICommunicatorType >::GEOFaceType *
ALU3dGridIntersectionIterator<GridImp>::
getFace(const GEOTetraElementType & elem, int index) const {
assert(index >= 0 && index < numFaces);
return elem.myhface3(ElementTopo::dune2aluFace(index));
}
template <class GridImp>
inline const typename ALU3dImplTraits< hexa, typename GridImp::MPICommunicatorType >::GEOFaceType *
ALU3dGridIntersectionIterator<GridImp>::
getFace(const GEOHexaElementType & elem, int index) const {
assert(index >= 0 && index < numFaces);
return elem.myhface4(ElementTopo::dune2aluFace(index));
}
template <class GridImp>
inline void ALU3dGridIntersectionIterator<GridImp>::
setNewFace(const GEOFaceType& newFace)
{
assert( ! ghost_ );
assert( innerLevel_ == item_->level() );
connector_.updateFaceInfo(newFace,innerLevel_,
item_->twist(ElementTopo::dune2aluFace(index_)) );
geoProvider_.resetFaceGeom();
}
template <class GridImp>
inline void ALU3dGridIntersectionIterator<GridImp>::
setGhostFace(const GEOFaceType& newFace)
{
assert( ghost_ );
assert( innerLevel_ == ghost_->level() );
connector_.updateFaceInfo(newFace,innerLevel_, ghost_->twist(0) );
geoProvider_.resetFaceGeom();
}
template <class GridImp>
inline int
ALU3dGridIntersectionIterator<GridImp>::
level() const {
assert( item_ && (innerLevel_ == item_->level()) );
return innerLevel_;
}
/************************************************************************************
###
# # # ##### ###### ##### #### ###### #### # #####
# ## # # # # # # # # # # #
# # # # # ##### # # #### ##### # # #
# # # # # # ##### # # # # #
# # ## # # # # # # # # # # #
### # # # ###### # # #### ###### #### # #
************************************************************************************/
// --IntersectionIterator
template<class GridImp>
inline ALU3dGridLevelIntersectionIterator<GridImp> ::
ALU3dGridLevelIntersectionIterator(const FactoryType& factory,
int wLevel)
: ALU3dGridIntersectionIterator<GridImp>(factory,wLevel)
, levelNeighbor_(false)
, isLeafItem_(false)
{}
// --IntersectionIterator
template<class GridImp>
inline ALU3dGridLevelIntersectionIterator<GridImp> ::
ALU3dGridLevelIntersectionIterator(const FactoryType& factory,
HElementType *el,
int wLevel,bool end)
: ALU3dGridIntersectionIterator<GridImp>(factory,el,wLevel,end)
, levelNeighbor_(false)
, isLeafItem_(false)
{}
template<class GridImp>
template <class EntityType>
inline void ALU3dGridLevelIntersectionIterator<GridImp> ::
first (const EntityType & en, int wLevel)
{
// if given Entity is not leaf, we create an end iterator
index_ = 0;
isLeafItem_ = en.isLeaf();
if( en.isGhost() )
{
setInteriorItem(en.getItem(), en.getGhost(), wLevel);
}
else
{
assert( numFaces == en.getItem().nFaces() );
setFirstItem(en.getItem(), wLevel);
}
}
template<class GridImp>
inline void ALU3dGridLevelIntersectionIterator<GridImp> ::
setFirstItem (const HElementType & elem, int wLevel)
{
ghost_ = 0;
item_ = static_cast<const IMPLElementType *> (&elem);
this->innerLevel_ = wLevel;
// Get first face
const GEOFaceType* firstFace = getFace(*item_, index_);
// Store the face in the connector
setNewFace(*firstFace);
}
template<class GridImp>
inline void ALU3dGridLevelIntersectionIterator<GridImp> ::
setInteriorItem (const HElementType & elem, const BNDFaceType& ghost, int wLevel)
{
// store ghost for method inside
ghost_ = &ghost;
item_ = static_cast<const IMPLElementType *> (&elem);
// get correct face number
index_ = ElementTopo::alu2duneFace( ghost.getGhost().second );
innerLevel_ = wLevel;
// Get first face
const GEOFaceType* firstFace = getFace( ghost, index_ );
// Store the face in the connector
setNewFace(*firstFace);
}
// copy constructor
template<class GridImp>
inline ALU3dGridLevelIntersectionIterator<GridImp> ::
ALU3dGridLevelIntersectionIterator(const ThisType & org)
: ALU3dGridIntersectionIterator<GridImp>(org)
, levelNeighbor_(org.levelNeighbor_)
, isLeafItem_(org.isLeafItem_)
{}
// copy constructor
template<class GridImp>
inline void
ALU3dGridLevelIntersectionIterator<GridImp> ::
assign(const ALU3dGridLevelIntersectionIterator<GridImp> & org)
{
ALU3dGridIntersectionIterator<GridImp>::assign(org);
levelNeighbor_ = org.levelNeighbor_;
isLeafItem_ = org.isLeafItem_;
}
template<class GridImp>
inline void ALU3dGridLevelIntersectionIterator<GridImp> :: increment ()
{
// level increment
assert( item_ );
// Next face number of starting element
++index_;
// When the face number is larger than the number of faces an element
// can have, we've reached the end...
if ( index_ >= numFaces || ImplTraits::isGhost( ghost_ ) )
{
done();
return;
}
// ... else we can take the next face
const GEOFaceType * nextFace = getFace(connector_.innerEntity(), index_);
assert(nextFace);
setNewFace(*nextFace);
return;
}
template<class GridImp>
inline bool ALU3dGridLevelIntersectionIterator<GridImp>::neighbor () const
{
return levelNeighbor_ && (BaseType :: neighbor());
}
template <class GridImp>
inline void ALU3dGridLevelIntersectionIterator<GridImp>::
setNewFace(const GEOFaceType& newFace)
{
assert( item_->level() == innerLevel_ );
levelNeighbor_ = (newFace.level() == innerLevel_);
connector_.updateFaceInfo(newFace, innerLevel_,
( ImplTraits::isGhost( ghost_ ) ) ?
ghost_->twist(0) :
item_->twist(ElementTopo::dune2aluFace( index_ )));
geoProvider_.resetFaceGeom();
// check again level neighbor because outer element might be coarser then
// this element
if( isLeafItem_ )
{
if( connector_.ghostBoundary() )
{
const BNDFaceType & ghost = connector_.boundaryFace();
// if nonconformity occurs then no level neighbor
levelNeighbor_ = (innerLevel_ == ghost.ghostLevel() );
}
else if ( ! connector_.outerBoundary() )
{
levelNeighbor_ = (connector_.outerEntity().level() == innerLevel_);
}
}
}
} // end namespace Dune
#if COMPILE_ALUGRID_INLINE
#include "iterator.cc"
#endif
#endif // DUNE_ALUGRID_ITERATOR_IMP_CC
|