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 
13 #include "basics/outputOperator.hh"
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 
21 namespace 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 <>
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 <>
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_;
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:
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
uint nchild() const
Maximal number of children.
Definition: element.hh:136
Key key_
Key of the element.
Definition: element.hh:151
An abstract class for an element of a space.
Definition: exceptions.hh:15
Haar3dXXX(const Haar3dXXX< F, d >::Key &key, const concepts::Real *m)
Constructor.
Definition: element.hh:128
M(const concepts::Real *m)
Constructor.
Definition: element.hh:73
Haar3d000< F > * lft_
Left child of the element.
Definition: element.hh:213
uint n() const
returns the matrix dimension
Definition: element.hh:56
int operator<(const Key &key)
Definition: element.hh:117
const M< d > & trafoM() const
Relation between the supports of parent and child.
Definition: element.hh:143
M< d > M_
Transformation matrix of the element.
Definition: element.hh:153
virtual std::ostream & info(std::ostream &os) const
Returns information in an output stream.
Definition: element.hh:65
const BiClNode00< F > * nd_
Node in the cluster tree.
Definition: element.hh:209
virtual ~M()
destructor
Definition: element.hh:39
const bem::Constant3d001< F > * element(uint j) const
Returns the j-th leaf of the wavelet.
Definition: element.hh:219
void mult(const F *src, F *dst) const
Multiplication of src with M.
virtual const bem::Constant3d001< F > * element(uint j) const =0
Element of the wavelet (if leaf)
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
virtual ~Haar3dXXX()
Destructor.
Definition: element.hh:131
Binary node for the cluster and Haar wavelet agglomeration algorithm.
Definition: tree.hh:124
void mult_T(const F *src, F *dst) const
Multiplication of src with M transpose.
Abstract space element for the agglomerated wavelets.
Definition: element.hh:104
Key of the wavelet element.
Definition: element.hh:110
Haar3d000< F > * rght_
Right child of the element.
Definition: element.hh:215
Haar3d000< F > * left() const
Left child of the element.
Definition: element.hh:184
Local transformation matrix.
Definition: element.hh:29
virtual Haar3dXXX< F, d > * child(uint j) const =0
j-th child of the element
Constant space element with a level dependent key.
Definition: element.hh:335
const bem::Constant3d001< F > * elmright() const
Return the right leaf of the wavelet.
Definition: element.hh:231
Binary space element for the agglomerated wavelets.
Definition: element.hh:162
concepts::TIndex< F > T_
Global degree of freedom.
Definition: element.hh:211
concepts::Real * m_
matrix entries
Definition: element.hh:61
An abstract class for a T matrix.
Definition: element.hh:37
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)
Constructor.
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
virtual concepts::Real radius() const =0
Radius of the element.
concepts::Real radius() const
Radius of the element.
Definition: element.hh:201
Key(uint l, uint j)
Definition: element.hh:112
int operator==(const Key &key)
Definition: element.hh:114
const concepts::TMatrixBase< F > & T() const
Global degree of freedom.
Definition: element.hh:189
Used for the aglowav classes for the boundary element method.
Definition: element.hh:21
std::string typeOf(const T &t)
Return the typeid name of a class object.
Definition: output.hh:43
virtual const concepts::Real3d & center() const =0
Center of the element.
Class providing an output operator.
double Real
Type normally used for a floating point number.
Definition: typedefs.hh:36
const concepts::Real3d & center() const
Center of the element.
Definition: element.hh:199
T matrix for linear and regular elements.
Definition: tmatrix.hh:428
Key key() const
Key of the element.
Definition: element.hh:141
Page URL: http://wiki.math.ethz.ch/bin/view/Concepts/WebHome
21 August 2020
© 2020 Eidgenössische Technische Hochschule Zürich