refinementGraphics.hh

Go to the documentation of this file.
1 
6 #ifndef refinementGraphics_hh
7 #define refinementGraphics_hh
8 
10 using concepts::Real;
11 
12 namespace estimator{
13 
14 template<ushort dim = 2>
16 public:
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) {
27  concepts::ElementWithCell<Real>& elm = (*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 
118 virtual PolynomialDegrees<dim>* clone() const{return new PolynomialDegrees<dim>(*this);}
119 
120 protected:
121  virtual std::ostream& info(std::ostream& os) const{
122  return os << concepts::typeOf(*this) << " : " << p_ << "]";
123  }
124 
125 private:
127 
128  //map from key to connector to check later
130 
131 }; //class
132 
133 
134 
135 
136 
137 
138 template<class F = Real>
140 public:
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 
161 virtual KeysInfo<F>* clone() const{return new KeysInfo<F>(*this);}
162 
163 protected:
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
virtual PolynomialDegrees< dim > * clone() const
Virtual constructor.
virtual Real operator()(const concepts::Connector &cntr, const concepts::Real3d &p, const Real t=0.0) const
virtual Connector & connector() const =0
Returns the connector.
virtual F operator()(const concepts::Connector &cntr, const concepts::Real3d &p, const Real t=0.0) const
Piecewise defined function on a number of cells.
#define conceptsException(exc)
Prepares an exception for throwing.
Definition: exceptions.hh:344
virtual const ushort * innerDof(const concepts::Connector2 &cntr) const
Returns a pointer to the maximal polynomial degrees of the inner degree of freedom in the cell quad.
Helper class for building 2D hp-FEM spaces (space pre builder).
#define conceptsAssert(cond, exc)
Assert that a certain condition is fulfilled.
Definition: exceptions.hh:394
hp-adaptive space with 2D elements.
virtual F operator()(const concepts::Connector &cntr, const Real p, const Real t=0.0) const
An array of objects.
Definition: bilinearForm.hh:23
Exception class for assertions.
Definition: exceptions.hh:258
const Key & key() const
Returns the key of the connector.
Definition: connector.hh:105
A 2D element of the topology.
Definition: connector.hh:226
virtual bool vtxDof(const concepts::Connector2 &cntr, uint i) const
Returns, if the i th vertex of cell cntr has a degree of freedom.
virtual Scan * scan() const
Returns a scanner to iterate over the elements of the space.
virtual KeysInfo< F > * clone() const
Virtual constructor.
virtual Real operator()(const concepts::Connector &cntr, const concepts::Real2d &p, const Real t=0.0) const
virtual std::ostream & info(std::ostream &os) const
Returns information in an output stream.
virtual const Cell & cell() const =0
Returns the cell on which the element is built.
Abstract class for a space.
Definition: space.hh:81
concepts::HashMap< concepts::Array< ushort > > p_
unsigned short ushort
Abbreviation for unsigned short.
Definition: typedefs.hh:48
concepts::HashMap< const concepts::Connector * > cntr_
Exception class to express a missing feature.
Definition: exceptions.hh:206
virtual F operator()(const concepts::Connector &cntr, const concepts::Real2d &p, const Real t=0.0) const
std::string typeOf(const T &t)
Return the typeid name of a class object.
Definition: output.hh:43
uint key() const
Returns the key.
Definition: connector.hh:66
virtual Real operator()(const concepts::Connector &cntr, const Real p, const Real t=0.0) const
PolynomialDegrees(const concepts::SpaceOnCells< F > &space)
virtual ushort edgeDof(const concepts::Connector2 &cntr, uint i) const
Returns the maximal polynomial degree of the degrees of freedom on edge i in the cell cntr.
An abstract class for elements of the topology.
Definition: connector.hh:85
virtual std::ostream & info(std::ostream &os) const
Returns information in an output stream.
double Real
Type normally used for a floating point number.
Definition: typedefs.hh:36
Page URL: http://wiki.math.ethz.ch/bin/view/Concepts/WebHome
21 August 2020
© 2020 Eidgenössische Technische Hochschule Zürich