moments.hh

Go to the documentation of this file.
1 
12 // TODO Some more documentation what this class is about, <emph>i.e.</emph> <grad_n u_h> as Mean value or for neumannboundary etc
13 
14 #ifndef moments_A0_hh
15 #define moments_A0_hh
16 
17 #include "geometry.hh"
18 #include "basics/typedefs.hh"
19 
20 #include "hp2D/space.hh"
21 
22 #include "patches.hh"
23 //#include "linInnerProd.hh"
24 #include "innerResidual.hh"
25 
26 //needed spaces
28 #include "hp1D.hh"
29 
30 #include "operator.hh"
31 
32 #include "toolbox/hashMap.hh"
33 #include "formula/exceptions.hh"
34 #include "basics/exceptions.hh"
35 
36 #include "geometry/cell.hh"
37 #include "space/element.hh"
38 #include "space/formula.hh"
39 
40 #include "formula/parsedFormula.hh"
41 
42 #include <limits>
43 # define EPS std::numeric_limits<double>::epsilon()
44 
45 namespace hp2D {
46 
47 template<typename F = concepts::Real>
49  //need of access to underlying Element Info
50  template<class>
51  friend class EquilibratedMomentsAO;
52 
53 public:
55 
56 
58 
65  concepts::Set<uint>& set) {
66  frms_.push_back(frm);
67  nAttrbs_.push_back(set);
68  }
69 
75  void addNeumann(concepts::ParsedFormula<F>& frm, uint attrib) {
76  frms_.push_back(frm);
77  nAttrbs_.push_back(concepts::Set<uint>(attrib));
78  }
79 
85  dAttrbs_ = dAttrbs_||set;
86  }
87 
92  void addDirichlet(uint attrb) {
93  dAttrbs_.insert(attrb);
94  }
95 
96 
101  void addComplete();
102 
103 
104  //Access routine to write and read moments.
105  const concepts::ElementMatrix<F>& operator()(uint edgeKey) const {
106  typename concepts::HashMap<concepts::ElementMatrix<F> >::const_iterator iter = hashM_.find(edgeKey);
107  conceptsAssert(iter!= hashM_.end(),concepts::Assertion());
108  return iter->second;
109  }
110 
111  //@pre the edgeKey exists in the underlying list
112  //@pre the InputQuad is a underlying quad of Edge edgekey
113  //sets a weight if input Quad is first underlying quad of edge E to w = 1 if it is the second w = -1, else
114  Real getWeight(uint quadKey,uint edgeKey) const{
115  typename concepts::HashMap<concepts::Sequence<UnderlyingElement> >::const_iterator iter = uelm_.find(edgeKey);
117  if (iter->second[0].elm->support().key().key()==quadKey)
118  return 1.0;
119  return -1.0;
120 
121 // conceptsAssert(hashM_.exists(edgeKey),concepts::Assertion());
122 // //the first (or only) uelm is the inputquad
123 // if(uelm_[edgeKey][0].elm->support().key().key()==quadKey)
124 // return 1.0;
125 // //the second due to pre have to be the InputQuad
126 // return -1.0;
127 
128  }
129 
130 protected:
131 
132  virtual std::ostream& info(std::ostream& os) const;
133 
134 
135 private:
136 
137 
138 
139  //local reference of the space on which the moments depend
141 
142  //map representing the moments via hashM[E] = mean(moments) on Edge E corresponding to the first underlying Element (e.g. Quad) K
144 
145 
147 
148  //HashMap from Edge Key to its underlying elements
149  // as info is given in TraceSpace and NeumannTracespaces, its just pointed here to it
150  //this info might be the same in the Patch map ittself
152 
153 
154  void computeID_();
155  void computeN_();
156 
157  //ushort m_;
158 
159  //Neumann formulas
161  //Neumann Attributes
163  //Dirichlet Attributes
165 
166 };//class
167 
168 
169 
170 
171 //@pre continuous Space, since of resize init routine, ie.
172 
173 template<typename F = concepts::Real>
175 
176 public :
177 
179 
181  const geometry::VtxToPatchMaps& patchMap,
182  const concepts::InnerResidual<F>& innerRes,
183  const hp2D::ApproxMoments<F>& apprxMoments);
184 
186 
187  const concepts::Vector<F>& operator()(uint edgeKey) const {
188  typename concepts::HashMap<concepts::Vector<F> >::const_iterator iter = hashM_.find(edgeKey);
189  conceptsAssert(iter!= hashM_.end(),concepts::Assertion());
190  return iter->second;
191  }
192 
193 
194 protected:
195  virtual std::ostream& info(std::ostream& os) const;
196 
197 private:
198 
199  //local reference of the space on which the moments depend
201 
202  //map representing the moments via hashM[E] = moments on Edge E corresponding to first UnderlyingElement (e.g. Quad) K
203  //to get moments for the second underlying element K', moments just have to be multiplicated with (-1)
205 
206 
207 
210 
211  void initMoments_(const geometry::VtxToPatchMaps& patchMap);
212 
213  //add routine for higher Moments, @pre Edge E is the k-th Edge of Quad K with Quad->p()={px,py}, and K is the first uelm of E.
214  void addHigherMoments_(const uint K, const uint E, const uint k,const uint px, const uint py);
215 
216  void buildRhs_(const geometry::VtxToPatchMaps& patchMap,
218 
219  //Routine that solves the first order considered Patchproblems
220  //vec respresenting the right hand sides as input and representing the solutions as output
222 
223  //routine to precompute all needed inverse matrices due to patchsizes and appearing patchtypes
225 
227  const concepts::InnerResidual<F>& innerRes,
228  const hp2D::ApproxMoments<F>& apprxMoments,
230 
231  //Method to solve a inner Patch problem with
232  //@ param patchsize size of the Patch
233  //@ param patchRhs given Rhs of the Patch computed with InnerResidual and apprxMoments
234  // the patchRhs holds the Solution later, coz of reference the rhs can not be used anymore, indeed this
235  // is no necessary anyway in the algorithm
237 
238  //solves inner Patch problem for given Patchsize and given rhs
239  // uses precomputed T+D, since T is singular the rhs gets corrected
240  // @ param N size of the patch
241  // @ param patchRhs right handed side of the Patchproblem
243 
244 
245  //solves a Dirichlet_Neumann patch problem for given patchsize and given rhs
246  // uses precomputed inverse of T , since T is regular on those problems
247  // @ param N size of the patch
248  // @ param patchRhs right handed side of the Patchproblem
250 
251 
252  //solves a Neumann-Dirichlet patch problem for given patchsize and given rhs
253  // uses precomputed inverse of the T_{DN} matrices due to symmetrie to the DN problem.
255 
256  //solves a local Dirichlet-Dirichlet patch problem for given patchsize and given rhs-
257  // uses precomputed inverses of the T_{DD} matrices in ddInvM_
259 
260  //Precomputes the inner Matrix inv(0.5*( T+ones() ) for requested sizes
262 
263  //precomputes the NN- Matrix inv(0.5*(T+ones() ) )
265 
266  //precomputes the DN - Matrix inverses inv (0.5*T) since here T is invertable
267  //@ param nr = number of precomputed inverse Matrices
269 
270  //precomputed DD - matrix inverse for some request of demanded patchsizes
271  // computes : (1/2*T_{DD})^{-1}
273 
274  //InnerPatch Circulant Matrix inverses :
276 
277  //Neumann_Neumann Patch Inverse Matrix (T+D)^(-1) computed up to ..
279 
280  //Dirichlet_Neumann Patch Inverse Matrix T^(-1) computed up to wanted number
282 
283  //Dirichlet_Dirichlecht Patch Inverse Matrix T^(-1) computed up to given dim
285 
286  //local reference to the underlying Elements information in the approximated Moments
288 
289 };
290 
291 
292 
293 
294 } //namespace
295 
296 #endif // moments_A0_hh
concepts::HashMap< concepts::DenseMatrix< Real > > ddInvM_
Definition: moments.hh:284
const concepts::Vector< F > & sol_
Definition: moments.hh:146
Real getWeight(uint quadKey, uint edgeKey) const
Definition: moments.hh:114
void addDirichlet(uint attrb)
Add homogeneous dirichlet data since integration rountines later need that information.
Definition: moments.hh:92
void solveNN_(concepts::Vector< Real > &patchRhs)
concepts::HashMap< concepts::ElementMatrix< F > > hashM_
Definition: moments.hh:143
concepts::HashMap< concepts::Array< Real > > innerCircM_
Definition: moments.hh:275
void solve_(const geometry::VtxToPatchMaps &patchMap, concepts::HashMap< concepts::Vector< Real > > &vec)
concepts::HashMap< concepts::Vector< F > > hashM_
Definition: moments.hh:204
void addNeumann(concepts::ParsedFormula< F > &frm, uint attrib)
Add Neumann data since integration rountines later need that information.
Definition: moments.hh:75
void buildRhs_(const geometry::VtxToPatchMaps &patchMap, const concepts::InnerResidual< F > &innerRes, const hp2D::ApproxMoments< F > &apprxMoments, concepts::HashMap< concepts::Vector< Real > > &rhs)
const concepts::SpaceOnCells< Real > & spc_
Definition: moments.hh:200
void addComplete()
Heart of this class.
#define conceptsAssert(cond, exc)
Assert that a certain condition is fulfilled.
Definition: exceptions.hh:394
void addNeumann(concepts::ParsedFormula< F > &frm, concepts::Set< uint > &set)
Add Neumann data since integration rountines later need that information.
Definition: moments.hh:64
concepts::Sequence< concepts::Set< uint > > nAttrbs_
Definition: moments.hh:162
void initMoments_(const geometry::VtxToPatchMaps &patchMap)
2D hp-FEM for H1-conforming elements.
void solveDD_(concepts::Vector< Real > &patchRhs)
concepts::HashMap< concepts::DenseMatrix< Real > > nnInvM_
Definition: moments.hh:278
ApproxMoments(const concepts::SpaceOnCells< F > &spc, const concepts::Vector< F > &sol)
void precomputeDNInverse_(const concepts::Set< uint > &dSet)
void solveInner_(concepts::Vector< Real > &patchRhs)
EquilibratedMomentsAO(const concepts::SpaceOnCells< F > &spc, const geometry::VtxToPatchMaps &patchMap, const concepts::InnerResidual< F > &innerRes, const hp2D::ApproxMoments< F > &apprxMoments)
concepts::HashMap< concepts::DenseMatrix< Real > > dnInvM_
Definition: moments.hh:281
Exception class for assertions.
Definition: exceptions.hh:258
void precomputeDDInverse_(const concepts::Set< uint > &dSet)
concepts::HashMap< concepts::Sequence< UnderlyingElement > > uelm_
Definition: moments.hh:151
concepts::Sequence< concepts::ParsedFormula< F > > frms_
Definition: moments.hh:160
void solveDN_(concepts::Vector< Real > &patchRhs)
concepts::Set< uint > dAttrbs_
Definition: moments.hh:164
const hp2D::ApproxMoments< F > & apprxMoments_
Definition: moments.hh:209
virtual std::ostream & info(std::ostream &os) const
Returns information in an output stream.
const concepts::SpaceOnCells< Real > & spc_
Definition: moments.hh:140
concepts::ElementAndFacette< hp2D::Element< F > > UnderlyingElement
Definition: moments.hh:178
Sequence with operations, output operator, and method of the particular element types.
Definition: sequence.hh:39
virtual std::ostream & info(std::ostream &os) const
Returns information in an output stream.
const concepts::InnerResidual< F > & innerRes_
Definition: moments.hh:208
void precomputeNNInverse_(const concepts::Set< uint > &dSet)
void precomputeInnerInverse_(const concepts::Set< uint > &dSet)
concepts::ElementAndFacette< hp2D::Element< F > > UnderlyingElement
Definition: moments.hh:54
Abstract class for a space.
Definition: space.hh:81
Element matrix.
Definition: linearForm.hh:18
void precomputeInverse_(const geometry::VtxToPatchMaps &patchMap, concepts::HashMap< concepts::Vector< Real > > &rhs)
void addHigherMoments_(const uint K, const uint E, const uint k, const uint px, const uint py)
Class to build up maps form Vertexkeys to EdgePatches or ElementPatches.
Definition: patches.hh:486
void addDirichlet(concepts::Set< uint > &set)
Add homogeneous dirichlet data since integration rountines later need that information.
Definition: moments.hh:84
const concepts::ElementMatrix< F > & operator()(uint edgeKey) const
Definition: moments.hh:105
const concepts::Vector< F > & operator()(uint edgeKey) const
Definition: moments.hh:187
const concepts::HashMap< concepts::Sequence< UnderlyingElement > > & uelm_
Definition: moments.hh:287
void computeMoments_(const geometry::VtxToPatchMaps &patchMap, const concepts::InnerResidual< F > &innerRes, const hp2D::ApproxMoments< F > &apprxMoments, concepts::HashMap< concepts::Vector< Real > > &sigma)
Class providing an output operator.
Container for an element and one facette (edge or face).
Definition: element.hh:113
double Real
Type normally used for a floating point number.
Definition: typedefs.hh:36
void solveND_(concepts::Vector< Real > &patchRhs)
Page URL: http://wiki.math.ethz.ch/bin/view/Concepts/WebHome
21 August 2020
© 2020 Eidgenössische Technische Hochschule Zürich