NiHu  2.0
stokes_kernel.hpp
Go to the documentation of this file.
1 // This file is a part of NiHu, a C++ BEM template library.
2 //
3 // Copyright (C) 2012-2014 Peter Fiala <fiala@hit.bme.hu>
4 // Copyright (C) 2012-2014 Peter Rucz <rucz@hit.bme.hu>
5 //
6 // This program is free software: you can redistribute it and/or modify
7 // it under the terms of the GNU General Public License as published by
8 // the Free Software Foundation, either version 3 of the License, or
9 // (at your option) any later version.
10 //
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
15 //
16 // You should have received a copy of the GNU General Public License
17 // along with this program. If not, see <http://www.gnu.org/licenses/>.
18 
23 
26 #ifndef stokes_KERNEL_HPP_INCLUDED
27 #define stokes_KERNEL_HPP_INCLUDED
28 
29 #include <boost/math/constants/constants.hpp>
30 
31 #include "../core/global_definitions.hpp"
32 #include "../core/kernel.hpp"
33 #include "../core/gaussian_quadrature.hpp"
34 #include "location_normal.hpp"
35 #include "guiggiani_1992.hpp"
36 
37 
38 namespace NiHu
39 {
40 
43 {
44 public:
48  stokes_kernel(double mu)
49  : m_mu(mu)
50  {
51  }
52 
55 
57 
58  double get_viscosity() const
59  {
60  return m_mu;
61  }
62 
63 private:
64  double m_mu;
65 };
66 
67 
70 
71 class stokes_2d_U_kernel;
72 
74 template <>
76 {
79  typedef Eigen::Matrix<double, 2, 2> result_t;
81  static bool const is_symmetric = true;
82 
84 
85  static bool const is_singular = true;
86 };
87 
88 
90 template <>
92 {
94  static unsigned const singular_quadrature_order = 7;
96 };
97 
100 
103  : public kernel_base<stokes_2d_U_kernel>
104  , public stokes_kernel
105 {
106 public:
107  typedef location_input_2d::x_t x_t;
108 
112  : stokes_kernel(mu)
113  {
114  }
115 
120  result_t operator()(x_t const &x, x_t const &y) const
121  {
122  using boost::math::double_constants::pi;
123  double mu = get_viscosity();
124  x_t rvec = y - x; // distance vector
125  double r = rvec.norm(); // scalar distance
126  x_t gradr = rvec.normalized(); // gradient of the distance vector
127  return ( - 1.* result_t::Identity() * (2.*std::log(r) +1.) + 2.* (gradr * gradr.transpose()) ) / (8.*pi*mu);
128  }
129 
135  location_input_2d const &x,
136  location_input_2d const &y) const
137  {
138  return (*this)(x.get_x(), y.get_x());
139  }
140 
141 };
142 
143 
145 class stokes_2d_T_kernel;
146 
148 template <>
150 {
153  typedef Eigen::Matrix<double, 2, 2> result_t;
155  static bool const is_symmetric = true;
156 
158 
159  static bool const is_singular = true;
160 };
161 
162 
164 template <>
166 {
168  static unsigned const singular_quadrature_order = 7;
170 };
171 
174  : public kernel_base<stokes_2d_T_kernel>
175  , public stokes_kernel
176 {
177 public:
178  typedef location_input_2d::x_t x_t;
179 
183  : stokes_kernel(mu)
184  {
185  }
186 
192  location_input_2d const &x,
193  location_normal_input_2d const &y) const
194  {
195  using boost::math::double_constants::pi;
196 
197  x_t rvec = y.get_x() - x.get_x();
198  double r = rvec.norm();
199  x_t gradr = rvec.normalized();
200  x_t const &n = y.get_unit_normal();
201  double rdny = gradr.dot(n);
202  return
203  -1.0 *( rdny *( gradr*gradr.transpose()) ) / (pi*r);
204  }
205 };
206 
207 
209 class stokes_3d_U_kernel;
210 
212 template <>
214 {
217  typedef Eigen::Matrix<double, 3, 3> result_t;
219  static bool const is_symmetric = true;
221  static bool const is_singular = true;
222 };
223 
224 
226 template <>
228 {
230  static unsigned const singular_quadrature_order = 7;
232 };
233 
236  : public kernel_base<stokes_3d_U_kernel>
237  , public stokes_kernel
238 {
239 public:
240  typedef location_input_3d::x_t x_t;
241 
245  : stokes_kernel(mu)
246  {
247  }
248 
254  x_t const& x,
255  x_t const& y) const
256  {
257  using boost::math::double_constants::pi;
258 
259  double mu = get_viscosity();
260  x_t rvec = y - x;
261  double r = rvec.norm();
262  x_t gradr = rvec.normalized();
263  return ( result_t::Identity() + (gradr * gradr.transpose())) / (8. * pi * r * mu);
264  }
265 
271  location_input_3d const &x,
272  location_input_3d const &y) const
273  {
274  return (*this)(x.get_x(), y.get_x());
275  }
276 };
277 
279 class stokes_3d_T_kernel;
280 
281 template <>
283 {
286  typedef Eigen::Matrix<double, 3, 3> result_t;
288  static bool const is_symmetric = false;
290  static bool const is_singular = true;
291 };
292 
294 template <>
296 {
298  static unsigned const singular_quadrature_order = 7;
300 };
301 
304  : public kernel_base<stokes_3d_T_kernel>
305  , public stokes_kernel
306 {
307 public:
308  typedef location_input_3d::x_t x_t;
309 
313  : stokes_kernel(mu)
314  {
315  }
316 
323  x_t const &x,
324  x_t const &y,
325  x_t const &ny) const
326  {
327  using boost::math::double_constants::pi;
328 
329  auto rvec = y - x;
330  auto r = rvec.norm();
331  auto gradr = rvec.normalized();
332  auto rdny = gradr.dot(ny);
333  return (-rdny * ( 3. * (gradr * gradr.transpose())) ) / (4. * pi * r * r);
334  }
335 
341  location_input_3d const &x,
342  location_normal_input_3d const &y) const
343  {
344  return (*this)(x.get_x(), y.get_x(), y.get_unit_normal());
345  }
346 };
347 
349 template <>
351 {
352 public:
356  template <class guiggiani>
357  static void eval(guiggiani &obj)
358  {
359  // in this case the traction kernel is only weakly singular
360  obj.set_laurent_coeff(_m1(), guiggiani::laurent_coeff_t::Zero());
361  }
362 };
363 
364 }
365 
366 #endif // STOKES_KERNEL_HPP_INCLUDED
367 
NiHu::singular_kernel_traits::singular_core_t
kernel_traits_ns::singular_core< Derived >::type singular_core_t
the kernel's singular core type
Definition: kernel.hpp:106
NiHu::kernel_traits::quadrature_family_t
kernel_traits_ns::quadrature_family< Derived >::type quadrature_family_t
the far field asymptotic behaviour of the kernel
Definition: kernel.hpp:84
NiHu::asymptotic::log< 1 >
NiHu::stokes_2d_T_kernel
2d traction kernel for Stokes flow
Definition: stokes_kernel.hpp:173
NiHu::stokes_2d_U_kernel
The velocity kernel of 2D Stokes flow.
Definition: stokes_kernel.hpp:102
NiHu::kernel_traits::far_field_behaviour_t
kernel_traits_ns::far_field_behaviour< Derived >::type far_field_behaviour_t
the far field asymptotic behaviour of the kernel
Definition: kernel.hpp:82
NiHu::singular_kernel_traits
singular traits class of a kernel
Definition: kernel.hpp:101
NiHu::stokes_2d_U_kernel::stokes_2d_U_kernel
stokes_2d_U_kernel(double mu)
Construct a new Stokes 2d U kernel object.
Definition: stokes_kernel.hpp:111
NiHu::kernel_traits::test_input_t
kernel_traits_ns::test_input< Derived >::type test_input_t
kernel test input type
Definition: kernel.hpp:76
NiHu::location_input::x_t
space_t::location_t x_t
the location type
Definition: location_normal.hpp:43
NiHu::location_normal_jacobian_input
a class representing a normal + Jacobian input
Definition: location_normal.hpp:79
NiHu::kernel_traits::is_singular
@ is_singular
indicates if the kernel is singular
Definition: kernel.hpp:91
guiggiani_1992.hpp
Guiggiani's method for CPV and HPF collocational integrals.
NiHu::kernel_base
CRTP base class of all BEM kernels.
Definition: kernel.hpp:133
NiHu::stokes_3d_U_kernel::operator()
result_t operator()(location_input_3d const &x, location_input_3d const &y) const
evaluate the stokes 3d velocity kernel between two kernel inputs
Definition: stokes_kernel.hpp:270
NiHu::_m1
std::integral_constant< int, -1 > _m1
shorthand for constant minus one
Definition: guiggiani_1992.hpp:69
NiHu::kernel_traits
traits class of a kernel
Definition: kernel.hpp:71
NiHu::stokes_kernel::get_viscosity
double get_viscosity() const
Get the viscosity.
Definition: stokes_kernel.hpp:58
NiHu::singular_kernel_traits::singular_quadrature_order
@ singular_quadrature_order
the quadrature order singular integrals are handled with
Definition: kernel.hpp:111
NiHu::singular_kernel_traits::singularity_type_t
kernel_traits_ns::singularity_type< Derived >::type singularity_type_t
the kernel's singularity type
Definition: kernel.hpp:104
NiHu::stokes_kernel::stokes_kernel
stokes_kernel(double mu)
Construct a new Stokes kernel object.
Definition: stokes_kernel.hpp:48
NiHu::stokes_kernel
Base class for Stokes kernels. This class contains one material parameter.
Definition: stokes_kernel.hpp:42
NiHu::kernel_traits::result_t
kernel_traits_ns::result< Derived >::type result_t
the kernel result type
Definition: kernel.hpp:80
NiHu::kernel_traits::is_symmetric
@ is_symmetric
indicates if the kernel is symmetric
Definition: kernel.hpp:89
NiHu::stokes_3d_T_kernel::stokes_3d_T_kernel
stokes_3d_T_kernel(double mu)
instantiate the stokes kernel
Definition: stokes_kernel.hpp:312
NiHu::polar_laurent_coeffs< stokes_3d_T_kernel >::eval
static void eval(guiggiani &obj)
evaluate the Laurent coefficients
Definition: stokes_kernel.hpp:357
NiHu::stokes_2d_T_kernel::operator()
result_t operator()(location_input_2d const &x, location_normal_input_2d const &y) const
Evaluate the kernel between two inputs.
Definition: stokes_kernel.hpp:191
NiHu::stokes_3d_U_kernel::operator()
result_t operator()(x_t const &x, x_t const &y) const
evaluate the stokes 3d traction kernel between two locations
Definition: stokes_kernel.hpp:253
NiHu::asymptotic::inverse< 1 >
NiHu::stokes_3d_U_kernel::stokes_3d_U_kernel
stokes_3d_U_kernel(double mu)
instantiate the stokes kernel
Definition: stokes_kernel.hpp:244
NiHu::stokes_2d_U_kernel::operator()
result_t operator()(location_input_2d const &x, location_input_2d const &y) const
Evaluate the kernel between two kernel inputs.
Definition: stokes_kernel.hpp:134
NiHu::stokes_3d_U_kernel
the velocity kernel for 3d Stokes flow
Definition: stokes_kernel.hpp:235
NiHu::location_input::get_x
const x_t & get_x(void) const
return the location
Definition: location_normal.hpp:65
location_normal.hpp
implementation of location and normal kernel inputs
NiHu::stokes_2d_U_kernel::operator()
result_t operator()(x_t const &x, x_t const &y) const
Evaluate the kernel between two locations.
Definition: stokes_kernel.hpp:120
NiHu::stokes_3d_T_kernel::operator()
result_t operator()(x_t const &x, x_t const &y, x_t const &ny) const
evaluate the stokes 3d traction kernel between two locations
Definition: stokes_kernel.hpp:322
NiHu::kernel_base< stokes_2d_U_kernel >::result_t
traits_t::result_t result_t
compile time check if the two kernel inputs are compatible
Definition: kernel.hpp:147
NiHu::stokes_3d_T_kernel::operator()
result_t operator()(location_input_3d const &x, location_normal_input_3d const &y) const
evaluate the stokes 3d traction kernel between two kernel inputs
Definition: stokes_kernel.hpp:340
NiHu::polar_laurent_coeffs
definition of Laurent coefficients of singularities
Definition: guiggiani_1992.hpp:64
NiHu::kernel_traits::trial_input_t
kernel_traits_ns::trial_input< Derived >::type trial_input_t
kernel trial input type
Definition: kernel.hpp:78
NiHu::stokes_2d_T_kernel::stokes_2d_T_kernel
stokes_2d_T_kernel(double mu)
Construct a new Stokes 2d T kernel object.
Definition: stokes_kernel.hpp:182
NiHu::guiggiani
Implementation of Guiggiani's method.
Definition: guiggiani_1992.hpp:84
NiHu::location_input
a class representing a simple location
Definition: location_normal.hpp:37
NiHu::stokes_3d_T_kernel
the traction kernel for 3d Stokes flow
Definition: stokes_kernel.hpp:303
NiHu::location_normal_jacobian_input::get_unit_normal
const x_t & get_unit_normal(void) const
return the unit normal vector
Definition: location_normal.hpp:116
NiHu::gauss_family_tag
tag for the family of Gaussian quadratures
Definition: gaussian_quadrature.hpp:517