Class documentation of Concepts

Loading...
Searching...
No Matches
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
41
42#include <limits>
43# define EPS std::numeric_limits<double>::epsilon()
44
45namespace hp2D {
46
47template<typename F = concepts::Real>
49 //need of access to underlying Element Info
50 template<class>
51 friend class EquilibratedMomentsAO;
52
53public:
55
56
58
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
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);
116 conceptsAssert(iter!=uelm_.end(),concepts::Assertion());
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
130protected:
131
132 virtual std::ostream& info(std::ostream& os) const;
133
134
135private:
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
146 const concepts::Vector<F>& sol_;
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
164 concepts::Set<uint> dAttrbs_;
165
166};//class
167
168
169
170
171//@pre continuous Space, since of resize init routine, ie.
172
173template<typename F = concepts::Real>
175
176public :
177
179
181 const geometry::VtxToPatchMaps& patchMap,
182 const concepts::InnerResidual<F>& innerRes,
183 const hp2D::ApproxMoments<F>& apprxMoments);
184
185 virtual ~EquilibratedMomentsAO();
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
194protected:
195 virtual std::ostream& info(std::ostream& os) const;
196
197private:
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
208 const concepts::InnerResidual<F>& innerRes_;
209 const hp2D::ApproxMoments<F>& apprxMoments_;
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
221 void solve_(const geometry::VtxToPatchMaps& patchMap, concepts::HashMap<concepts::Vector<Real> >& vec);
222
223 //routine to precompute all needed inverse matrices due to patchsizes and appearing patchtypes
224 void precomputeInverse_(const geometry::VtxToPatchMaps& patchMap, concepts::HashMap<concepts::Vector<Real> >& rhs);
225
226 void computeMoments_(const geometry::VtxToPatchMaps& patchMap,
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
236 void solveInner_(concepts::Vector<Real>& patchRhs);
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
242 void solveNN_(concepts::Vector<Real>& patchRhs);
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
249 void solveDN_(concepts::Vector<Real>& patchRhs);
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.
254 void solveND_(concepts::Vector<Real>& patchRhs);
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_
258 void solveDD_(concepts::Vector<Real>& patchRhs);
259
260 //Precomputes the inner Matrix inv(0.5*( T+ones() ) for requested sizes
261 void precomputeInnerInverse_(const concepts::Set<uint>& dSet);
262
263 //precomputes the NN- Matrix inv(0.5*(T+ones() ) )
264 void precomputeNNInverse_(const concepts::Set<uint>& dSet);
265
266 //precomputes the DN - Matrix inverses inv (0.5*T) since here T is invertable
267 //@ param nr = number of precomputed inverse Matrices
268 void precomputeDNInverse_(const concepts::Set<uint>& dSet);
269
270 //precomputed DD - matrix inverse for some request of demanded patchsizes
271 // computes : (1/2*T_{DD})^{-1}
272 void precomputeDDInverse_(const concepts::Set<uint>& dSet);
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
virtual std::ostream & info(std::ostream &os) const
Returns information in an output stream.
void addDirichlet(uint attrb)
Definition moments.hh:92
void addDirichlet(concepts::Set< uint > &set)
Definition moments.hh:84
void addNeumann(concepts::ParsedFormula< F > &frm, uint attrib)
Definition moments.hh:75
void addNeumann(concepts::ParsedFormula< F > &frm, concepts::Set< uint > &set)
Definition moments.hh:64
virtual std::ostream & info(std::ostream &os) const
Returns information in an output stream.
#define conceptsAssert(cond, exc)