dune-mmesh 1.4.1-git
Loading...
Searching...
No Matches
interface/cachingentity.hh
Go to the documentation of this file.
1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2// vi: set et ts=4 sw=2 sts=2:
3#ifndef DUNE_MMESH_INTERFACE_CACHINGENTITY_HH
4#define DUNE_MMESH_INTERFACE_CACHINGENTITY_HH
5
10#include <set>
11
12// Dune includes
13#include <dune/grid/common/grid.hh>
14
15// MMesh includes
18
19namespace Dune {
20// Forward declarations
21template <int codim, int dim, class GridImp>
23
24//**********************************************************************
25//
26// --MMeshInterfaceCachingEntity
27// --Entity
28//
33template <int dim, class GridImp>
35 : public MMeshInterfaceGridEntity<0, dim, GridImp> {
36 template <class GridImp_>
38
39 template <class GridImp_>
40 friend class MMeshInterfaceGridLocalIdSet;
41
42 template <class GridImp_>
44
45 private:
46 // this type
48
49 // base type
51
52 // type of scalars
53 typedef typename GridImp::ctype ctype;
54
55 // type of the host grid
56 typedef typename GridImp::HostGridType HostGrid;
57
58 // type of entity
59 typedef typename GridImp::template Codim<0>::Entity Element;
60
61 // standard MMesh entity implementation
62 typedef typename GridImp::template Codim<0>::Entity MMeshEntity;
63
64 // type of ids
66
67 public:
68 // geometry type
70
71 // type of global coordinate
73
75
76 explicit MMeshInterfaceCachingEntity(const Element& element)
77 : BaseType(&element.impl().grid(), element.impl().hostEntity(),
78 element.impl().grid().globalIdSet().id(element)) {
79 for (int i = 0; i < dim + 1; ++i)
80 this->vertex_[i] = element.geometry().corner(i);
81 }
82
85 return this->id_ == other.id_;
86 }
87
90 return this->equals(other);
91 }
92
94 bool operator==(const MMeshEntity& entity) const {
95 return this->id_ == entity.impl().grid()->globalIdSet().id(entity);
96 }
97
100 return this->id_ < other.id_;
101 }
102
104 bool hasFather() const { return false; }
105
107 const bool isNew() const { return false; }
108
110 const bool mightVanish() const { return true; }
111
113 int level() const {
114 // we only have one level
115 return 0;
116 }
117
120 return PartitionType::InteriorEntity; /* dummy */
121 }
122
125 return Geometry(GeometryTypes::simplex(dim), this->vertex_);
126 }
127
129 unsigned int subEntities(unsigned int cc) const {
130 // we have a simplex grid
131 int n = dim + 1;
132 int k = dim - cc + 1;
133
134 // binomial: n over k
135 int binomial = 1;
136 for (int i = n - k + 1; i <= n; i++) binomial *= i;
137 for (long i = 2; i <= k; i++) binomial /= i;
138
139 return binomial;
140 }
141
143 bool isLeaf() const { return false; }
144
145 // calculates the intersection volume with another entity
146 ctype intersectionVolume(const MMeshEntity& entity) const {
147 // assuming simple components (of 2 entities)
148 return std::min(geometry().volume(), entity.geometry().volume());
149 }
150
151}; // end of MMeshInterfaceCachingEntity codim = 0
152
153} // namespace Dune
154
155#endif
The multi id class.
Helpers for conversion from CGAL::Point_x to DUNE::FieldVector.
int id()
bool equals(const SLListConstIterator< T, A > &other) const
size_type dim() const
static constexpr T binomial(const T &n, const T &k) noexcept
@ Element
Definition curvatureoperator.hh:22
PartitionType
const EntityType & entity() const
const Geometry & geometry() const
StackAllocator< U, S > other
Definition multiid.hh:15
Definition interface/cachingentity.hh:22
The implementation of caching entities in a MMesh interface grid.
Definition interface/cachingentity.hh:35
int level() const
Level of this element.
Definition interface/cachingentity.hh:113
bool equals(const MMeshInterfaceCachingEntity &other) const
returns true if host entities are equal
Definition interface/cachingentity.hh:84
const bool mightVanish() const
returns true if this entity will vanish after adaptation
Definition interface/cachingentity.hh:110
bool isLeaf() const
returns true if Entity has no children
Definition interface/cachingentity.hh:143
AffineGeometry< ctype, dim, dim+1 > Geometry
Definition interface/cachingentity.hh:69
bool hasFather() const
returns true if father entity exists
Definition interface/cachingentity.hh:104
unsigned int subEntities(unsigned int cc) const
Return the number of subEntities of codimension cc.
Definition interface/cachingentity.hh:129
Geometry geometry() const
Geometry of this entity.
Definition interface/cachingentity.hh:124
MMeshInterfaceCachingEntity(const Element &element)
Definition interface/cachingentity.hh:76
ctype intersectionVolume(const MMeshEntity &entity) const
Definition interface/cachingentity.hh:146
const bool isNew() const
returns true if this entity is new after adaptation
Definition interface/cachingentity.hh:107
Geometry::GlobalCoordinate GlobalCoordinate
Definition interface/cachingentity.hh:72
PartitionType partitionType() const
The partition type for parallel computing.
Definition interface/cachingentity.hh:119
bool operator<(const MMeshInterfaceCachingEntity &other) const
returns true if id of other is greater
Definition interface/cachingentity.hh:99
bool operator==(const MMeshInterfaceCachingEntity &other) const
returns true if host entities are equal
Definition interface/cachingentity.hh:89
bool operator==(const MMeshEntity &entity) const
returns true if caching entity has same id like mmesh entity
Definition interface/cachingentity.hh:94
The implementation of entities in a MMesh interface grid.
Definition interface/entity.hh:34
Specialization for codim-0-entities.
Definition interface/entity.hh:328
Geometry geometry() const
Geometry of this entity.
Definition interface/entity.hh:548
Definition interface/indexsets.hh:18
Definition interface/indexsets.hh:355
T min(T... args)