00001
00002
00003
00004 #ifndef clusterCebysevK_hh
00005 #define clusterCebysevK_hh
00006
00007 #include "basics/exceptions.hh"
00008 #include "cluster/expansion.hh"
00009 #include "bem/kernel.hh"
00010
00011 namespace cluster {
00012
00013
00014
00017 template <class K>
00018 class CebysevKFTraits {
00019 public:
00020 typedef typename K::F Fkrnl;
00021
00022 static Fkrnl eval(K& k, const concepts::Real3d& x,
00023 const concepts::Real3d& y) {return k(x, y);}
00024 };
00025
00026
00027
00032 template <class K = bem::Laplace, class Fspc = concepts::Real>
00033 class CebysevKF : public ExpansionF<Fspc> {
00034 public:
00035 typedef CebysevKFTraits<K> Traits;
00036 typedef typename Traits::Fkrnl Fkrnl;
00037
00038 private:
00040 uint m_;
00042 concepts::Real eta_;
00044 concepts::Real** cebysev_;
00046 concepts::Real* x_;
00047 concepts::Real* y_;
00048 concepts::Real* z_;
00050 Fkrnl* kernel_;
00052 K& krnl_;
00054 Fkrnl* d_;
00055 Fkrnl* dd_;
00056
00057 inline int index_(int ix, int iy, int iz) const;
00058
00059 public:
00065 CebysevKF(K& krnl, uint m, concepts::Real eta);
00066
00067 virtual ~CebysevKF();
00068
00069 uint blksz(uint m) const {return (m * (m * (m + 3) + 2)) / 6;}
00070 uint m() const {return m_;}
00072 virtual FColF<Fkrnl>* getCol(uint blksz) const {
00073 return new FColF<Fkrnl>(blksz);
00074 }
00075
00077 void fit(uint m, const concepts::Real3d& z, Fkrnl F[]) const;
00079 void ceby2poly(uint m, const concepts::Real3d& z, Fkrnl F[]) const;
00080
00082 inline void evaluate(uint m, const concepts::Real3d& z,
00083 FColExp* Fexp) const;
00084 inline void evaluate(uint m, const concepts::Real3d& z,
00085 FColF<Fkrnl> Fexp[]) const;
00087 inline void apply(uint m, const FColExp* Fexp,
00088 const Fspc src[], Fspc dst[]) const;
00089 void apply(uint m, const FColF<Fkrnl> Fexp[],
00090 const Fspc src[], Fspc dst[]) const;
00091 };
00092
00093 template <class K, class Fspc>
00094 inline int CebysevKF<K, Fspc>::index_(int ix, int iy, int iz) const {
00095 int m = ix + iy + iz;
00096 return (((m+3)*m+2)*m + ((3-ix)*3*ix)) / 6 + m*ix + iy;
00097 }
00098
00099 template <class K, class Fspc>
00100 inline void CebysevKF<K, Fspc>::evaluate(uint m, const concepts::Real3d& z,
00101 FColExp* Fexp) const {
00102 FColF<Fkrnl>* fexp = dynamic_cast<FColF<Fkrnl>*>(Fexp);
00103 if (fexp) {
00104 Fkrnl* F = fexp->value();
00105 fit(m, z, F); ceby2poly(m, z, F);
00106 return;
00107 }
00108
00109 throw
00110 conceptsException(concepts::MissingFeature("FColExp not supported"));
00111 }
00112
00113 template <class K, class Fspc>
00114 inline void CebysevKF<K, Fspc>::evaluate(uint m, const concepts::Real3d& z,
00115 FColF<Fkrnl> Fexp[]) const {
00116 Fkrnl* F = Fexp->value();
00117 fit(m, z, F); ceby2poly(m, z, F);
00118 }
00119
00120 template <class K, class Fspc>
00121 inline void CebysevKF<K, Fspc>::apply(uint m, const FColExp* Fexp,
00122 const Fspc src[], Fspc dst[]) const {
00123 const FColF<Fkrnl>* fexp = dynamic_cast<const FColF<Fkrnl>*>(Fexp);
00124 if (fexp) {apply(m, fexp, src, dst); return;}
00125
00126 throw
00127 conceptsException(concepts::MissingFeature("FColExp not supported"));
00128 }
00129
00130 }
00131
00132 #endif // clusterCebysevK_hh