25 #ifndef HELMHOLTZ_KERNEL_HPP_INCLUDED
26 #define HELMHOLTZ_KERNEL_HPP_INCLUDED
28 #include <boost/math/constants/constants.hpp>
32 #include "../core/global_definitions.hpp"
33 #include "../core/gaussian_quadrature.hpp"
34 #include "../util/math_functions.hpp"
37 #include "wave_number_kernel.hpp"
43 template <
class Space,
class WaveNumber>
47 namespace distance_dependent_kernel_traits_ns
49 template <
class Space,
class WaveNumber>
52 template <
class Space,
class WaveNumber>
55 typedef std::complex<typename Space::scalar_t> type;
58 template <
class Space,
class WaveNumber>
62 template <
class Space,
class WaveNumber>
65 template <
class Space,
class WaveNumber>
70 template <
class Space,
class WaveNumber>
72 : std::integral_constant<unsigned, 7> {};
74 template <
class Scalar,
class WaveNumber>
78 template <
class Scalar,
class WaveNumber>
82 template <
class Scalar,
class WaveNumber>
86 template <
class Scalar,
class WaveNumber>
92 template <
class scalar,
class WaveNumber>
103 void eval_impl(std::integral_constant<unsigned, 0>,
scalar r, result_t *f)
const
105 auto z = this->get_wave_number() * r;
106 auto H0 = bessel::H<0, 2>(std::complex<scalar>(z));
107 *f = std::complex<scalar>(0, -.25) * H0;
110 void eval_impl(std::integral_constant<unsigned, 1>,
scalar r, result_t *f)
const
112 auto const &k = this->get_wave_number();
114 auto H1 = bessel::H<1, 2>(std::complex<scalar>(z));
115 *f = std::complex<scalar>(0, .25) * this->get_wave_number() * H1;
118 void eval_impl(std::integral_constant<unsigned, 2>,
scalar r, result_t *f)
const
120 auto const &k = this->get_wave_number();
122 auto H0 = bessel::H<0, 2>(std::complex<scalar>(z));
123 auto H1 = bessel::H<1, 2>(std::complex<scalar>(z));
124 auto H2 = bessel::H<2, 2>(std::complex<scalar>(z));
125 f[1] = std::complex<scalar>(0, .25) * k*k * (H1/z);
126 f[0] = std::complex<scalar>(0, -.25) * k*k * (.5 * H2 - .5 * H0 + H1/z);
129 void eval_impl(std::integral_constant<unsigned, 3>,
scalar r, result_t *f)
const
131 f[0] = f[1] = result_t(0);
140 template <
unsigned order>
141 void eval(
scalar r, std::complex<scalar> *f)
const
143 eval_impl(std::integral_constant<unsigned, order>(), r, f);
148 template <
class scalar,
class WaveNumber>
159 void eval_impl(std::integral_constant<unsigned, 0>,
scalar r, result_t *f)
const
161 using namespace boost::math::double_constants;
162 auto kr = this->get_wave_number() * r;
163 auto ikr = result_t(0,1) * kr;
164 f[0] = std::exp(-ikr) / r / (4. * pi);
168 void eval_impl(std::integral_constant<unsigned, 1>,
scalar r, result_t *f)
const
170 using boost::math::double_constants::pi;
171 auto kr = this->get_wave_number() * r;
172 auto ikr = result_t(0,1) * kr;
173 f[0] = std::exp(-ikr) / (r*r) / (4. * pi) * (-ikr - 1.);
177 void eval_impl(std::integral_constant<unsigned, 2>,
scalar r, result_t *f)
const
179 using boost::math::double_constants::pi;
180 auto ikr = result_t(0,1) * (this->get_wave_number() * r);
181 auto g = std::exp(-ikr) / (r*r*r) / (4. * pi);
182 f[1] = -g * (1. + ikr);
183 f[0] = g * (3. + ikr * (3. + ikr));
187 void eval_impl(std::integral_constant<unsigned, 3>,
scalar r, result_t *f)
const
189 using boost::math::double_constants::pi;
190 auto ikr = result_t(0,1) * (this->get_wave_number() * r);
191 auto g = std::exp(-ikr)/(r*r*r*r) / (4. * pi);
192 f[1] = g * (3. + ikr * (3. + ikr));
193 f[0] = -g * (15. + ikr * (15 + ikr * (6 + ikr)));
202 template <
unsigned order>
203 void eval(
scalar r, result_t *f)
const
205 this->eval_impl(std::integral_constant<unsigned, order>(), r, f);
210 namespace kernel_traits_ns
212 template <
class Scalar,
class WaveNumber>
217 template <
class Scalar,
class WaveNumber>
223 template <
class Scalar,
class WaveNumber>
229 template <
class Scalar,
class WaveNumber>
235 template <
class Scalar,
class WaveNumber>
241 template <
class Scalar,
class WaveNumber>
247 template <
class Scalar,
class WaveNumber>
253 template <
class Scalar,
class WaveNumber>
261 namespace kernel_traits_ns
263 template <
class Scalar,
class WaveNumber,
int Nx,
int Ny>
268 template <
class Scalar,
class WaveNumber,
int Nx,
int Ny>
275 template <
class Scalar,
class WaveNumber>
282 template <
class Scalar,
class WaveNumber>
291 template <
class WaveNumber>
294 template <
class WaveNumber>
297 template <
class WaveNumber>
300 template <
class WaveNumber>
303 template <
class WaveNumber>
306 template <
class WaveNumber>
309 template <
class WaveNumber>
312 template <
class WaveNumber>
315 template <
class WaveNumber>
320 #endif // HELMHOLTZ_KERNEL_HPP_INCLUDED