Class documentation of Concepts

Loading...
Searching...
No Matches
refinementGraphics.hh
Go to the documentation of this file.
1
6#ifndef refinementGraphics_hh
7#define refinementGraphics_hh
8
10using concepts::Real;
11
12namespace estimator{
13
14template<ushort dim = 2>
16public:
17
18 template<class F=Real>
20
21 const hp2D::hpAdaptiveSpace<F>* spc = dynamic_cast<const hp2D::hpAdaptiveSpace<F>* >(&space);
22 if(spc){
23 //information about the polynomial degree
24 hp2D::hpFull& hpfull = spc->prebuild();
25 std::unique_ptr<hp2D::hpAdaptiveSpaceH1::Scanner> sc(spc->scan());
26 while (*sc) {
28 //key of current element
29 uint K = elm.cell().connector().key().key();
30 const concepts::Connector2* cntr =
31 dynamic_cast<const concepts::Connector2*>(&elm.cell().connector());
32 //the cntr must be 2d since it is out of hpAdaptiveSpace
34
35 cntr_[K] = cntr;
36 //set maximal polynomial degree (i.e inner), if no inner exists
37 // default is 1 if there is a vertex dof on this cell
38 const ushort* pMax = hpfull.innerDof(*cntr);
39
40 //no inner dof
41 if(pMax == 0){
42 //check if there is at least one dof, i.e a vertex dof
43 //this has 4 vertexList searches (costs?)
44 bool hasVDof = (hpfull.vtxDof(*cntr, 0) || hpfull.vtxDof(*cntr, 1) ||
45 hpfull.vtxDof(*cntr, 2) || hpfull.vtxDof(*cntr, 3));
46 if(hasVDof){
47 //set default to one
48 p_[K] = concepts::Array<ushort>(dim);
49 for(ushort i = 0 ; i < dim; ++i)
50 p_[K][i] = 1;
51 }else{
52 //no dofs on vertices, e.g. :
53 //
54 // Cell x for h=1 only has hanging nodes as vertices and is therefore not supported
55 // __________
56 // |__________|
57 // | |x| |
58 // | |_|
59 // |___|_|____|
60 throw conceptsException(concepts::MissingFeature("Cell has no vertex dofs, cannot be handled atm"));
61 }
62 }else{
63 //has inner Dof and therefore a polynomial degree >= 2
64 p_[K] = concepts::Array<ushort>(dim);
65 for(ushort i = 0 ; i < dim; ++i)
66 p_[K][i] = std::max(pMax[i], hpfull.edgeDof(*cntr, i));
67 }
68 }
69 }else//no hp2D space
70 throw conceptsException(concepts::MissingFeature("Currently just hpAdaptiveSpace supported"));
71 }//constructor
72
73 virtual Real operator()(const concepts::Connector& cntr, const Real p, const Real t = 0.0) const{
74 //key of current Element
75 uint K = cntr.key();
76 //check if same connector
77 //const concepts::Connector* cntr2 = cntr_.find(K)->second;
78 if( (&cntr) == cntr_.find(K)->second){
79 concepts::HashMap<concepts::Array<ushort> >::const_iterator iter = p_.find(K);
80 if(iter != p_.end()){
81 conceptsAssert(iter->second[0] == iter->second[1] && dim == 2, concepts::Assertion());
82 return iter->second[0];
83 }
84 }
85 return 0;
86 }
87
88 virtual Real operator()(const concepts::Connector& cntr, const concepts::Real2d& p, const Real t = 0.0) const{
89 //key of current Element
90 uint K = cntr.key();
91 //check if same connector
92 //const concepts::Connector* cntr2 = cntr_.find(K)->second;
93 if( (&cntr) == cntr_.find(K)->second){
94 concepts::HashMap<concepts::Array<ushort> >::const_iterator iter = p_.find(K);
95 if(iter != p_.end()){
96 conceptsAssert(iter->second[0] == iter->second[1] && dim == 2, concepts::Assertion());
97 return iter->second[0];
98 }
99 }
100 return 0;
101 }
102
103 virtual Real operator()(const concepts::Connector& cntr, const concepts::Real3d& p, const Real t = 0.0) const{
104 //key of current Element
105 uint K = cntr.key();
106 //check if same connector
107 //const concepts::Connector* cntr2 = cntr_.find(K)->second;
108 if( (&cntr) == cntr_.find(K)->second){
109 concepts::HashMap<concepts::Array<ushort> >::const_iterator iter = p_.find(K);
110 if(iter != p_.end()){
111 conceptsAssert(iter->second[0] == iter->second[1] && dim == 2, concepts::Assertion());
112 return iter->second[0];
113 }
114 }
115 return 0;
116 }
117
118virtual PolynomialDegrees<dim>* clone() const{return new PolynomialDegrees<dim>(*this);}
119
120protected:
121 virtual std::ostream& info(std::ostream& os) const{
122 return os << concepts::typeOf(*this) << " : " << p_ << "]";
123 }
124
125private:
127
128 //map from key to connector to check later
130
131}; //class
132
133
134
135
136
137
138template<class F = Real>
140public:
141 KeysInfo(){}
142
143 virtual F operator()(const concepts::Connector& cntr, const Real p, const Real t = 0.0) const{
144 //key of current Element
145 uint K = cntr.key();
146 return K;
147 }
148
149 virtual F operator()(const concepts::Connector& cntr, const concepts::Real2d& p, const Real t = 0.0) const{
150 //key of current Element
151 uint K = cntr.key();
152 return K;
153 }
154
155 virtual F operator()(const concepts::Connector& cntr, const concepts::Real3d& p, const Real t = 0.0) const{
156 //key of current Element
157 uint K = cntr.key();
158 return K;
159 }
160
161virtual KeysInfo<F>* clone() const{return new KeysInfo<F>(*this);}
162
163protected:
164 virtual std::ostream& info(std::ostream& os) const{
165 return os << concepts::typeOf(*this);
166 }
167}; //class
168
169
170
171
172
173
174//,const Refinement<F>& ref
175
176}//namespace estimator
177
178#endif //refinementGraphics_hh
#define conceptsException(exc)
virtual Connector & connector() const =0
Returns the connector.
const Key & key() const
Returns the key of the connector.
Definition connector.hh:105
virtual const Cell & cell() const =0
Returns the cell on which the element is built.
uint key() const
Returns the key.
Definition connector.hh:66
virtual KeysInfo< F > * clone() const
Virtual copy constructor.
virtual std::ostream & info(std::ostream &os) const
Returns information in an output stream.
virtual PolynomialDegrees< dim > * clone() const
Virtual copy constructor.
virtual std::ostream & info(std::ostream &os) const
Returns information in an output stream.
virtual Scan * scan() const
Returns a scanner to iterate over the elements of the space.
virtual const ushort * innerDof(const concepts::Connector2 &cntr) const
virtual ushort edgeDof(const concepts::Connector2 &cntr, uint i) const
virtual bool vtxDof(const concepts::Connector2 &cntr, uint i) const
#define conceptsAssert(cond, exc)
std::string typeOf(const T &t)
Definition output.hh:43
double Real
Definition typedefs.hh:39
Set< F > makeSet(uint n, const F &first,...)
Definition set.hh:320