innerResidual.hh

Go to the documentation of this file.
1 
7 #ifndef innerResidual_own_hh
8 #define innerResidual_own_hh
9 
10 //TODO: Includes
11 #include "basics/exceptions.hh"
12 
13 #include "space.hh"
14 #include "hp2D.hh"
15 #include "geometry.hh"
16 #include "toolbox.hh"
17 #include "operator.hh"
18 
19 #include "basics.hh"
20 #include "function.hh"
21 
22 #define fillEntrieAddM 0
23 #define ADD_D 0
24 
25 namespace concepts{
26 
27 // forward declaration
28 template<class F, class G>
29 class LinearForm;
30 
31 template<class F>
32 class Space;
33 
34 using concepts::Real;
35 
36 /* TODO:
37  * - Documenntation beispielklassen nennen die nur auf randbasisfunktionen aufbauen
38  * - Schreibe Operator und PatchRHS operator
39  * - dont make ElementMatrix use Array
40  *
41  * -Der Space muss ein hpAdaptiveSpaceH1 erstmal sein sonst nicht implementiert
42  * -Die Linearform muss Elemente aus dem entsprechenden Raum nur annehmen können!
43  * -Die Linearform darf nur eine Linearform_0 oder _1 sein da diese nur die enstsprechenden
44  * -Shapefunktion integrale berechnet ! Alles andere wäre falsch
45  * -Vermeide doppelte Matrix resizing durch fillEntries bei add und Constructor
46  *
47  * -Deconstructor schreiben
48  * -Add routine muss linearForm bekommen die auf den Space zugreift
49  *
50  * TODO: Const routine umschreibung, todo: documentation
51  */
52 
53 template<class F>
54 class InnerResidual: public OutputOperator { //Function<F> {
55 public:
56 
61  template<class G>
63 
64 
72  template<class G>
73  InnerResidual(const SpaceOnCells<G>& spc,LinearForm<F, G>& lform, const F a = 1);
74 
75 
76  virtual ~InnerResidual() {};
77 
83  inline const concepts::ElementMatrix<F>& operator[](uint quadKey){
85  return hashM_[quadKey];
86  }
87 
88 
94  inline const concepts::ElementMatrix<F>& operator()(uint quadKey) const{
95  typename concepts::HashMap<concepts::ElementMatrix<F> >::const_iterator iter = hashM_.find(quadKey);
96  assert(iter!=hashM_.end());
97  return iter->second;
98  }
99 
105  const F operator()(const hp2D::Quad<F>& quad,const uint locNode) {
106  uint K = quad.support().key();
108  return hashM_[K].getData()[getPos_(locNode,quad.p())];
109  }
110 
111 
117  template<class G>
118  void add(LinearForm<F, G>& lform, const F a = 1);
119 
120 
121 
122  /*Operator gets a Patch an computes right hand side for the
123  * corresponding linear system due to the topology of the
124  * Patch
125  */
126 
127  /* template<class G>
128  Vector<F> operator()(ElementPatch<G> Patch){
129  }*/
130 
131 
132 
133 protected:
134  inline std::ostream& info(std::ostream& os) const {
135  return os << concepts::typeOf(*this) <<"( \n" << hashM_ << "\n )";
136  }
137 
138 
139 
140 
141 private:
142 
143  //TODO: dont make ElementMatrix use Array
145  //local reference to the current space
146  const Space<F>& spc_;
147 
148 
149  //maps from ElementKey to its belonging polynomial degree.
151 
152  //all appearing polynomial degrees in x and y direction
153  //concepts::Sequence<const ushort*> degP_;
154 
155 
156 
157  template<class G>
158  void fillEntries_(LinearForm<F, G>& lform, const F a = 1);
159 
160 
161 
162 // Method is used to read the correct innerResidual due to first order Basisfunctions.
163 // Let N0,N1, E1,...,EP-1 be the Basis functions on [-1,1] ( [0,1] )
164 // Then Innerresidual is computed due to first x then y tensor basis ordering :
165 // Elementmatrix of size 2(p[0]+p[1]) iterative filled with :
166 //
167 // N0_x*N0_y , N1_x * N0_y , E1_x *N0_y,... EP-1_x * N0_y first p[0]+1 entries
168 // increasing y-directed basis:
169 // N0_x*N1_y , N1_x * N1_y , E1_x *N1_y,... EP-1_x * N1_y ...
170 // increasing y-directed basis:
171 // ...
172 //
173 // So the necassary nodal basis functions are
174 // N0_x*N0_y at positon 0
175 // N1_x * N0_y at position 1
176 // N0_x*N1_y at position p[0]+1
177 // N1_x * N1_y at position p[0]+2
178 //
179 // where p[0] is degree of basis functions in x direction
180 //
181 //
182 // i=0..3 is the i-th (local numbered) node of quad, this local numbering is counter clockwise.
183 //
184 // But the polynomials are given first x then y order,
185 // means for first order basis functioN:
186 //
187 // 0 node is 0th basis function
188 // 1 node is 1th basis function
189 // 2 node is 3th basis function
190 // 3 node is 2th basis function
191 //
192 // For higher order including edge functions therefore 0-> 0 , 1 -> 1 , 2->p[0]+1+1 , 3->p[0]+1
193 // For p[0]=1 this coincides with the shown example.
194 
195  //TODO: This will be be used in new class anymore
199  uint getPos_(const uint i, const ushort* p) {
201  uint pos = 0;
202  switch (i) {
203  case (0):
204  return pos = 0;
205  break;
206  case (1):
207  return pos = 1;
208  break;
209  case (2):
210  return pos = p[0] + 2;
211  break;
212  case (3):
213  return pos = p[0] + 1;
214  break;
215  default:
216  return -1;
217  }
218  }
219 
220 };
221 
222 }//namespace
223 #endif
const concepts::ElementMatrix< F > & operator()(uint quadKey) const
Const Read Operator for a requested list of local inner residuals to local basis functions.
Abstract class for a space.
void fillEntries_(LinearForm< F, G > &lform, const F a=1)
#define conceptsAssert(cond, exc)
Assert that a certain condition is fulfilled.
Definition: exceptions.hh:394
InnerResidual(const SpaceOnCells< G > &spc)
Standard constructur builds up the mapping by default of each element of the Space spc.
Abstract class for a linear form.
const Space< F > & spc_
Exception class for assertions.
Definition: exceptions.hh:258
const concepts::ElementMatrix< F > & operator[](uint quadKey)
Read Operator for a requested list of local inner residuals to local basis functions.
const F operator()(const hp2D::Quad< F > &quad, const uint locNode)
Read Operator returning the local inner residual corresponding to the requested first order basis fun...
InnerResidual(const SpaceOnCells< G > &spc, LinearForm< F, G > &lform, const F a=1)
Constructur building the mapping from element key to the local (inner) residuals.
concepts::HashMap< concepts::ElementMatrix< F > > hashM_
concepts::HashMap< const ushort * > degP_
Abstract class for a space.
Definition: space.hh:81
Element matrix.
Definition: linearForm.hh:18
unsigned short ushort
Abbreviation for unsigned short.
Definition: typedefs.hh:48
A 2D FEM element: a quad.
Definition: bf_advection.hh:44
std::ostream & info(std::ostream &os) const
Returns information in an output stream.
uint getPos_(const uint i, const ushort *p)
Method returning position of i-th nodal considered first order basis function's inner residual.
bool exists(uint i) const
Returns true if the entrance exists.
Definition: hashMap.hh:23
std::string typeOf(const T &t)
Return the typeid name of a class object.
Definition: output.hh:43
void add(LinearForm< F, G > &lform, const F a=1)
Add routine to build up the local inner Residuals.
Class providing an output operator.
double Real
Type normally used for a floating point number.
Definition: typedefs.hh:36
Basic namespace for Concepts-2.
Definition: pml_formula.h:16
Page URL: http://wiki.math.ethz.ch/bin/view/Concepts/WebHome
21 August 2020
© 2020 Eidgenössische Technische Hochschule Zürich