kernel.hh

Go to the documentation of this file.
1 
6 #ifndef bemKernel_hh
7 #define bemKernel_hh
8 
10 
11 #include <cmath>
12 #ifndef M_1_PI
13 # define M_1_PI 0.31830988618379067154 /* 1/pi */
14 #endif
15 
16 namespace bem {
17 
18 #define KrnlEPS 1e-10
19 
20  // ****************************************************************** Cnst **
21 
24  class Cnst {
25  friend std::ostream& operator<<(std::ostream& os, const Cnst& c);
27 
28  public:
29  typedef concepts::Real F;
30 
31  Cnst(concepts::Real c) : c_(c) {}
32 
34  { return c_; }
35  };
36 
37  // ****************************************************************** Poly **
38 
41  class Poly {
42  friend std::ostream& operator<<(std::ostream& os, const Poly& p);
43  bool var_;
44  uint idx_;
45  uint exp_;
46 
47  public:
48  typedef concepts::Real F;
49 
50  Poly(bool var, uint idx, uint e)
51  : var_(var), idx_((idx > 2 ? 2 : idx)), exp_(e) {}
52 
54  const concepts::Real3d& y) {
55  concepts::Real vari = var_ ? y[idx_] : x[idx_];
56  concepts::Real krnl = 1.0;
57  for(uint i = 0; i < exp_; i++) krnl *= vari;
58  return krnl;
59  }
60  };
61 
62  // ***************************************************************** ExpR2 **
63 
66  class ExpR2 {
67  friend std::ostream& operator<<(std::ostream& os, const ExpR2& e);
69 
70  public:
71  typedef concepts::Real F;
72 
73  ExpR2(concepts::MapReal3d& gamma) : gamma_(gamma) {}
74 
76  const concepts::Real3d& y) {
77  concepts::Real3d r(x-y);
78  concepts::Real e = r * (gamma_ * r);
79 
80  return std::exp(-e);
81  }
82  };
83 
84  // ****************************************************************** ExpR **
85 
88  class ExpR {
89  friend std::ostream& operator<<(std::ostream& os, const ExpR& e);
90 
92 
93  public:
94  typedef concepts::Real F;
95  ExpR(concepts::Real gamma) : gamma_(gamma) {}
96 
98  const concepts::Real3d& y) {
99  concepts::Real r = (x - y).l2();
100  return std::exp(-gamma_ * r);
101  }
102  };
103 
104  // **************************************************************** Inv1Rn **
105 
108  class Inv1Rn {
109  friend std::ostream& operator<<(std::ostream& os, const Inv1Rn& krnl);
111  uint n_;
112 
113  public:
114  typedef concepts::Real F;
115 
116  Inv1Rn(concepts::Real gamma, uint n) : gamma_(gamma), n_(n) {}
117 
119  const concepts::Real3d& y) {
120  concepts::Real r = (x - y).l2();
121  return (r < KrnlEPS) ? 1.0
122  : 1.0 / (1.0 + gamma_*std::exp(n_ * std::log(r)));
123  }
124  };
125 
126  // *************************************************************** Laplace **
127 
130  class Laplace {
131  friend std::ostream& operator<<(std::ostream& os, const Laplace& lpl);
133 
134  public:
135  typedef concepts::Real F;
136 
137  Laplace() : sc_(0.25 * M_1_PI) {}
138 
140  const concepts::Real3d& y) {
141  concepts::Real r = (x - y).l2();
142  return sc_ / r;
143  }
144  };
145 
146 } // namespace bem
147 
148 #endif // bemKernel_hh
uint idx_
Definition: kernel.hh:44
friend std::ostream & operator<<(std::ostream &os, const Poly &p)
Cnst(concepts::Real c)
Definition: kernel.hh:31
concepts::Real F
Definition: kernel.hh:29
concepts::Real operator()(const concepts::Real3d &, const concepts::Real3d &)
Definition: kernel.hh:33
Inv1Rn(concepts::Real gamma, uint n)
Definition: kernel.hh:116
friend std::ostream & operator<<(std::ostream &os, const Laplace &lpl)
friend std::ostream & operator<<(std::ostream &os, const Inv1Rn &krnl)
concepts::Real F
Definition: kernel.hh:71
ExpR2(concepts::MapReal3d &gamma)
Definition: kernel.hh:73
Poly(bool var, uint idx, uint e)
Definition: kernel.hh:50
concepts::MapReal3d gamma_
Definition: kernel.hh:68
#define M_1_PI
Definition: kernel.hh:13
Polynomial in one variable (used only to test quadrature schemes)
Definition: kernel.hh:41
friend std::ostream & operator<<(std::ostream &os, const Cnst &c)
#define KrnlEPS
Definition: kernel.hh:18
friend std::ostream & operator<<(std::ostream &os, const ExpR &e)
concepts::Real c_
Definition: kernel.hh:26
uint exp_
Definition: kernel.hh:45
concepts::Real operator()(const concepts::Real3d &x, const concepts::Real3d &y)
Definition: kernel.hh:118
concepts::Real F
Definition: kernel.hh:94
ExpR(concepts::Real gamma)
Definition: kernel.hh:95
Constant kernel function (used only to test quadrature schemes)
Definition: kernel.hh:24
concepts::Real F
Definition: kernel.hh:135
concepts::Real operator()(const concepts::Real3d &x, const concepts::Real3d &y)
Definition: kernel.hh:53
Used for the basic classes of the boundary element method.
Definition: bform.hh:13
const concepts::Real sc_
Definition: kernel.hh:132
bool var_
Definition: kernel.hh:43
concepts::Real F
Definition: kernel.hh:114
concepts::Real F
Definition: kernel.hh:48
concepts::Real operator()(const concepts::Real3d &x, const concepts::Real3d &y)
Definition: kernel.hh:97
friend std::ostream & operator<<(std::ostream &os, const ExpR2 &e)
uint n_
Definition: kernel.hh:111
concepts::Real operator()(const concepts::Real3d &x, const concepts::Real3d &y)
Definition: kernel.hh:75
concepts::Real gamma_
Definition: kernel.hh:91
concepts::Real gamma_
Definition: kernel.hh:110
double Real
Type normally used for a floating point number.
Definition: typedefs.hh:36
concepts::Real operator()(const concepts::Real3d &x, const concepts::Real3d &y)
Definition: kernel.hh:139
Page URL: http://wiki.math.ethz.ch/bin/view/Concepts/WebHome
21 August 2020
© 2020 Eidgenössische Technische Hochschule Zürich