Loading [MathJax]/extensions/tex2jax.js

dune-mmesh (1.4)

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{
21 // Forward declarations
22 template<int codim, int dim, class GridImp>
23 class MMeshInterfaceCachingEntity;
24
25 //**********************************************************************
26 //
27 // --MMeshInterfaceCachingEntity
28 // --Entity
29 //
34 template<int dim, class GridImp>
35 class MMeshInterfaceCachingEntity<0,dim,GridImp> :
36 public MMeshInterfaceGridEntity<0,dim,GridImp>
37 {
38 template <class GridImp_>
39 friend class MMeshInterfaceGridLeafIndexSet;
40
41 template <class GridImp_>
42 friend class MMeshInterfaceGridLocalIdSet;
43
44 template <class GridImp_>
45 friend class MMeshInterfaceGridGlobalIdSet;
46
47 private:
48 // this type
50
51 // base type
53
54 // type of scalars
55 typedef typename GridImp::ctype ctype;
56
57 // type of the host grid
58 typedef typename GridImp::HostGridType HostGrid;
59
60 // type of entity
61 typedef typename GridImp::template Codim<0>::Entity Element;
62
63 // standard MMesh entity implementation
64 typedef typename GridImp::template Codim<0>::Entity MMeshEntity;
65
66 // type of ids
67 typedef MMeshImpl::MultiId IdType;
68
69 public:
70 // geometry type
71 typedef AffineGeometry<ctype, dim, dim+1> Geometry;
72
73 // type of global coordinate
74 typedef typename Geometry::GlobalCoordinate GlobalCoordinate;
75
76 MMeshInterfaceCachingEntity() = delete;
77
78 explicit MMeshInterfaceCachingEntity(const Element& element)
79 : BaseType(
80 &element.impl().grid(),
81 element.impl().hostEntity(),
82 element.impl().grid().globalIdSet().id( element )
83 )
84 {
85 for ( int i = 0; i < dim+1; ++i )
86 this->vertex_[i] = element.geometry().corner(i);
87 }
88
90 bool equals(const MMeshInterfaceCachingEntity& other) const
91 {
92 return this->id_ == other.id_;
93 }
94
96 bool operator==(const MMeshInterfaceCachingEntity& other) const
97 {
98 return this->equals(other);
99 }
100
102 bool operator==(const MMeshEntity& entity) const
103 {
104 return this->id_ == entity.impl().grid()->globalIdSet().id( entity );
105 }
106
108 bool operator<(const MMeshInterfaceCachingEntity& other) const
109 {
110 return this->id_ < other.id_;
111 }
112
114 bool hasFather () const
115 {
116 return false;
117 }
118
120 const bool isNew () const
121 {
122 return false;
123 }
124
126 const bool mightVanish () const
127 {
128 return true;
129 }
130
132 int level () const
133 {
134 // we only have one level
135 return 0;
136 }
137
139 PartitionType partitionType () const {
140 return PartitionType::InteriorEntity; /* dummy */
141 }
142
144 Geometry geometry () const
145 {
146 return Geometry( GeometryTypes::simplex(dim), this->vertex_ );
147 }
148
150 unsigned int subEntities (unsigned int cc) const
151 {
152 // we have a simplex grid
153 int n = dim+1;
154 int k = dim-cc+1;
155
156 // binomial: n over k
157 int binomial=1;
158 for (int i=n-k+1; i<=n; i++)
159 binomial *= i;
160 for (long i=2; i<=k; i++)
161 binomial /= i;
162
163 return binomial;
164 }
165
167 bool isLeaf() const {
168 return false;
169 }
170
171 //calculates the intersection volume with another entity
172 ctype intersectionVolume ( const MMeshEntity& entity ) const
173 {
174 // assuming simple components (of 2 entities)
175 return std::min( geometry().volume(), entity.geometry().volume() );
176 }
177
178 }; // end of MMeshInterfaceCachingEntity codim = 0
179
180} // namespace Dune
181
182#endif
The implementation of entities in a MMesh.
Definition: entity.hh:53
Geometry geometry() const
geometry of this entity
Definition: entity.hh:363
The implementation of caching entities in a MMesh interface grid.
Definition: cachingentity.hh:37
int level() const
Level of this element.
Definition: cachingentity.hh:132
bool equals(const MMeshInterfaceCachingEntity &other) const
returns true if host entities are equal
Definition: cachingentity.hh:90
const bool mightVanish() const
returns true if this entity will vanish after adaptation
Definition: cachingentity.hh:126
bool isLeaf() const
returns true if Entity has no children
Definition: cachingentity.hh:167
bool hasFather() const
returns true if father entity exists
Definition: cachingentity.hh:114
unsigned int subEntities(unsigned int cc) const
Return the number of subEntities of codimension cc.
Definition: cachingentity.hh:150
Geometry geometry() const
Geometry of this entity.
Definition: cachingentity.hh:144
const bool isNew() const
returns true if this entity is new after adaptation
Definition: cachingentity.hh:120
PartitionType partitionType() const
The partition type for parallel computing.
Definition: cachingentity.hh:139
bool operator<(const MMeshInterfaceCachingEntity &other) const
returns true if id of other is greater
Definition: cachingentity.hh:108
bool operator==(const MMeshInterfaceCachingEntity &other) const
returns true if host entities are equal
Definition: cachingentity.hh:96
bool operator==(const MMeshEntity &entity) const
returns true if caching entity has same id like mmesh entity
Definition: cachingentity.hh:102
Specialization for codim-0-entities.
Definition: entity.hh:373
Geometry geometry() const
Geometry of this entity.
Definition: entity.hh:616
The implementation of entities in a MMesh interface grid.
Definition: entity.hh:35
The multi id class.
Helpers for conversion from CGAL::Point_x to DUNE::FieldVector.
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden & Uni Heidelberg  |  generated with Hugo v0.111.3 (Apr 13, 22:42, 2025)