/usr/include/dune/grid/common/entity.hh 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 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 | // -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
// vi: set et ts=4 sw=2 sts=2:
#ifndef DUNE_GRID_ENTITY_HH
#define DUNE_GRID_ENTITY_HH
#include <dune/common/iteratorrange.hh>
#include <dune/common/typetraits.hh>
#include <dune/geometry/dimension.hh>
#include "grid.hh"
#include "entitypointer.hh"
#include "rangegenerators.hh"
namespace Dune
{
/**
@brief Wrapper class for entities
\tparam cd Codimension of the entity
\tparam dim Dimension of the grid
\tparam GridImp Type that is a model of Dune::Grid
\tparam EntityImp Class template that is a model of Dune::Entity
<H3>Engine Concept</H3>
This class wraps a object of type EntityImp and forwards all member
function calls to corresponding members of this class. In that sense Entity
defines the interface and EntityImp supplies the implementation.
For various reasons we do not use an inheritance hierarchy and the
Barton-Nackman trick here.
<H3>Specialization</H3>
The Entity class template is specialized for <tt>cd=0</tt> (elements,
Dune::Entity<0,dim,GridImp,EntityImp>).
This case has an extended interface.
The methods defined in the general template
are provided by the specialization as well. We did not use inheritance
because different implementations for different codimensions may be required
and virtual functions had to be avoided.
<H3>View concept</H3>
Entities can not be created, assigned or otherwise modified outside
the interface in the user code. They are only accessible by immutable
iterators provided on the corresponding grid class.
The only way to modify the entities of a grid is through grid adaptation which
consists of tagging entities (of codimension 0) for refinement and then
calling the adapt() method on the grid.
\ingroup GIEntity
\nosubgrouping
*/
template<int cd, int dim, class GridImp, template<int,int,class> class EntityImp>
class Entity
{
#if DUNE_GRID_EXPERIMENTAL_GRID_EXTENSIONS
public:
#else
protected:
// give the GridDefaultImplementation class access to the realImp
friend class GridDefaultImplementation<
GridImp::dimension, GridImp::dimensionworld,
typename GridImp::ctype,
typename GridImp::GridFamily> ;
// Default*GridView classes need access to intersection iterators
template< class, PartitionIteratorType > friend class DefaultLevelGridView;
template< class, PartitionIteratorType > friend class DefaultLeafGridView;
#endif
// type of underlying implementation, for internal use only
typedef EntityImp< cd, dim, GridImp > Implementation;
//! Return reference to the real implementation
Implementation &impl () { return realEntity; }
//! Return const reference to the real implementation
const Implementation &impl () const { return realEntity; }
protected:
Implementation realEntity;
public:
//===========================================================
/** @name Exported types and constants
*/
//@{
//===========================================================
//! \brief The corresponding geometry type
typedef typename GridImp::template Codim<cd>::Geometry Geometry;
//! \brief The corresponding entity seed (for storage of entities)
typedef typename GridImp::template Codim<cd>::EntitySeed EntitySeed;
enum {
//! \brief Know your own codimension.
codimension=cd
};
enum {
//! \brief Know the grid dimension.
dimension=dim
};
enum {
//! \brief Dimensionality of the reference element of the entity.
mydimension=dim-cd
};
//@}
//===========================================================
/** @name Methods shared by entities of all codimensions
*/
//@{
//===========================================================
//! The level of this entity
int level () const { return realEntity.level(); }
//! Partition type of this entity
PartitionType partitionType () const { return realEntity.partitionType(); }
/** \brief obtain geometric realization of the entity
*
* Each entity provides an object of type
* Dune::Geometry< dimension-codimension, dimensionworld, ... > that
* represents the map from a reference element to world coordinates.
*
* \note Previously, the geometry was encapsulated in the entity object and
* a const reference was returned.
*
* \note The returned geometry object is guaranteed to remain valid until the
* grid is modified (or deleted).
*/
Geometry geometry () const { return realEntity.geometry(); }
/** \brief Return the name of the reference element. The type can
be used to access the Dune::ReferenceElement.
*/
GeometryType type () const { return realEntity.type(); }
/** \brief Return the entity seed which contains sufficient information
* to generate the entity again and uses as little memory as possible
*/
EntitySeed seed () const { return realEntity.seed(); }
//! Compares two entities for equality.
bool operator==(const Entity& other) const
{
return realEntity.equals(other.realEntity);
}
//! Compares two entities for inequality.
bool operator!=(const Entity& other) const
{
return !realEntity.equals(other.realEntity);
}
/** \brief Compares an Entity with an EntityPointer for equality.
*
* \deprecated This method only exists for backwards compatibility during the 2.4
* release cycle and will be removed after dune-grid-2.4 is released.
*/
template<typename ItImp>
DUNE_DEPRECATED_MSG("EntityPointer is deprecated and will be removed after the release of dune-grid-2.4. Instead, you can copy and store entities directly now.")
bool operator==(const Dune::EntityPointer<GridImp,ItImp>& other) const
{
return (*this) == (*other);
}
/** \brief Compares an Entity with an EntityPointer for inequality.
*
* \deprecated This method only exists for backwards compatibility during the 2.4
* release cycle and will be removed after dune-grid-2.4 is released.
*/
template<typename ItImp>
DUNE_DEPRECATED_MSG("EntityPointer is deprecated and will be removed after the release of dune-grid-2.4. Instead, you can copy and store entities directly now.")
bool operator!=(const Dune::EntityPointer<GridImp,ItImp>& other) const
{
return (*this) != (*other);
}
Entity()
{}
//! Copy constructor from an existing entity.
Entity(const Entity& other)
: realEntity(other.realEntity)
{}
//! Move constructor from an existing entity.
Entity(Entity&& other)
: realEntity(std::move(other.realEntity))
{}
//! Copy assignment operator from an existing entity.
Entity& operator=(const Entity& other)
{
realEntity = other.realEntity;
return *this;
}
//! Move assignment operator from an existing entity.
Entity& operator=(Entity&& other)
{
realEntity = std::move(other.realEntity);
return *this;
}
/** \brief Dereference Entity to itself for backwards compatibility with EntityPointer.
*
* \deprecated This method only exists to provide backwards compatibility for dune-grid-2.4.
* It will be removed after the release of dune-grid-2.4.
*/
const Entity& operator*() const
DUNE_DEPRECATED_MSG("This is now an Entity instead of an EntityPointer. You do not have to dereference it anymore!")
{
return *this;
}
/** \brief Dereference Entity to itself for backwards compatibility with EntityPointer.
*
* \deprecated This method only exists to provide backwards compatibility for dune-grid-2.4.
* It will be removed after the release of dune-grid-2.4.
*/
const Entity* operator->() const
DUNE_DEPRECATED_MSG("This is now an Entity instead of an EntityPointer. You do not have to dereference it anymore!")
{
return this;
}
//@}
//===========================================================
/** @name Interface for the implementor
*/
//@{
//===========================================================
//! Copy constructor from EntityImp
Entity(const EntityImp<cd,dim,GridImp> & e) : realEntity(e) {}
//! Move constructor from EntityImp
Entity(EntityImp<cd,dim,GridImp> && e) : realEntity(std::move(e)) {}
//@}
protected:
// need to make copy constructor of EntityPointer work for any iterator
template< class, class > friend class Dune::EntityPointer;
};
/**
@brief Template specialization of Dune::Entity for Elements (codim==0)
\tparam dim Dimension of the grid
\tparam GridImp Type that is a model of Dune::Grid
\tparam EntityImp Class template that is a model of Dune::Entity
@see Dune::Entity (general version) for the full documentation
\extends Entity<int cd, int dim, class GridImp, template<int,int,class> class EntityImp>
\ingroup GIEntity
\nosubgrouping
*/
template<int dim, class GridImp, template<int,int,class> class EntityImp>
class Entity <0,dim,GridImp,EntityImp>
{
#if DUNE_GRID_EXPERIMENTAL_GRID_EXTENSIONS
public:
#else
protected:
// give the GridDefaultImplementation class access to the realImp
friend class GridDefaultImplementation<
GridImp::dimension, GridImp::dimensionworld,
typename GridImp::ctype,
typename GridImp::GridFamily> ;
// Default*GridView classes need access to intersection iterators
template< class, PartitionIteratorType > friend class DefaultLevelGridView;
template< class, PartitionIteratorType > friend class DefaultLeafGridView;
#endif
// type of underlying implementation, for internal use only
typedef EntityImp< 0, dim, GridImp > Implementation;
//! Return reference to the real implementation
Implementation &impl () { return realEntity; }
//! Return const reference to the real implementation
const Implementation &impl () const { return realEntity; }
protected:
Implementation realEntity;
public:
//===========================================================
/** @name Exported types and constants
*/
//@{
//===========================================================
/** \brief The geometry type of this entity */
typedef typename GridImp::template Codim<0>::Geometry Geometry;
//! \brief The corresponding entity seed (for storage of entities)
typedef typename GridImp::template Codim<0>::EntitySeed EntitySeed;
/** \brief The geometry type of this entity when the geometry is expressed
embedded in the father element.
This differs from Geometry in particular when dim != dimworld,
but even when dim == dimworld the implementation may choose to use
a different type here.
*/
typedef typename GridImp::template Codim<0>::LocalGeometry LocalGeometry;
/** \brief EntityPointer types of the different codimensions */
template <int cd>
struct Codim
{
typedef typename GridImp::template Codim<cd>::EntityPointer EntityPointer;
typedef typename GridImp::template Codim<cd>::Entity Entity;
};
/** \brief The codim==0 EntityPointer type */
typedef typename GridImp::template Codim<0>::EntityPointer EntityPointer;
/** \brief The HierarchicIterator type*/
typedef typename GridImp::HierarchicIterator HierarchicIterator;
enum {
//! Know your own codimension
codimension=0
};
enum {
//! Know the grid's dimension
dimension=dim
};
enum {
/** \brief Know dimension of the entity */
mydimension=dim
};
//@}
//===========================================================
/** @name Methods shared by entities of all codimensions
*/
//@{
//===========================================================
//! @copydoc Dune::Entity::level()
int level () const { return realEntity.level(); }
//! @copydoc Dune::Entity::partitionType()
PartitionType partitionType () const { return realEntity.partitionType(); }
//! @copydoc Dune::Entity::geometry()
Geometry geometry () const { return realEntity.geometry(); }
/** \brief Return the name of the reference element. The type can
be used to access the Dune::ReferenceElement.
*/
GeometryType type () const { return realEntity.type(); }
/** \brief Return the entity seed which contains sufficient information
* to generate the entity again and uses as little memory as possible
*/
EntitySeed seed () const { return realEntity.seed(); }
//! Compares two entities for equality.
bool operator==(const Entity& other) const
{
return realEntity.equals(other.realEntity);
}
//! Compares two entities for inequality.
bool operator!=(const Entity& other) const
{
return !realEntity.equals(other.realEntity);
}
/** \brief Compares an Entity with an EntityPointer for equality.
*
* \deprecated This method only exists for backwards compatibility during the 2.4
* release cycle and will be removed after dune-grid-2.4 is released.
*/
template<typename ItImp>
DUNE_DEPRECATED_MSG("EntityPointer is deprecated and will be removed after the release of dune-grid-2.4. Instead, you can copy and store entities directly now.")
bool operator==(const Dune::EntityPointer<GridImp,ItImp>& other) const
{
return (*this) == (*other);
}
/** \brief Compares an Entity with an EntityPointer for equality.
*
* \deprecated This method only exists for backwards compatibility during the 2.4
* release cycle and will be removed after dune-grid-2.4 is released.
*/
template<typename ItImp>
DUNE_DEPRECATED_MSG("EntityPointer is deprecated and will be removed after the release of dune-grid-2.4. Instead, you can copy and store entities directly now.")
bool operator!=(const Dune::EntityPointer<GridImp,ItImp>& other) const
{
return (*this) != (*other);
}
Entity()
{}
//! Copy constructor from an existing entity.
Entity(const Entity& other)
: realEntity(other.realEntity)
{}
//! Move constructor from an existing entity.
Entity(Entity&& other)
: realEntity(std::move(other.realEntity))
{}
//! Copy assignment operator from an existing entity.
Entity& operator=(const Entity& other)
{
realEntity = other.realEntity;
return *this;
}
//! Move assignment operator from an existing entity.
Entity& operator=(Entity&& other)
{
realEntity = std::move(other.realEntity);
return *this;
}
/** \brief Dereference Entity to itself for backwards compatibility with EntityPointer.
*
* \deprecated This method only exists to provide backwards compatibility for dune-grid-2.4.
* It will be removed after the release of dune-grid-2.4.
*/
const Entity& operator*() const
DUNE_DEPRECATED_MSG("This is now an Entity instead of an EntityPointer. You do not have to dereference it anymore!")
{
return *this;
}
/** \brief Dereference Entity to itself for backwards compatibility with EntityPointer.
*
* \deprecated This method only exists to provide backwards compatibility for dune-grid-2.4.
* It will be removed after the release of dune-grid-2.4.
*/
const Entity* operator->() const
DUNE_DEPRECATED_MSG("This is now an Entity instead of an EntityPointer. You do not have to dereference it anymore!")
{
return this;
}
//@}
//===========================================================
/** @name Extended interface of entities of codimension 0
*/
//@{
//===========================================================
/**\brief Number of subentities with codimension <tt>cc</tt>.
*
* Strictly speaking this method is redundant, because the same information can be obtained
* from the corresponding reference element. It is here for efficiency reasons only.
*
* \deprecated This method will be removed after the release of dune-grid-2.4.
* Please use the method subEntities instead.
*/
template<int codim> int DUNE_DEPRECATED_MSG("Use subEntities(unsigned int) instead!") count () const { return realEntity.template count<codim>(); }
/**\brief Number of subentities with codimension <tt>codim</tt>.
*
* Strictly speaking this method is redundant, because the same information can be obtained
* from the corresponding reference element. It is here for efficiency reasons only.
*/
unsigned int subEntities(unsigned int codim) const
{
return realEntity.subEntities(codim);
}
#ifndef DOXYGEN
// The following ugly helper struct is here to work around deficiencies in the decltype() implementation
// of GCC 4.4.
// If we try to merge the two typedefs in the struct and put them directly into the return value of
// subEntity(), GCC 4.4 dies with an internal compiler error complaining that mangling of template_id_name
// is not supported.
// So we put everything into this separate struct and just instantiate it in the signature of subEntity()
// which makes GCC 4.4 happy.
template <int codim_>
struct subentity_return_info
{
// Step 1: Obtain return value of subentity from implementation class
//
// it would be more readable to use std::declval() here, but that's another thing that's missing
// GCC 4.4, so we do it the manual way with a static cast
typedef decltype(
static_cast<Implementation*>(nullptr)->template subEntity<codim_>(0)
) implementation_return_type;
// Step 2: Check whether the implementation returned a facade entity or not
// If yes -> declare Entity return type
// If no -> declare EntityPointer return type
typedef typename std::conditional<
std::is_same<
implementation_return_type,
typename Entity::template Codim<codim_>::Entity
>::value,
typename Entity::template Codim<codim_>::Entity,
typename Entity::template Codim<codim_>::EntityPointer
>::type type;
};
#endif // DOXYGEN
/** \brief Obtain a subentity
*
* \tparam codim codimension of the desired subentity
*
* \param[in] i number of the subentity (in generic numbering)
*
* \returns the specified subentity
*
* \note The subentities are numbered 0, ..., subEntities( codim )-1
*/
template< int codim >
#ifdef DOXYGEN
typename Codim< codim >::Entity
#else
typename subentity_return_info<codim>::type
#endif
subEntity ( int i ) const
{
warnOnDeprecatedEntityPointer<typename subentity_return_info<codim>::type>();
return realEntity.template subEntity< codim >( i );
}
/**\brief Inter-level access to father entity on the next-coarser grid.
The given entity resulted directly from a subdivision of its father
entity. The behaviour for elements on the macro grid, that is when
\ref hasFather() is false, is undefined.
\note If the partitionType of the Entity is GhostEntity,
it is not guaranteed that this method is working
or implemented in general.
For some grids it might be available, though.
*/
#ifdef DOXYGEN
Entity
father () const
#else
template<typename Foo = void>
typename std::conditional<
std::is_same<
decltype(realEntity.father()),
Entity
>::value,
Entity,
EntityPointer
>::type
father (typename std::enable_if<std::is_same<Foo,void>::value,void*>::type = nullptr) const
#endif
{
warnOnDeprecatedEntityPointer<decltype(realEntity.father())>();
return realEntity.father();
}
/**\brief Return true if entity has a father entity which can be accessed
using the father() method.
*/
bool hasFather () const
{
return realEntity.hasFather();
}
//! Returns true if the entity is contained in the leaf grid
bool isLeaf () const
{
return realEntity.isLeaf();
}
/** @brief Returns true if element is of regular type in red/green type refinement.
In bisection or hanging node refinement this is always true.
*/
bool isRegular() const { return realEntity.isRegular(); }
/** \brief Provides information how this element has been subdivided from its
* father element.
*
* The returned LocalGeometry is a model of
* Dune::Geometry<dimension,dimension,...>, mapping the reference element of
* the given entity to the reference element of its father.
*
* This information is sufficient to interpolate all degrees of freedom in
* the conforming case.
* Nonconforming may require access to neighbors of the father and
* calculations with local coordinates.
* The on-the-fly case is somewhat inefficient since degrees of freedom may be
* visited several times.
* If we store interpolation matrices, this is tolerable.
* We assume that on-the-fly implementation of interpolation is only done for
* simple discretizations.
*
* \note For ghost entities, this method is not guaranteed to be implemented.
*
* \note Previously, the geometry was encapsulated in the entity object and
* a const reference was returned.
*
* \note The returned geometry object is guaranteed to remain valid until the
* grid is modified (or deleted).
*/
LocalGeometry geometryInFather () const { return realEntity.geometryInFather(); }
/**\brief Inter-level access to elements that resulted from (recursive)
subdivision of this element.
\param[in] maxLevel Iterator does not stop at elements with level greater than maxlevel.
\return Iterator to the first son (level is not greater than maxlevel)
\note If the partitionType of the Entity is GhostEntity,
it is not guaranteed that this method is working
or implemented in general.
For some grids it might be available, though.
*/
HierarchicIterator hbegin (int maxLevel) const
{
return realEntity.hbegin(maxLevel);
}
/** \brief Returns iterator to one past the last son element
\note If the partitionType of the Entity is GhostEntity,
it is not guaranteed that this method is working
or implemented in general.
For some grids it might be available, though.
*/
HierarchicIterator hend (int maxLevel) const
{
return realEntity.hend(maxLevel);
}
/**\brief Returns true, if the entity has been created during the last call to adapt()
*/
bool isNew () const { return realEntity.isNew(); }
/**\brief Returns true, if entity might disappear during the next call to adapt().
* If the method returns false, the entity is guaranteed to still be present after
* adaptation.
*/
bool mightVanish () const { return realEntity.mightVanish(); }
/**\brief Returns true, if entity has intersections with boundary
*/
bool hasBoundaryIntersections () const { return realEntity.hasBoundaryIntersections(); }
//===========================================================
/** @name Interface for the implementor
*/
//@{
//===========================================================
//! Copy constructor from EntityImp
Entity(const EntityImp<0,dim,GridImp> & e) : realEntity(e) {}
//! Move constructor from EntityImp
Entity(EntityImp<0,dim,GridImp> && e) : realEntity(std::move(e)) {}
//@}
#ifndef DOXYGEN
// these two methods are just here for the 2.4 transition from EntityPointer to Entity
// they will generate a compile time warning if the grid implementation still returns
// an EntityPointer from certain interface methods.
// These methods are also required by the intersection facade, so I just made them public
// and hid them from Doxygen. As they don't do anything remotely useful, I don't think any
// user will try to call them manually... :-P
// this non-warning version only matches if E is an entity that has been correctly wrapped
// in a facade class
template<typename E>
static typename std::enable_if<
std::is_same<
E,
typename Codim<E::codimension>::Entity
>::value
>::type
warnOnDeprecatedEntityPointer()
{}
template<typename E>
DUNE_DEPRECATED_MSG("This grid still returns EntityPointers instead of Entities")
static typename std::enable_if<
not std::is_same<
E,
typename Codim<E::codimension>::Entity
>::value
>::type
warnOnDeprecatedEntityPointer()
{}
#endif // DOXYGEN
protected:
// needed to make copy constructor from EntityPointer work for any iterator
template< class, class > friend class Dune::EntityPointer;
};
//********************************************************************
/**
@brief Default Implementations for EntityImp
EntityDefaultImplementation provides default implementations for Entity which uses
the implemented interface which has to be done by the user.
@note this is the general version, but there is a specialization for cd=0
@ingroup GridDevel
*/
template<int cd, int dim, class GridImp, template<int,int,class> class EntityImp>
class EntityDefaultImplementation
{
public:
//! know your own codimension
enum { codimension=cd };
//! Dimension of the grid
enum { dimension=dim };
/** \brief Know dimension of the entity */
enum { mydimension=dim-cd };
//! \brief The corresponding entity seed (for storage of entities)
typedef typename GridImp::template Codim<cd>::EntitySeed EntitySeed;
//! \brief The corresponding entity seed (for storage of entities)
typedef typename GridImp::template Codim<cd>::EntityPointer EntityPointer;
/** \brief Return the name of the reference element. The type can
be used to access the Dune::ReferenceElement.
*/
GeometryType type () const { return asImp().geometry().type(); }
private:
//! Barton-Nackman trick
EntityImp<cd,dim,GridImp>& asImp ()
{
return static_cast<EntityImp<cd,dim,GridImp>&>(*this);
}
const EntityImp<cd,dim,GridImp>& asImp () const
{
return static_cast<const EntityImp<cd,dim,GridImp>&>(*this);
}
}; // end EntityDefaultImplementation
//********************************************************************
/**
@brief Default Implementations for EntityImp (Elements [cd=0])
EntityDefaultImplementation provides default implementations for Entity which uses
the implemented interface which has to be done by the user.
\extends EntityDefaultImplementation<int cd, int dim, class GridImp, template<int,int,class> class EntityImp>
@ingroup GridDevel
*/
template<int dim, class GridImp, template<int,int,class> class EntityImp>
class EntityDefaultImplementation <0,dim,GridImp,EntityImp>
{
public:
//! know your own codimension
enum { codimension=0 };
//! Dimension of the grid
enum { dimension=dim };
/** \brief Know dimension of the entity */
enum { mydimension=dim };
//! \brief The corresponding entity seed (for storage of entities)
typedef typename GridImp::template Codim<0>::EntitySeed EntitySeed;
//! \brief The corresponding entity seed (for storage of entities)
typedef typename GridImp::template Codim<0>::EntityPointer EntityPointer;
/** @brief Returns true if element is of regular type in red/green type refinement.
In bisection or hanging node refinement this is always true.
*/
bool isRegular() const { return true; }
/** \brief Return the name of the reference element. The type can
be used to access the Dune::ReferenceElement.
*/
GeometryType type () const { return asImp().geometry().type(); }
/**\brief Returns true, if the entity has been created during the last call to adapt()
*/
bool isNew () const { return false; }
/**\brief Returns true, if entity might disappear during the next call to adapt()
*/
bool mightVanish () const { return false; }
/**\brief Returns true, if entity has intersections with boundary,
this implementation uses the Level- and LeafIntersectionIterator to
check for boundary intersections
*/
bool hasBoundaryIntersections () const
{
typedef typename GridImp::LevelIntersectionIterator IntersectionIterator;
IntersectionIterator end = asImp().ilevelend();
for (IntersectionIterator it = asImp().ilevelbegin(); it != end; ++it)
if( it->boundary() )
return true;
return false;
}
private:
// Barton-Nackman trick
EntityImp<0,dim,GridImp>& asImp () { return static_cast<EntityImp<0,dim,GridImp>&>(*this); }
const EntityImp<0,dim,GridImp>& asImp () const { return static_cast<const EntityImp<0,dim,GridImp>&>(*this); }
};
}
#endif // DUNE_GRID_ENTITY_HH
|