Go to the documentation of this file.00001
00002
00003
00004 #ifndef aglowavElement_hh
00005 #define aglowavElement_hh
00006
00007 #ifdef __GUNG__
00008 #pragma interface
00009 #endif
00010
00011 #include "basics/outputOperator.hh"
00012 #include "basics/vectorsMatricesForward.hh"
00013 #include "geometry/cell2D.hh"
00014 #include "space/tmatrix.hh"
00015 #include "space/element.hh"
00016 #include "aglowav/tree.hh"
00017
00018 namespace aglowav {
00019
00020
00021
00025 template <uint d = 2>
00026 class M : public concepts::OutputOperator {
00027 public:
00028
00029
00034 M(const concepts::Real* m);
00036 virtual ~M() {delete[] m_;}
00037
00043 template<class F>
00044 void mult(const F* src, F* dst) const;
00050 template<class F>
00051 void mult_T(const F* src, F* dst) const;
00053 uint n() const {return d;}
00054 protected:
00055 virtual std::ostream& info(std::ostream& os) const;
00056 private:
00058 concepts::Real* m_;
00059 };
00060
00061 template<uint d>
00062 std::ostream& M<d>::info(std::ostream& os) const {
00063 os << "aglowav::M<" << d << ">=[";
00064 for(uint i = 0; i < d-1; i++) os << m_[i] << ", ";
00065 if (d) os << m_[d-1];
00066 return os << "]";
00067 }
00068
00069 template <uint d>
00070 inline M<d>::M(const concepts::Real* m) {
00071 m_ = new concepts::Real[d];
00072 concepts::Real A = 0;
00073 uint i;
00074 for(i = 0; i < d; i++) A += m[i];
00075 for(i = 0; i < d; i++) m_[i] = sqrt(m[i]/A);
00076 }
00077
00078 template <>
00079 template <>
00080 inline void M<2>::mult<concepts::Real>(const concepts::Real* src,
00081 concepts::Real* dst) const {
00082 dst[0] = m_[0]*src[0] - m_[1]*src[1];
00083 dst[1] = m_[1]*src[0] + m_[0]*src[1];
00084 }
00085
00086 template <>
00087 template <>
00088 inline void M<2>::mult_T<concepts::Real>(const concepts::Real* src,
00089 concepts::Real* dst) const {
00090 dst[0] = m_[0]*src[0] + m_[1]*src[1];
00091 dst[1] = -m_[1]*src[0] + m_[0]*src[1];
00092 }
00093
00094
00095
00100 template <class F = concepts::Real, uint d = 2>
00101 class Haar3dXXX : public concepts::Element<F> {
00102 public:
00107 class Key {
00108 public:
00109 Key(uint l, uint j) : l_(l), j_(j) {}
00110
00111 int operator==(const Key& key) {
00112 return l_ == key.l() && j_ == key.j();
00113 }
00114 int operator<(const Key& key) {
00115 return l_ < key.l() || (l_ == key.l() && j_ < key.j());
00116 }
00117 uint l() const {return l_;}
00118 uint j() const {return j_;}
00119 private:
00120 uint l_;
00121 uint j_;
00122 };
00123
00125 Haar3dXXX(const Haar3dXXX<F, d>::Key& key,
00126 const concepts::Real* m) : key_(key), M_(m) {}
00128 virtual ~Haar3dXXX() {};
00129
00131 virtual Haar3dXXX<F,d>* child(uint j) const = 0;
00133 uint nchild() const {return d;}
00134
00136 virtual const bem::Constant3d001<F>* element(uint j) const = 0;
00138 Key key() const {return key_;}
00140 const M<d>& trafoM() const {return M_;}
00142 virtual const concepts::Real3d& center() const = 0;
00144 virtual concepts::Real radius() const = 0;
00145
00146 private:
00148 Key key_;
00150 M<d> M_;
00151 };
00152
00153
00154
00158 template <class F = concepts::Real>
00159 class Haar3d000 : public Haar3dXXX<F, 2> {
00160 public:
00169 Haar3d000(const typename Haar3dXXX<F, 2>::Key& key,
00170 const concepts::Real* m, const BiClNode00<F>* nd,
00171 uint idx[], Haar3d000<F>* lft = 0, Haar3d000<F>* rght = 0)
00172 : Haar3dXXX<F, 2>(key, m), nd_(nd),
00173 T_((key.l()==0) ? 2 : 1, (key.l()==0) ? 2 : 1, idx), lft_(lft),
00174 rght_(rght) {}
00175
00177 inline Haar3d000<F>* child(uint j) const {
00178 return (!j) ? lft_ : (j == 1) ? rght_ : (Haar3d000<F>*)0;
00179 }
00181 inline Haar3d000<F>* left() const {return lft_;}
00183 inline Haar3d000<F>* right() const {return rght_;}
00184
00186 inline const concepts::TMatrixBase<F>& T() const {return T_;}
00187
00189 inline const bem::Constant3d001<F>* element(uint j) const;
00191 inline const bem::Constant3d001<F>* elmleft() const;
00193 inline const bem::Constant3d001<F>* elmright() const;
00194
00196 const concepts::Real3d& center() const {return nd_->center();}
00198 concepts::Real radius() const {return nd_->radius();}
00199
00200 protected:
00202 std::ostream& info(std::ostream& os) const;
00203
00204 private:
00206 const BiClNode00<F>* nd_;
00208 concepts::TIndex<F> T_;
00210 Haar3d000<F>* lft_;
00212 Haar3d000<F>* rght_;
00213 };
00214
00215 template<class F>
00216 inline const bem::Constant3d001<F>* Haar3d000<F>::element(uint j) const {
00217 return (!j && !lft_) ? nd_->child(0)->element() :
00218 (j==1 && !rght_) ? nd_->child(1)->element() :
00219 (const bem::Constant3d001<F>*)0;
00220 }
00221
00222 template<class F>
00223 inline const bem::Constant3d001<F>* Haar3d000<F>::elmleft() const {
00224 return (lft_) ? 0 : nd_->child(0)->element();
00225 }
00226
00227 template<class F>
00228 inline const bem::Constant3d001<F>* Haar3d000<F>::elmright() const {
00229 return (rght_) ? 0 : nd_->child(1)->element();
00230 }
00231
00232 template<class F>
00233 std::ostream& Haar3d000<F>::info(std::ostream& os) const {
00234 os << "aglowav::Haar3d000(" << *nd_ << ", key = (" << this->key().l();
00235 os << ',' << this->key().j() << "), " << T_ << ", ";
00236 return os << this->trafoM() << ")";
00237 }
00238
00239 }
00240
00241 #endif // aglowavElement_hh