dune-mmesh (unstable)

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>
22class MMeshInterfaceCachingEntity;
23
24//**********************************************************************
25//
26// --MMeshInterfaceCachingEntity
27// --Entity
28//
33template <int dim, class GridImp>
34class MMeshInterfaceCachingEntity<0, dim, GridImp>
35 : public MMeshInterfaceGridEntity<0, dim, GridImp> {
36 template <class GridImp_>
37 friend class MMeshInterfaceGridLeafIndexSet;
38
39 template <class GridImp_>
40 friend class MMeshInterfaceGridLocalIdSet;
41
42 template <class GridImp_>
43 friend class MMeshInterfaceGridGlobalIdSet;
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
65 typedef MMeshImpl::MultiId IdType;
66
67 public:
68 // geometry type
69 typedef AffineGeometry<ctype, dim, dim + 1> Geometry;
70
71 // type of global coordinate
72 typedef typename Geometry::GlobalCoordinate GlobalCoordinate;
73
74 MMeshInterfaceCachingEntity() = delete;
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
84 bool equals(const MMeshInterfaceCachingEntity& other) const {
85 return this->id_ == other.id_;
86 }
87
89 bool operator==(const MMeshInterfaceCachingEntity& other) const {
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
99 bool operator<(const MMeshInterfaceCachingEntity& other) const {
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
119 PartitionType partitionType() const {
120 return PartitionType::InteriorEntity; /* dummy */
121 }
122
124 Geometry geometry() const {
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 implementation of entities in a MMesh.
Definition: entity.hh:50
Geometry geometry() const
geometry of this entity
Definition: entity.hh:335
The implementation of caching entities in a MMesh interface grid.
Definition: cachingentity.hh:35
int level() const
Level of this element.
Definition: cachingentity.hh:113
bool equals(const MMeshInterfaceCachingEntity &other) const
returns true if host entities are equal
Definition: cachingentity.hh:84
const bool mightVanish() const
returns true if this entity will vanish after adaptation
Definition: cachingentity.hh:110
bool isLeaf() const
returns true if Entity has no children
Definition: cachingentity.hh:143
bool hasFather() const
returns true if father entity exists
Definition: cachingentity.hh:104
unsigned int subEntities(unsigned int cc) const
Return the number of subEntities of codimension cc.
Definition: cachingentity.hh:129
Geometry geometry() const
Geometry of this entity.
Definition: cachingentity.hh:124
const bool isNew() const
returns true if this entity is new after adaptation
Definition: cachingentity.hh:107
PartitionType partitionType() const
The partition type for parallel computing.
Definition: cachingentity.hh:119
bool operator<(const MMeshInterfaceCachingEntity &other) const
returns true if id of other is greater
Definition: cachingentity.hh:99
bool operator==(const MMeshInterfaceCachingEntity &other) const
returns true if host entities are equal
Definition: cachingentity.hh:89
bool operator==(const MMeshEntity &entity) const
returns true if caching entity has same id like mmesh entity
Definition: cachingentity.hh:94
Specialization for codim-0-entities.
Definition: entity.hh:328
Geometry geometry() const
Geometry of this entity.
Definition: entity.hh:548
The implementation of entities in a MMesh interface grid.
Definition: entity.hh:34
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 (Mar 17, 23:30, 2025)