Class documentation of Concepts

Loading...
Searching...
No Matches
element.hh
Go to the documentation of this file.
1
6#ifndef aglowavElement_hh
7#define aglowavElement_hh
8
9#ifdef __GUNG__
10 #pragma interface
11#endif
12
14#include "basics/output.hh"
16#include "geometry/cell2D.hh"
17#include "space/tmatrix.hh"
18#include "space/element.hh"
19#include "aglowav/tree.hh"
20
21namespace aglowav {
22
23 // ********************************************************************* M **
24
28 template <uint d = 2>
29 class M : public concepts::OutputOperator {
30 public:
31 //friend std::ostream& operator<< <>(std::ostream& os, const M<d>& m);
32
37 M(const concepts::Real* m);
39 virtual ~M() {delete[] m_;}
40
46 template<class F>
47 void mult(const F* src, F* dst) const;
53 template<class F>
54 void mult_T(const F* src, F* dst) const;
56 uint n() const {return d;}
57 protected:
58 virtual std::ostream& info(std::ostream& os) const;
59 private:
62 };
63
64 template<uint d>
65 std::ostream& M<d>::info(std::ostream& os) const {
66 os << "aglowav::"<< concepts::typeOf(*this) << "[";
67 for(uint i = 0; i < d-1; i++) os << m_[i] << ", ";
68 if (d) os << m_[d-1];
69 return os << "]";
70 }
71
72 template <uint d>
73 inline M<d>::M(const concepts::Real* m) {
74 m_ = new concepts::Real[d];
75 concepts::Real A = 0;
76 uint i;
77 for(i = 0; i < d; i++) A += m[i];
78 for(i = 0; i < d; i++) m_[i] = sqrt(m[i]/A);
79 }
80
81 template <>
82 template <>
83 inline void M<2>::mult<concepts::Real>(const concepts::Real* src,
84 concepts::Real* dst) const {
85 dst[0] = m_[0]*src[0] - m_[1]*src[1];
86 dst[1] = m_[1]*src[0] + m_[0]*src[1];
87 }
88
89 template <>
90 template <>
91 inline void M<2>::mult_T<concepts::Real>(const concepts::Real* src,
92 concepts::Real* dst) const {
93 dst[0] = m_[0]*src[0] + m_[1]*src[1];
94 dst[1] = -m_[1]*src[0] + m_[0]*src[1];
95 }
96
97 // ************************************************************* Haar3dXXX **
98
103 template <class F = concepts::Real, uint d = 2>
104 class Haar3dXXX : public concepts::Element<F> {
105 public:
110 class Key {
111 public:
112 Key(uint l, uint j) : l_(l), j_(j) {}
113
114 int operator==(const Key& key) {
115 return l_ == key.l() && j_ == key.j();
116 }
117 int operator<(const Key& key) {
118 return l_ < key.l() || (l_ == key.l() && j_ < key.j());
119 }
120 uint l() const {return l_;}
121 uint j() const {return j_;}
122 private:
123 uint l_;
124 uint j_;
125 };
126
129 const concepts::Real* m) : key_(key), M_(m) {}
131 virtual ~Haar3dXXX() {};
132
134 virtual Haar3dXXX<F,d>* child(uint j) const = 0;
136 uint nchild() const {return d;}
137
139 virtual const bem::Constant3d001<F>* element(uint j) const = 0;
141 Key key() const {return key_;}
143 const M<d>& trafoM() const {return M_;}
145 virtual const concepts::Real3d& center() const = 0;
147 virtual concepts::Real radius() const = 0;
148
149 private:
151 Key key_;
153 M<d> M_;
154 };
155
156 // ************************************************************* Haar3d000 **
157
161 template <class F = concepts::Real>
162 class Haar3d000 : public Haar3dXXX<F, 2> {
163 public:
173 const concepts::Real* m, const BiClNode00<F>* nd,
174 uint idx[], Haar3d000<F>* lft = 0, Haar3d000<F>* rght = 0)
175 : Haar3dXXX<F, 2>(key, m), nd_(nd),
176 T_((key.l()==0) ? 2 : 1, (key.l()==0) ? 2 : 1, idx), lft_(lft),
177 rght_(rght) {}
178
180 inline Haar3d000<F>* child(uint j) const {
181 return (!j) ? lft_ : (j == 1) ? rght_ : (Haar3d000<F>*)0;
182 }
184 inline Haar3d000<F>* left() const {return lft_;}
186 inline Haar3d000<F>* right() const {return rght_;}
187
189 inline const concepts::TMatrixBase<F>& T() const {return T_;}
190
192 inline const bem::Constant3d001<F>* element(uint j) const;
194 inline const bem::Constant3d001<F>* elmleft() const;
196 inline const bem::Constant3d001<F>* elmright() const;
197
199 const concepts::Real3d& center() const {return nd_->center();}
201 concepts::Real radius() const {return nd_->radius();}
202
203 protected:
205 std::ostream& info(std::ostream& os) const;
206
207 private:
209 const BiClNode00<F>* nd_;
213 Haar3d000<F>* lft_;
215 Haar3d000<F>* rght_;
216 };
217
218 template<class F>
219 inline const bem::Constant3d001<F>* Haar3d000<F>::element(uint j) const {
220 return (!j && !lft_) ? nd_->child(0)->element() :
221 (j==1 && !rght_) ? nd_->child(1)->element() :
222 (const bem::Constant3d001<F>*)0;
223 }
224
225 template<class F>
227 return (lft_) ? 0 : nd_->child(0)->element();
228 }
229
230 template<class F>
232 return (rght_) ? 0 : nd_->child(1)->element();
233 }
234
235 template<class F>
236 std::ostream& Haar3d000<F>::info(std::ostream& os) const {
237 os << "aglowav::"<< concepts::typeOf(*this) << "(" << *nd_ << ", key = (" << this->key().l();
238 os << ',' << this->key().j() << "), " << T_ << ", ";
239 return os << this->trafoM() << ")";
240 }
241
242} // namespace aglowav
243
244#endif // aglowavElement_hh
concepts::Real radius() const
Radius of the element.
Definition element.hh:201
const bem::Constant3d001< F > * element(uint j) const
Returns the j-th leaf of the wavelet.
Definition element.hh:219
const bem::Constant3d001< F > * elmright() const
Return the right leaf of the wavelet.
Definition element.hh:231
Haar3d000< F > * right() const
Right child of the element.
Definition element.hh:186
std::ostream & info(std::ostream &os) const
Information about the element.
Definition element.hh:236
Haar3d000< F > * left() const
Left child of the element.
Definition element.hh:184
Haar3d000(const typename Haar3dXXX< F, 2 >::Key &key, const concepts::Real *m, const BiClNode00< F > *nd, uint idx[], Haar3d000< F > *lft=0, Haar3d000< F > *rght=0)
Definition element.hh:172
Haar3d000< F > * child(uint j) const
j-th child of the element
Definition element.hh:180
const bem::Constant3d001< F > * elmleft() const
Returns the left leaf of the wavelet.
Definition element.hh:226
const concepts::TMatrixBase< F > & T() const
Global degree of freedom.
Definition element.hh:189
const concepts::Real3d & center() const
Center of the element.
Definition element.hh:199
virtual concepts::Real radius() const =0
Radius of the element.
virtual const bem::Constant3d001< F > * element(uint j) const =0
Element of the wavelet (if leaf)
Haar3dXXX(const Haar3dXXX< F, d >::Key &key, const concepts::Real *m)
Constructor.
Definition element.hh:128
virtual Haar3dXXX< F, d > * child(uint j) const =0
j-th child of the element
virtual ~Haar3dXXX()
Destructor.
Definition element.hh:131
const M< d > & trafoM() const
Relation between the supports of parent and child.
Definition element.hh:143
virtual const concepts::Real3d & center() const =0
Center of the element.
Key key() const
Key of the element.
Definition element.hh:141
uint nchild() const
Maximal number of children.
Definition element.hh:136
uint n() const
returns the matrix dimension
Definition element.hh:56
virtual std::ostream & info(std::ostream &os) const
Returns information in an output stream.
Definition element.hh:65
void mult_T(const F *src, F *dst) const
virtual ~M()
destructor
Definition element.hh:39
void mult(const F *src, F *dst) const
M(const concepts::Real *m)
Definition element.hh:73
std::string typeOf(const T &t)
Definition output.hh:43
double Real
Definition typedefs.hh:39