/usr/include/dune/grid/alugrid/3d/entity_imp.cc is in libdune-grid-dev 2.2.1-2.
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 | #ifndef DUNE_ALUGRID_ENTITY_CC
#define DUNE_ALUGRID_ENTITY_CC
#if COMPILE_ALUGRID_INLINE == 0
#include <config.h>
#endif
#include "alu3dinclude.hh"
#include <dune/grid/alugrid/3d/alugrid.hh>
#include "entity.hh"
#if COMPILE_ALUGRID_INLINE == 0
#include <dune/grid/alugrid/3d/alu3dgridfactory.hh>
#endif
#include <dune/grid/alugrid/common/geostorage.hh>
#if COMPILE_ALUGRID_INLINE
#define alu_inline inline
#else
#define alu_inline
#endif
namespace Dune {
// --Entity
template <int cd, int dim, class GridImp>
ALU3dGridEntity<cd,dim,GridImp> ::
ALU3dGridEntity(const FactoryType& factory, int level) :
factory_( factory ),
item_(0),
level_(0),
gIndex_(-1),
twist_(0),
face_(-1),
partitionType_(InteriorEntity)
{}
// --Entity
template <int cd, int dim, class GridImp>
alu_inline ALU3dGridEntity<cd,dim,GridImp> ::
ALU3dGridEntity(const ALU3dGridEntity<cd,dim,GridImp> & org) :
factory_(org.factory_),
item_(org.item_),
level_(org.level_),
gIndex_(org.gIndex_),
twist_(org.twist_),
face_(org.face_),
partitionType_(org.partitionType_)
{}
template<int cd, int dim, class GridImp>
alu_inline void ALU3dGridEntity<cd,dim,GridImp> ::
setEntity(const ALU3dGridEntity<cd,dim,GridImp> & org)
{
item_ = org.item_;
gIndex_ = org.gIndex_;
twist_ = org.twist_;
level_ = org.level_;
face_ = org.face_;
partitionType_ = org.partitionType_;
}
template<int cd, int dim, class GridImp>
alu_inline void ALU3dGridEntity<cd,dim,GridImp> ::
setElement(const HItemType & item)
{
setElement(item,GetLevel<GridImp,cd>::getLevel(grid(),item));
}
template<int cd, int dim, class GridImp>
alu_inline void ALU3dGridEntity<cd,dim,GridImp> ::
setElement(const EntitySeed& seed )
{
setElement(*seed.item(), seed.level(), seed.twist(), seed.face());
}
template<int cd, int dim, class GridImp>
alu_inline void ALU3dGridEntity<cd,dim,GridImp> ::
setElement(const HItemType & item, const int level, int twist , int face )
{
// cast interface to implementation
item_ = static_cast<const ItemType *> (&item);
gIndex_ = (*item_).getIndex();
twist_ = twist;
level_ = level;
face_ = face;
partitionType_ = this->convertBndId( *item_ );
// reset geometry information
geo_.invalidate();
}
template<int cd, int dim, class GridImp>
alu_inline void ALU3dGridEntity<cd,dim,GridImp> ::
setGhost(const HBndSegType &ghost)
{
// this method only exists, that we don't have to specialize the
// Iterators for each codim, this method should not be called otherwise
// error
DUNE_THROW(GridError,"This method should not be called!");
}
template<int cd, int dim, class GridImp>
alu_inline PartitionType ALU3dGridEntity<cd,dim,GridImp> ::
convertBndId(const HItemType & item) const
{
if(item.isGhost())
{
return GhostEntity;
}
else if(item.isBorder())
{
return BorderEntity;
}
else
{
assert( item.isInterior() );
return InteriorEntity;
}
}
template< int cd, int dim, class GridImp >
alu_inline typename ALU3dGridEntity< cd, dim, GridImp >::Geometry
ALU3dGridEntity< cd, dim, GridImp >::geometry () const
{
if( ! geo_.valid() )
geo_.buildGeom( *item_, twist_, face_ );
return Geometry( geo_ );
}
/////////////////////////////////////////////////
//
// --Entity0
// --Codim0Entity
//
/////////////////////////////////////////////////
template<int dim, class GridImp>
alu_inline ALU3dGridEntity<0,dim,GridImp> ::
ALU3dGridEntity(const FactoryType &factory, int wLevel)
: factory_( factory )
, item_( 0 )
, ghost_( 0 )
, level_(-1)
, isLeaf_ (false)
{ }
template<int dim, class GridImp>
alu_inline ALU3dGridEntity<0,dim,GridImp> ::
ALU3dGridEntity(const ALU3dGridEntity<0,dim,GridImp> & org)
: factory_(org.factory_)
, item_(org.item_)
, ghost_( org.ghost_ )
, level_(org.level_)
, isLeaf_ (org.isLeaf_)
{ }
template< int dim, class GridImp >
alu_inline typename ALU3dGridEntity< 0, dim, GridImp >::Geometry
ALU3dGridEntity< 0, dim, GridImp >::geometry () const
{
assert(item_ != 0);
if( ! geo_.valid() )
geo_.buildGeom( *item_ );
return Geometry( geo_ );
}
template< int dim, class GridImp >
alu_inline typename ALU3dGridEntity<0,dim,GridImp>::LocalGeometry
ALU3dGridEntity< 0, dim, GridImp >::geometryInFather () const
{
assert( item_ );
// this method should only be called if a father exists
assert( item_->up() );
// get child number
const int child = item_->nChild();
// if the rule of the farher is not refine_element, it has to be bisection
// this can only be true for tetrahedral elements
if( (GridImp::elementType == tetra) && (item_->up()->getrule() != ImplTraits::refine_element_t) )
{
static LocalGeometryImpl geom;
geom.buildGeomInFather( father()->geometry(), geometry() );
return LocalGeometry( geom );
}
else
{
// to be improved, when we using not the refine 8 rule
// see dune/grid/alugrid/common/geostrage.hh for implementation
static ALULocalGeometryStorage< GridImp, LocalGeometryImpl, 8 > geoms( type(), true );
assert( geoms.geomCreated( child ) );
return LocalGeometry( geoms[ child ] );
}
}
//********* begin method subIndex ********************
// partial specialisation of subIndex
template <class IMPLElemType, ALU3dGridElementType type, int codim>
struct IndexWrapper {};
// specialisation for vertices
template <class IMPLElemType, ALU3dGridElementType type>
struct IndexWrapper<IMPLElemType, type, 3>
{
typedef ElementTopologyMapping<type> ElemTopo;
static int subIndex(const IMPLElemType &elem, int i)
{
return elem.myvertex( ElemTopo::dune2aluVertex(i) )->getIndex(); // element topo
}
};
// specialisation for faces
template <class IMPLElemType, ALU3dGridElementType type>
struct IndexWrapper<IMPLElemType, type , 1>
{
static int subIndex(const IMPLElemType &elem, int i)
{
// is specialised for each element type and uses
// the dune2aluFace mapping
return (getFace(elem,i))->getIndex();
}
};
// specialisation for edges
template <class IMPLElemType, ALU3dGridElementType type>
struct IndexWrapper<IMPLElemType, type, 2>
{
typedef ElementTopologyMapping<type> ElemTopo;
// return subIndex of given edge
static int subIndex(const IMPLElemType &elem, int i)
{
// get hedge1 corresponding to dune reference element and return number
return elem.myhedge1( ElemTopo::dune2aluEdge(i) )->getIndex();
}
};
// specialisation for elements
template <class IMPLElemType, ALU3dGridElementType type>
struct IndexWrapper<IMPLElemType, type, 0>
{
static int subIndex(const IMPLElemType &elem, int i) {
// just return the elements index
return elem.getIndex();
}
};
template<int dim, class GridImp>
template<int cc>
alu_inline int ALU3dGridEntity<0,dim,GridImp> :: getSubIndex (int i) const
{
assert(item_ != 0);
typedef typename ImplTraits::IMPLElementType IMPLElType;
return IndexWrapper<IMPLElType,GridImp::elementType,cc>::subIndex ( *item_, i);
}
template<int dim, class GridImp>
alu_inline int ALU3dGridEntity<0,dim,GridImp> :: subIndex (int i, unsigned int codim ) const
{
typedef ElementTopologyMapping<GridImp::elementType> ElemTopo;
assert(item_ != 0);
switch (codim)
{
case 0:
return this->getIndex();
case 1:
return (ALU3dGridFaceGetter< Comm >::getFace( *item_, i ))->getIndex();
case 2:
return item_->myhedge1( ElemTopo::dune2aluEdge( i ) )->getIndex();
case 3:
return item_->myvertex( ElemTopo::dune2aluVertex( i ) )->getIndex();
default :
assert(false);
abort();
}
return -1;
}
//******** begin method entity ******************
template <class GridImp, int dim, int cd> struct SubEntities {};
// specialisation for elements
template <class GridImp, int dim>
struct SubEntities<GridImp, dim, 0>
{
typedef typename GridImp::GridObjectFactoryType FactoryType;
typedef ALU3dGridEntity<0,dim,GridImp> EntityType;
static typename ALU3dGridEntity<0,dim,GridImp>::template Codim<0>::EntityPointer
entity (const FactoryType& factory,
const int level,
const EntityType & entity,
const typename ALU3dImplTraits<GridImp::elementType, typename GridImp::MPICommunicatorType>::IMPLElementType & item,
int i)
{
return ALU3dGridEntityPointer<0, GridImp>( entity );
}
};
// specialisation for faces
template <class GridImp, int dim>
struct SubEntities<GridImp,dim,1>
{
typedef typename GridImp::GridObjectFactoryType FactoryType;
typedef ElementTopologyMapping<GridImp::elementType> Topo;
typedef ALU3dGridEntity<0,dim,GridImp> EntityType;
static typename ALU3dGridEntity<0,dim,GridImp> :: template Codim<1>:: EntityPointer
entity (const FactoryType& factory,
const int level,
const EntityType & en,
const typename ALU3dImplTraits<GridImp::elementType, typename GridImp::MPICommunicatorType>::IMPLElementType & item,
int duneFace)
{
int aluFace = Topo::dune2aluFace(duneFace);
return
ALU3dGridEntityPointer<1,GridImp>
(factory,
level,
*(ALU3dGridFaceGetter< typename GridImp::MPICommunicatorType >::getFace(item, duneFace)), // getFace already constains dune2aluFace
item.twist(aluFace),
duneFace // we need the duneFace number here for the buildGeom method
);
}
};
// specialisation for edges
template <class GridImp, int dim>
struct SubEntities<GridImp,dim,2>
{
typedef typename GridImp::GridObjectFactoryType FactoryType;
typedef ElementTopologyMapping<GridImp::elementType> Topo;
typedef ALU3dGridEntity<0,dim,GridImp> EntityType;
typedef typename GridImp::ctype coordType;
typedef typename GridImp :: ReferenceElementType ReferenceElementType;
static typename ALU3dGridEntity<0,dim,GridImp> :: template Codim<2>:: EntityPointer
entity (const FactoryType& factory,
const int level,
const EntityType & en,
const typename ALU3dImplTraits<GridImp::elementType, typename GridImp::MPICommunicatorType>::IMPLElementType & item,
int i)
{
// get reference element
const ReferenceElementType & refElem = factory.grid().referenceElement();
// get first local vertex number of edge i
int localNum = refElem.subEntity(i,2,0,dim);
// get number of first vertex on edge
int v = en.template getSubIndex<dim> (localNum);
// get the hedge object
const typename ALU3dImplTraits<GridImp::elementType, typename GridImp::MPICommunicatorType>::GEOEdgeType &
edge = *(item.myhedge1(Topo::dune2aluEdge(i)));
int vx = edge.myvertex(0)->getIndex();
// check whether vertex numbers are equal, otherwise twist is 1
int twst = (v != vx) ? 1 : 0;
return ALU3dGridEntityPointer<2,GridImp> (factory, level, edge, twst );
}
};
// specialisation for vertices
template <class GridImp, int dim>
struct SubEntities<GridImp,dim,3>
{
typedef typename GridImp::GridObjectFactoryType FactoryType;
typedef ElementTopologyMapping<GridImp::elementType> Topo;
typedef ALU3dGridEntity<0,dim,GridImp> EntityType;
static typename ALU3dGridEntity<0,dim,GridImp> :: template Codim<3>:: EntityPointer
entity (const FactoryType& factory,
const int level,
const EntityType & en,
const typename ALU3dImplTraits<GridImp::elementType, typename GridImp::MPICommunicatorType>::IMPLElementType & item,
int i)
{
return ALU3dGridEntityPointer<3,GridImp>
(factory, level, *item.myvertex(Topo::dune2aluVertex(i))); // element topo
}
};
template<int dim, class GridImp>
template<int cc>
typename ALU3dGridEntity<0,dim,GridImp>::template Codim<cc>:: EntityPointer
ALU3dGridEntity<0,dim,GridImp> :: subEntity (int i) const
{
return SubEntities<GridImp,dim,cc>::entity(factory_,level(),*this,*item_,i);
}
//**** end method entity *********
template<int dim, class GridImp>
typename ALU3dGridEntity<0,dim,GridImp> :: EntityPointer
ALU3dGridEntity<0,dim,GridImp> :: father() const
{
HElementType* up = item_->up();
if( ! up )
{
std::cerr << "ALU3dGridEntity<0," << dim << "," << dimworld << "> :: father() : no father of entity globalid = " << getIndex() << "\n";
return ALU3dGridEntityPointer<0,GridImp> (factory_, static_cast<HElementType &> (*item_));
}
if( isGhost () )
{
return ALU3dGridEntityPointer<0,GridImp> (factory_, static_cast<const HBndSegType &> (*(getGhost().up())));
}
return ALU3dGridEntityPointer<0,GridImp> (factory_, static_cast<HElementType &> ( *up ));
}
// Adaptation methods
template<int dim, class GridImp>
bool ALU3dGridEntity<0,dim,GridImp> :: mark (int ref) const
{
assert(item_ != 0);
// do not allow to mark ghost cells or non-leaf cells
// this will lead to unpredictable results errors
if( isGhost() || ! isLeaf() ) return false ;
// mark for coarsening
if(ref < 0)
{
// don't mark macro elements for coarsening ;)
if(level() <= 0) return false;
item_->request(coarse_element_t);
return true;
}
// mark for refinement
if(ref > 0)
{
// for tetrahedral elements check whether to use bisection
if( GridImp :: elementType == tetra &&
grid().conformingRefinement() )
{
item_->request( bisect_element_t );
}
else
{
item_->request( refine_element_t );
}
return true;
}
// mark for none
item_->request( nosplit_element_t );
return true;
}
// return mark of entity
template<int dim, class GridImp>
alu_inline int ALU3dGridEntity<0,dim,GridImp> :: getMark () const
{
assert(item_ != 0);
const MarkRuleType rule = (*item_).requestrule();
if(rule == refine_element_t) return 1;
if(rule == coarse_element_t) return -1;
assert( rule == nosplit_element_t );
return 0;
}
template<int dim, class GridImp>
bool ALU3dGridEntity<0,dim,GridImp> :: hasBoundaryIntersections () const
{
// on ghost elements return false
if( isGhost() ) return false;
enum { numFaces = EntityCount<GridImp::elementType>::numFaces };
typedef typename ImplTraits::HasFaceType HasFaceType;
typedef typename ImplTraits::GEOFaceType GEOFaceType;
assert( item_ );
for(int i=0; i<numFaces; ++i)
{
const GEOFaceType &face = *ALU3dGridFaceGetter< Comm >::getFace( *item_, i );
// don't count internal boundaries as boundary
if( face.isBorder() ) continue ;
// check both
const HasFaceType * outerElement = face.nb.front().first;
// if we got our own element, get other side
if( item_ == outerElement )
{
outerElement = face.nb.rear().first;
}
assert( outerElement );
if( outerElement->isboundary() ) return true;
}
return false;
}
#if COMPILE_ALUGRID_LIB
// Instantiation
template class ALU3dGrid< hexa, No_Comm >;
template class ALU3dGrid< tetra, No_Comm >;
// Instantiation
template class ALU3dGridEntity<0, 3, const ALU3dGrid< tetra, No_Comm > >;
template class ALU3dGridEntity<0, 3, const ALU3dGrid< hexa, No_Comm > >;
template class ALU3dGridEntity<1, 3, const ALU3dGrid< tetra, No_Comm > >;
template class ALU3dGridEntity<1, 3, const ALU3dGrid< hexa, No_Comm > >;
template class ALU3dGridEntity<2, 3, const ALU3dGrid< tetra, No_Comm > >;
template class ALU3dGridEntity<2, 3, const ALU3dGrid< hexa, No_Comm > >;
template class ALU3dGridEntity<3, 3, const ALU3dGrid< tetra, No_Comm > >;
template class ALU3dGridEntity<3, 3, const ALU3dGrid< hexa, No_Comm > >;
template ALU3dGrid< tetra, No_Comm > :: Traits :: Codim< 0 > :: EntityPointer
ALU3dGridEntity<0, 3, const ALU3dGrid< tetra, No_Comm > > :: subEntity< 0 >( int ) const;
template ALU3dGrid< hexa, No_Comm > :: Traits :: Codim< 0 > :: EntityPointer
ALU3dGridEntity<0, 3, const ALU3dGrid< hexa, No_Comm > > :: subEntity< 0 >( int ) const;
template ALU3dGrid< tetra, No_Comm > :: Traits :: Codim< 1 > :: EntityPointer
ALU3dGridEntity<0, 3, const ALU3dGrid< tetra, No_Comm > > :: subEntity< 1 >( int ) const;
template ALU3dGrid< hexa, No_Comm > :: Traits :: Codim< 1 > :: EntityPointer
ALU3dGridEntity<0, 3, const ALU3dGrid< hexa, No_Comm > > :: subEntity< 1 >( int ) const;
template ALU3dGrid< tetra, No_Comm > :: Traits :: Codim< 2 > :: EntityPointer
ALU3dGridEntity<0, 3, const ALU3dGrid< tetra, No_Comm > > :: subEntity< 2 >( int ) const;
template ALU3dGrid< hexa, No_Comm > :: Traits :: Codim< 2 > :: EntityPointer
ALU3dGridEntity<0, 3, const ALU3dGrid< hexa, No_Comm > > :: subEntity< 2 >( int ) const;
template ALU3dGrid< tetra, No_Comm > :: Traits :: Codim< 3 > :: EntityPointer
ALU3dGridEntity<0, 3, const ALU3dGrid< tetra, No_Comm > > :: subEntity< 3 >( int ) const;
template ALU3dGrid< hexa, No_Comm > :: Traits :: Codim< 3 > :: EntityPointer
ALU3dGridEntity<0, 3, const ALU3dGrid< hexa, No_Comm > > :: subEntity< 3 >( int ) const;
#if ALU3DGRID_PARALLEL
// Instantiation
template class ALU3dGrid< hexa, MPI_Comm >;
template class ALU3dGrid< tetra, MPI_Comm >;
// Instantiation with MPI
template class ALU3dGridEntity<0, 3, const ALU3dGrid< tetra, MPI_Comm > >;
template class ALU3dGridEntity<0, 3, const ALU3dGrid< hexa, MPI_Comm > >;
template class ALU3dGridEntity<1, 3, const ALU3dGrid< tetra, MPI_Comm > >;
template class ALU3dGridEntity<1, 3, const ALU3dGrid< hexa, MPI_Comm > >;
template class ALU3dGridEntity<2, 3, const ALU3dGrid< tetra, MPI_Comm > >;
template class ALU3dGridEntity<2, 3, const ALU3dGrid< hexa, MPI_Comm > >;
template class ALU3dGridEntity<3, 3, const ALU3dGrid< tetra, MPI_Comm > >;
template class ALU3dGridEntity<3, 3, const ALU3dGrid< hexa, MPI_Comm > >;
template ALU3dGrid< tetra, MPI_Comm > :: Traits :: Codim< 0 > :: EntityPointer
ALU3dGridEntity<0, 3, const ALU3dGrid< tetra, MPI_Comm > > :: subEntity< 0 >( int ) const;
template ALU3dGrid< hexa, MPI_Comm > :: Traits :: Codim< 0 > :: EntityPointer
ALU3dGridEntity<0, 3, const ALU3dGrid< hexa, MPI_Comm > > :: subEntity< 0 >( int ) const;
template ALU3dGrid< tetra, MPI_Comm > :: Traits :: Codim< 1 > :: EntityPointer
ALU3dGridEntity<0, 3, const ALU3dGrid< tetra, MPI_Comm > > :: subEntity< 1 >( int ) const;
template ALU3dGrid< hexa, MPI_Comm > :: Traits :: Codim< 1 > :: EntityPointer
ALU3dGridEntity<0, 3, const ALU3dGrid< hexa, MPI_Comm > > :: subEntity< 1 >( int ) const;
template ALU3dGrid< tetra, MPI_Comm > :: Traits :: Codim< 2 > :: EntityPointer
ALU3dGridEntity<0, 3, const ALU3dGrid< tetra, MPI_Comm > > :: subEntity< 2 >( int ) const;
template ALU3dGrid< hexa, MPI_Comm > :: Traits :: Codim< 2 > :: EntityPointer
ALU3dGridEntity<0, 3, const ALU3dGrid< hexa, MPI_Comm > > :: subEntity< 2 >( int ) const;
template ALU3dGrid< tetra, MPI_Comm > :: Traits :: Codim< 3 > :: EntityPointer
ALU3dGridEntity<0, 3, const ALU3dGrid< tetra, MPI_Comm > > :: subEntity< 3 >( int ) const;
template ALU3dGrid< hexa, MPI_Comm > :: Traits :: Codim< 3 > :: EntityPointer
ALU3dGridEntity<0, 3, const ALU3dGrid< hexa, MPI_Comm > > :: subEntity< 3 >( int ) const;
#endif // #if ALU3DGRID_PARALLEL
#endif // #if COMPILE_ALUGRID_LIB
}
#undef alu_inline
#endif
|