dune-foamgrid  2.8-git
foamgridedge.hh
Go to the documentation of this file.
1 // -*- tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 // vi: set et ts=8 sw=4 sts=4:
3 
4 #ifndef DUNE_FOAMGRID_EDGE_HH
5 #define DUNE_FOAMGRID_EDGE_HH
6 
7 #include <dune/geometry/type.hh>
8 #include <dune/grid/common/gridenums.hh>
9 
11 
12 namespace Dune {
13 
15  template <int dimworld, class ctype>
16  class FoamGridEntityImp<1, 2, dimworld, ctype>
17  : public FoamGridEntityBase
18  {
19  public:
21  enum {dimgrid = 2};
22 
25  int level, unsigned int id)
26  : FoamGridEntityBase(level,id), elements_(), nSons_(0), father_(nullptr)
27  {
28  vertex_[0] = v0;
29  vertex_[1] = v1;
30  sons_[0] =sons_[1] = nullptr;
31  }
32 
33 
36  int level, unsigned int id,
37  FoamGridEntityImp* father)
38  : FoamGridEntityBase(level,id), elements_(), nSons_(0), father_(father)
39  {
40  vertex_[0] = v0;
41  vertex_[1] = v1;
42  sons_[0] =sons_[1] = nullptr;
43  }
44 
46  bool isLeaf() const {
47  return sons_[0]==nullptr;
48  }
49 
51  unsigned int boundarySegmentIndex() const {
52  return boundarySegmentIndex_;
53  }
54 
56  unsigned int boundaryId() const {
57  return boundaryId_;
58  }
59 
60  GeometryType type() const {
61  return GeometryTypes::line;
62  }
63 
64  bool hasFather() const
65  {
66  return father_!=nullptr;
67  }
68 
70  int corners() const {
71  return 2;
72  }
73 
74  FieldVector<ctype, dimworld> corner(int i) const {
75  return vertex_[i]->pos_;
76  }
77 
78  PartitionType partitionType() const {
79  return InteriorEntity;
80  }
81 
84  int subLevelIndex (int i, unsigned int codim) const {
85  assert(1<=codim && codim<=2);
86  switch (codim) {
87  case 1:
88  return this->levelIndex_;
89  case 2:
90  return vertex_[i]->levelIndex_;
91  }
92  DUNE_THROW(GridError, "Non-existing codimension requested!");
93  }
94 
97  int subLeafIndex (int i,unsigned int codim) const {
98  assert(1<=codim && codim<=2);
99  switch (codim) {
100  case 1:
101  return this->leafIndex_;
102  case 2:
103  return vertex_[i]->leafIndex_;
104  }
105  DUNE_THROW(GridError, "Non-existing codimension requested!");
106  }
107 
108  std::vector<const FoamGridEntityImp<dimgrid, dimgrid, dimworld, ctype>*> elements_;
109 
110  std::array<const FoamGridEntityImp<0, dimgrid, dimworld, ctype>*, 2> vertex_;
111 
113  unsigned int boundarySegmentIndex_;
114  unsigned int boundaryId_;
115 
117  std::array<FoamGridEntityImp<1, dimgrid, dimworld, ctype>*,2> sons_;
118 
120  unsigned int nSons_;
121 
124 
125  };
126 
127 }
128 
129 #endif
Definition: dgffoam.cc:6
std::array< const FoamGridEntityImp< 0, dimgrid, dimworld, ctype > *, 2 > vertex_
Definition: foamgridedge.hh:110
FoamGridEntityImp(const FoamGridEntityImp< 0, dimgrid, dimworld, ctype > *v0, const FoamGridEntityImp< 0, dimgrid, dimworld, ctype > *v1, int level, unsigned int id, FoamGridEntityImp *father)
Definition: foamgridedge.hh:34
PartitionType partitionType() const
Definition: foamgridedge.hh:78
unsigned int boundarySegmentIndex() const
This has no function yet in Foamgrid.
Definition: foamgridedge.hh:51
unsigned int nSons_
The number of refined edges (0 or 2).
Definition: foamgridedge.hh:120
unsigned int boundarySegmentIndex_
The boundary id. Only used if this edge is a boundary edge.
Definition: foamgridedge.hh:113
FoamGridEntityImp< 1, dimgrid, dimworld, ctype > * father_
Pointer to father edge.
Definition: foamgridedge.hh:123
FoamGridEntityImp(const FoamGridEntityImp< 0, dimgrid, dimworld, ctype > *v0, const FoamGridEntityImp< 0, dimgrid, dimworld, ctype > *v1, int level, unsigned int id)
Definition: foamgridedge.hh:23
unsigned int boundaryId() const
This has no function yet in Foamgrid.
Definition: foamgridedge.hh:56
bool isLeaf() const
Definition: foamgridedge.hh:46
std::array< FoamGridEntityImp< 1, dimgrid, dimworld, ctype > *, 2 > sons_
links to refinements of this edge
Definition: foamgridedge.hh:117
bool hasFather() const
Definition: foamgridedge.hh:64
int corners() const
Number of corners (==2)
Definition: foamgridedge.hh:70
unsigned int boundaryId_
Definition: foamgridedge.hh:114
int subLevelIndex(int i, unsigned int codim) const
Return level index of sub entity with codim = cc and local number i.
Definition: foamgridedge.hh:84
int subLeafIndex(int i, unsigned int codim) const
Return leaf index of sub entity with codim = cc and local number i.
Definition: foamgridedge.hh:97
std::vector< const FoamGridEntityImp< dimgrid, dimgrid, dimworld, ctype > * > elements_
Definition: foamgridedge.hh:108
GeometryType type() const
Definition: foamgridedge.hh:60
FieldVector< ctype, dimworld > corner(int i) const
Definition: foamgridedge.hh:74
Base class for FoamGrid entity implementation classes.
Definition: foamgridvertex.hh:16
The actual entity implementation.
Definition: foamgridvertex.hh:47
Vertex specialization of FoamGridEntityImp.
Definition: foamgridvertex.hh:53