dune-foamgrid 2.8.0
Loading...
Searching...
No Matches
foamgridvertex.hh
Go to the documentation of this file.
1// -*- tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2// vi: set ts=8 sw=4 et sts=4:
3#ifndef DUNE_FOAMGRID_VERTEX_HH
4#define DUNE_FOAMGRID_VERTEX_HH
5
6#include <dune/common/fvector.hh>
7#include <dune/geometry/type.hh>
8#include <dune/grid/common/gridenums.hh>
9#include <dune/grid/common/exceptions.hh>
10
11
12namespace Dune {
13
16 {
17 public:
18 FoamGridEntityBase(int level, unsigned int id)
19 : level_(level), id_(id), willVanish_()
20 {}
21
22 int level() const {
23 return level_;
24 }
25
27 int level_;
28
30 unsigned int levelIndex_;
31
32 unsigned int leafIndex_;
33
34 unsigned int id_;
37 };
38
46 template <int dimentity, int dimgrid, int dimworld, class ctype>
48
50 template <int dimgrid, int dimworld, class ctype>
51 class FoamGridEntityImp<0, dimgrid, dimworld, ctype>
52 : public FoamGridEntityBase
53 {
54 public:
55
56 FoamGridEntityImp(int level, const FieldVector<ctype, dimworld>& pos, unsigned int id)
57 : FoamGridEntityBase(level, id), pos_(pos), nSons_(0)
58 , elements_(), vertex_{{this}}, father_(nullptr), isNew_(false)
59 , growthInsertionIndex_(-1)
60 {
61 sons_[0] = nullptr;
62 }
63
64 bool isLeaf() const {
65 return sons_[0]==nullptr;
66 }
67
68 GeometryType type() const {
69 return GeometryTypes::vertex;
70 }
71
72 bool hasFather() const
73 {
74 return father_!=nullptr;
75 }
76
78 unsigned int boundarySegmentIndex() const {
79 return boundarySegmentIndex_;
80 }
81
83 unsigned int boundaryId() const {
84 return boundaryId_;
85 }
86
88 int corners() const {
89 return 1;
90 }
91
92 FieldVector<ctype, dimworld> corner(int i) const {
93 assert(i<this->corners());
94 return pos_;
95 }
96
97 PartitionType partitionType() const {
98 return InteriorEntity;
99 }
100
103 int subLevelIndex (int i, unsigned int codim) const {
104 assert(codim==dimgrid);
105 return this->levelIndex_;
106 DUNE_THROW(GridError, "Non-existing codimension requested!");
107 }
108
111 int subLeafIndex (int i, unsigned int codim) const {
112 assert(codim==dimgrid);
113 return this->leafIndex_;
114 DUNE_THROW(GridError, "Non-existing codimension requested!");
115 }
116
118 FieldVector<ctype, dimworld> pos_;
119
121 unsigned int nSons_;
122
124 std::vector<const FoamGridEntityImp<dimgrid, dimgrid ,dimworld, ctype>*> elements_;
125
127 std::array<const FoamGridEntityImp<0, dimgrid ,dimworld, ctype>*, 1> vertex_;
128
130 // only used if the vertex is a boundary vertex
132 unsigned int boundaryId_;
133
136
138 std::array<FoamGridEntityImp<0, dimgrid, dimworld, ctype>*, 1> sons_;
139
141 bool isNew_;
142
149 };
150
151}
152
153#endif
Definition: dgffoam.cc:6
Base class for FoamGrid entity implementation classes.
Definition: foamgridvertex.hh:16
FoamGridEntityBase(int level, unsigned int id)
Definition: foamgridvertex.hh:18
int level_
level
Definition: foamgridvertex.hh:27
unsigned int levelIndex_
entity number
Definition: foamgridvertex.hh:30
int level() const
Definition: foamgridvertex.hh:22
unsigned int id_
Definition: foamgridvertex.hh:34
bool willVanish_
Whether this entity will vanish due to coarsening.
Definition: foamgridvertex.hh:36
unsigned int leafIndex_
Definition: foamgridvertex.hh:32
The actual entity implementation.
Definition: foamgridvertex.hh:47
unsigned int nSons_
The number of refined vertices *‍/.
Definition: foamgridvertex.hh:121
int subLeafIndex(int i, unsigned int codim) const
Return leaf index of sub entity with codim = cc and local number i.
Definition: foamgridvertex.hh:111
std::array< FoamGridEntityImp< 0, dimgrid, dimworld, ctype > *, 1 > sons_
Son vertex on the next finer grid.
Definition: foamgridvertex.hh:138
bool hasFather() const
Definition: foamgridvertex.hh:72
PartitionType partitionType() const
Definition: foamgridvertex.hh:97
FoamGridEntityImp< 0, dimgrid, dimworld, ctype > * father_
Pointer to father vertex on next coarser grid *‍/.
Definition: foamgridvertex.hh:135
FieldVector< ctype, dimworld > pos_
Position vector of this vertex.
Definition: foamgridvertex.hh:118
GeometryType type() const
Definition: foamgridvertex.hh:68
unsigned int boundaryId_
Definition: foamgridvertex.hh:132
int growthInsertionIndex_
If this vertex was created in a growth step this will be the index of insertion So if this is the fir...
Definition: foamgridvertex.hh:148
FoamGridEntityImp(int level, const FieldVector< ctype, dimworld > &pos, unsigned int id)
Definition: foamgridvertex.hh:56
std::array< const FoamGridEntityImp< 0, dimgrid,dimworld, ctype > *, 1 > vertex_
A vertex array for compatibility reasons with edges. Initialized with the this pointer.
Definition: foamgridvertex.hh:127
unsigned int boundarySegmentIndex() const
This has no function yet in Foamgrid.
Definition: foamgridvertex.hh:78
bool isLeaf() const
Definition: foamgridvertex.hh:64
int corners() const
Number of corners (==1)
Definition: foamgridvertex.hh:88
FieldVector< ctype, dimworld > corner(int i) const
Definition: foamgridvertex.hh:92
std::vector< const FoamGridEntityImp< dimgrid, dimgrid,dimworld, ctype > * > elements_
Elements the vertex is related to.
Definition: foamgridvertex.hh:124
unsigned int boundarySegmentIndex_
Boundary index if vertex is on boundary.
Definition: foamgridvertex.hh:131
int subLevelIndex(int i, unsigned int codim) const
Return level index of sub entity with codim = cc and local number i.
Definition: foamgridvertex.hh:103
unsigned int boundaryId() const
This has no function yet in Foamgrid.
Definition: foamgridvertex.hh:83
bool isNew_
If the vertex was newly inserted (at run-time)
Definition: foamgridvertex.hh:141