cebysevK.hh

Go to the documentation of this file.
1 
6 #ifndef clusterCebysevK_hh
7 #define clusterCebysevK_hh
8 
9 #include "basics/exceptions.hh"
10 #include "cluster/expansion.hh"
11 #include "bem/kernel.hh"
12 
13 namespace cluster {
14 
15  // ******************************************************* CebysevKFTraits **
16 
19  template <class K>
21  public:
22  typedef typename K::F Fkrnl;
23 
24  static Fkrnl eval(K& k, const concepts::Real3d& x,
25  const concepts::Real3d& y) {return k(x, y);}
26  };
27 
28  // ************************************************************* CebysevKF **
29 
34  template <class K = bem::Laplace, class Fspc = concepts::Real>
35  class CebysevKF : public ExpansionF<Fspc> {
36  public:
38  typedef typename Traits::Fkrnl Fkrnl;
39 
40  private:
42  uint m_;
54  K& krnl_;
58 
59  inline int index_(int ix, int iy, int iz) const;
60 
61  public:
67  CebysevKF(K& krnl, uint m, concepts::Real eta);
68 
69  virtual ~CebysevKF();
70 
71  uint blksz(uint m) const {return (m * (m * (m + 3) + 2)) / 6;}
72  uint m() const {return m_;}
74  virtual FColF<Fkrnl>* getCol(uint blksz) const {
75  return new FColF<Fkrnl>(blksz);
76  }
77 
79  void fit(uint m, const concepts::Real3d& z, Fkrnl F[]) const;
81  void ceby2poly(uint m, const concepts::Real3d& z, Fkrnl F[]) const;
82 
84  inline void evaluate(uint m, const concepts::Real3d& z,
85  FColExp* Fexp) const;
86  inline void evaluate(uint m, const concepts::Real3d& z,
87  FColF<Fkrnl> Fexp[]) const;
89  inline void apply(uint m, const FColExp* Fexp,
90  const Fspc src[], Fspc dst[]) const;
91  void apply(uint m, const FColF<Fkrnl> Fexp[],
92  const Fspc src[], Fspc dst[]) const;
93  };
94 
95  template <class K, class Fspc>
96  inline int CebysevKF<K, Fspc>::index_(int ix, int iy, int iz) const {
97  int m = ix + iy + iz;
98  return (((m+3)*m+2)*m + ((3-ix)*3*ix)) / 6 + m*ix + iy;
99  }
100 
101  template <class K, class Fspc>
102  inline void CebysevKF<K, Fspc>::evaluate(uint m, const concepts::Real3d& z,
103  FColExp* Fexp) const {
104  FColF<Fkrnl>* fexp = dynamic_cast<FColF<Fkrnl>*>(Fexp);
105  if (fexp) {
106  Fkrnl* F = fexp->value();
107  fit(m, z, F); ceby2poly(m, z, F);
108  return;
109  }
110 
111  throw
112  conceptsException(concepts::MissingFeature("FColExp not supported"));
113  }
114 
115  template <class K, class Fspc>
116  inline void CebysevKF<K, Fspc>::evaluate(uint m, const concepts::Real3d& z,
117  FColF<Fkrnl> Fexp[]) const {
118  Fkrnl* F = Fexp->value();
119  fit(m, z, F); ceby2poly(m, z, F);
120  }
121 
122  template <class K, class Fspc>
123  inline void CebysevKF<K, Fspc>::apply(uint m, const FColExp* Fexp,
124  const Fspc src[], Fspc dst[]) const {
125  const FColF<Fkrnl>* fexp = dynamic_cast<const FColF<Fkrnl>*>(Fexp);
126  if (fexp) {apply(m, fexp, src, dst); return;}
127 
128  throw
129  conceptsException(concepts::MissingFeature("FColExp not supported"));
130  }
131 
132 } // namespace cluster
133 
134 #endif // clusterCebysevK_hh
Class to hold expansion coefficients of type F.
Definition: expansion.hh:156
void ceby2poly(uint m, const concepts::Real3d &z, Fkrnl F[]) const
Conversion from Cebysev to monomial basis of interpolation polynom.
F * value() const
Definition: expansion.hh:161
#define conceptsException(exc)
Prepares an exception for throwing.
Definition: exceptions.hh:344
uint blksz(uint m) const
Size of memory used for the expansion.
Definition: cebysevK.hh:71
uint m() const
Definition: cebysevK.hh:72
int index_(int ix, int iy, int iz) const
Definition: cebysevK.hh:96
CebysevKFTraits< K > Traits
Definition: cebysevK.hh:37
concepts::Real ** cebysev_
Values of the Cebysev polynomials.
Definition: cebysevK.hh:46
Fkrnl * d_
Auxiliary vectors.
Definition: cebysevK.hh:56
concepts::Real * z_
Definition: cebysevK.hh:50
part of the Cebysev expansion for arbitrary kernels.
Definition: cebysevK.hh:35
virtual FColF< Fkrnl > * getCol(uint blksz) const
Allocates memory for the expansion coefficients.
Definition: cebysevK.hh:74
concepts::Real * y_
Definition: cebysevK.hh:49
Fkrnl * kernel_
values of the kernel function
Definition: cebysevK.hh:52
Traits::Fkrnl Fkrnl
Definition: cebysevK.hh:38
void apply(uint m, const FColF< Fkrnl > Fexp[], const Fspc src[], Fspc dst[]) const
concepts::Real * x_
Interpolation points.
Definition: cebysevK.hh:48
CebysevKF(K &krnl, uint m, concepts::Real eta)
Constructor.
void evaluate(uint m, const concepts::Real3d &z, FColExp *Fexp) const
Definition: cebysevK.hh:102
virtual ~CebysevKF()
Used for the cluster classes for the boundary element method.
Definition: cebysev.hh:13
Abstract class for the part of a kernel expansion.
Definition: expansion.hh:185
Exception class to express a missing feature.
Definition: exceptions.hh:206
void apply(uint m, const FColExp *Fexp, const Fspc src[], Fspc dst[]) const
Definition: cebysevK.hh:123
K & krnl_
Kernel function.
Definition: cebysevK.hh:54
Interface for the kernel function used by CebysevKF.
Definition: cebysevK.hh:20
void fit(uint m, const concepts::Real3d &z, Fkrnl F[]) const
Interpolation.
void apply(Operator< F > &op, const Matrix< H > &mX, Matrix< I > &mY)
Multiplication with a matrix.
Definition: matrix.hh:256
concepts::Real eta_
Interpolation coefficient.
Definition: cebysevK.hh:44
static Fkrnl eval(K &k, const concepts::Real3d &x, const concepts::Real3d &y)
Definition: cebysevK.hh:24
uint m_
Expansion order.
Definition: cebysevK.hh:42
double Real
Type normally used for a floating point number.
Definition: typedefs.hh:36
Abstract class to hold the expansion coefficients.
Definition: expansion.hh:143
Page URL: http://wiki.math.ethz.ch/bin/view/Concepts/WebHome
21 August 2020
© 2020 Eidgenössische Technische Hochschule Zürich