NiHu  2.0
stokes_singular_integrals.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 
21 #ifndef stokes_SINGULAR_INTEGRALS_HPP_INCLUDED
22 #define stokes_SINGULAR_INTEGRALS_HPP_INCLUDED
23 
24 #include <boost/math/constants/constants.hpp>
25 
26 #include "../core/integral_operator.hpp"
27 #include "../core/singular_integral_shortcut.hpp"
28 
29 #include "stokes_kernel.hpp"
30 #include "field_type_helpers.hpp"
31 #include "guiggiani_1992.hpp"
32 #include "lib_element.hpp"
33 
34 
35 namespace NiHu
36 {
37 
40 {
41  typedef Eigen::Matrix<double, 2, 2> result_t;
42 public:
47  static result_t eval(line_1_elem const &elem, double mu)
48  {
49  using boost::math::double_constants::pi;
50 
51  auto const &C = elem.get_coords();
52  auto rvec = (C.col(1) - C.col(0)).eval();
53  auto r = rvec.norm(); // elem length
54  auto gradr = rvec.normalized();
55 
56  return (
57  - result_t::Identity() * (r * (2.*(std::log(r/2) - 1.) +1. ) )
58  +
59  2.* (gradr * gradr.transpose()) * r
60  ) / (8.*pi*mu);
61  }
62 };
63 
67 template <class TestField, class TrialField>
69  stokes_2d_U_kernel, TestField, TrialField, match::match_1d_type,
70  typename std::enable_if<
71  is_collocational<TestField, TrialField>::value &&
72  is_constant_line<TrialField>::value
73  >::type
74 >
75 {
76 public:
83  template <class result_t>
84  static result_t &eval(
85  result_t &result,
86  kernel_base<stokes_2d_U_kernel> const &kernel,
87  field_base<TestField> const &,
88  field_base<TrialField> const &trial_field,
89  element_match const &)
90  {
92  trial_field.get_elem(), kernel.derived().get_viscosity());
93  return result;
94  }
95 };
96 
97 
101 template <class TestField, class TrialField>
103  stokes_2d_T_kernel, TestField, TrialField, match::match_1d_type,
104  typename std::enable_if<
105  is_collocational<TestField, TrialField>::value &&
106  is_constant_line<TrialField>::value
107  >::type
108 >
109 {
110 public:
117  template <class result_t>
118  static result_t &eval(
119  result_t &result,
121  field_base<TestField> const &,
122  field_base<TrialField> const &,
123  element_match const &)
124  {
125  result.setZero();
126  return result;
127  }
128 };
129 
130 
134 template <class TestField, class TrialField>
136  stokes_3d_T_kernel, TestField, TrialField, match::match_2d_type,
137  typename std::enable_if<
138  std::is_same<typename get_formalism<TestField, TrialField>::type, formalism::collocational>::value
139  >::type
140 >
141 {
142 public:
148  template <class result_t>
149  static result_t &eval(
150  result_t &result,
151  kernel_base<stokes_3d_T_kernel> const &kernel,
152  field_base<TestField> const &,
153  field_base<TrialField> const &trial_field,
154  element_match const &)
155  {
157  auto const &elem = trial_field.get_elem();
158  guiggiani_t gui(elem, kernel.derived());
159 
160  auto const &xi0 = TestField::nset_t::corner_at(0);
161  gui.integrate(result, xi0, elem.get_normal(xi0));
162 
163  return result;
164  }
165 };
166 
167 
170 {
171  typedef Eigen::Matrix<double, 2, 2> result_t;
172 public:
178  static result_t eval(line_1_elem const &elem, double mu)
179  {
180  using boost::math::double_constants::pi;
181 
182  auto const &C = elem.get_coords();
183  auto rvec = (C.col(1) - C.col(0)).eval();
184  auto r = rvec.norm(); // elem length
185  auto gradr = rvec.normalized();
186 
187  return r*r * (
188  - result_t::Identity() * (2.*(std::log(r) - 1.5)+1.)
189  + 2.* (gradr * gradr.transpose())
190  ) / (8.*pi*mu) ;
191  }
192 };
193 
194 
199 template <class TestField, class TrialField>
201  stokes_2d_U_kernel, TestField, TrialField, match::match_1d_type,
202  typename std::enable_if<
203  std::is_same<typename get_formalism<TestField, TrialField>::type, formalism::general>::value &&
204  std::is_same<typename TrialField::elem_t::lset_t, line_1_shape_set>::value &&
205  std::is_same<typename TestField::nset_t, line_0_shape_set>::value &&
206  std::is_same<typename TrialField::nset_t, line_0_shape_set>::value
207  >::type
208 >
209 {
210 public:
217  template <class result_t>
218  static result_t &eval(
219  result_t &result,
220  kernel_base<stokes_2d_U_kernel> const &kernel,
221  field_base<TestField> const &,
222  field_base<TrialField> const &trial_field,
223  element_match const &)
224  {
226  trial_field.get_elem(), kernel.derived().get_viscosity());
227  return result;
228  }
229 };
230 
231 
232 
233 
237 template <class TestField, class TrialField>
239  stokes_2d_T_kernel, TestField, TrialField, match::match_1d_type,
240  typename std::enable_if<
241  std::is_same<typename get_formalism<TestField, TrialField>::type, formalism::general>::value &&
242  std::is_same<typename TestField::elem_t::lset_t, line_1_shape_set>::value &&
243  std::is_same<typename TrialField::elem_t::lset_t, line_1_shape_set>::value &&
244  std::is_same<typename TestField::nset_t, line_0_shape_set>::value &&
245  std::is_same<typename TrialField::nset_t, line_0_shape_set>::value
246  >::type
247 >
248 {
249 public:
257  template <class result_t>
258  static result_t &eval(
259  result_t &result,
260  kernel_base<stokes_2d_T_kernel> const &kernel,
261  field_base<TestField> const &test_field,
262  field_base<TrialField> const &trial_field,
263  element_match const &)
264  {
265  result.setZero();
266  return result;
267  }
268 };
269 
270 } // end of namespace NiHu
271 
272 
273 #endif // STOKES_SINGULAR_INTEGRALS_HPP_INCLUDED
NiHu::singular_integral_shortcut< stokes_2d_U_kernel, TestField, TrialField, match::match_1d_type, typename std::enable_if< is_collocational< TestField, TrialField >::value &&is_constant_line< TrialField >::value >::type >::eval
static result_t & eval(result_t &result, kernel_base< stokes_2d_U_kernel > const &kernel, field_base< TestField > const &, field_base< TrialField > const &trial_field, element_match const &)
evaluate singular integral
Definition: stokes_singular_integrals.hpp:84
C
Definition: bbfmm_covariance.cpp:47
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::stokes_2d_U_collocation_constant_line::eval
static result_t eval(line_1_elem const &elem, double mu)
Evaluate the integral.
Definition: stokes_singular_integrals.hpp:47
guiggiani_1992.hpp
Guiggiani's method for CPV and HPF collocational integrals.
NiHu::singular_integral_shortcut< stokes_2d_T_kernel, TestField, TrialField, match::match_1d_type, typename std::enable_if< is_collocational< TestField, TrialField >::value &&is_constant_line< TrialField >::value >::type >::eval
static result_t & eval(result_t &result, kernel_base< stokes_2d_T_kernel > const &, field_base< TestField > const &, field_base< TrialField > const &, element_match const &)
evaluate singular integral
Definition: stokes_singular_integrals.hpp:118
NiHu::kernel_base< stokes_2d_U_kernel >
NiHu::match::match_2d_type
std::integral_constant< int, 2 > match_2d_type
two elements are adjacent with a 2d (surface) match
Definition: match_types.hpp:42
NiHu::element_match
class describing the adjacency (match) state of two elements
Definition: element_match.hpp:39
NiHu::stokes_2d_U_collocation_constant_line
Collocational singular integral of 2D Stokes U kernel over constant line.
Definition: stokes_singular_integrals.hpp:39
NiHu::singular_integral_shortcut
a shortcut for the user to define customised singular integral methods
Definition: double_integral.hpp:709
NiHu::match::match_1d_type
std::integral_constant< int, 1 > match_1d_type
two elements are adjacent with a 1d (line) match
Definition: match_types.hpp:40
NiHu::stokes_2d_U_galerkin_face_constant_line::eval
static result_t eval(line_1_elem const &elem, double mu)
Evaluate the integral.
Definition: stokes_singular_integrals.hpp:178
NiHu::singular_integral_shortcut< stokes_3d_T_kernel, TestField, TrialField, match::match_2d_type, typename std::enable_if< std::is_same< typename get_formalism< TestField, TrialField >::type, formalism::collocational >::value >::type >::eval
static result_t & eval(result_t &result, kernel_base< stokes_3d_T_kernel > const &kernel, field_base< TestField > const &, field_base< TrialField > const &trial_field, element_match const &)
evaluate singular integral
Definition: stokes_singular_integrals.hpp:149
NiHu::field_base::get_elem
const elem_t & get_elem() const
return underlying element
Definition: field.hpp:149
NiHu::field_base
CRTP base class of all fields.
Definition: field.hpp:111
NiHu::surface_element
class describing a surface element that provides a normal vector
Definition: element.hpp:451
NiHu::stokes_2d_U_galerkin_face_constant_line
Galerkin face match integral of 2D Stokes U kernel over constant line.
Definition: stokes_singular_integrals.hpp:169
NiHu::singular_integral_shortcut< stokes_2d_U_kernel, TestField, TrialField, match::match_1d_type, typename std::enable_if< std::is_same< typename get_formalism< TestField, TrialField >::type, formalism::general >::value &&std::is_same< typename TrialField::elem_t::lset_t, line_1_shape_set >::value &&std::is_same< typename TestField::nset_t, line_0_shape_set >::value &&std::is_same< typename TrialField::nset_t, line_0_shape_set >::value >::type >::eval
static result_t & eval(result_t &result, kernel_base< stokes_2d_U_kernel > const &kernel, field_base< TestField > const &, field_base< TrialField > const &trial_field, element_match const &)
evaluate singular integral
Definition: stokes_singular_integrals.hpp:218
stokes_kernel.hpp
implementation of fundamental solutions of Stokes flow
lib_element.hpp
NiHu::guiggiani
Implementation of Guiggiani's method.
Definition: guiggiani_1992.hpp:84
NiHu::stokes_3d_T_kernel
the traction kernel for 3d Stokes flow
Definition: stokes_kernel.hpp:303
NiHu::singular_integral_shortcut< stokes_2d_T_kernel, TestField, TrialField, match::match_1d_type, typename std::enable_if< std::is_same< typename get_formalism< TestField, TrialField >::type, formalism::general >::value &&std::is_same< typename TestField::elem_t::lset_t, line_1_shape_set >::value &&std::is_same< typename TrialField::elem_t::lset_t, line_1_shape_set >::value &&std::is_same< typename TestField::nset_t, line_0_shape_set >::value &&std::is_same< typename TrialField::nset_t, line_0_shape_set >::value >::type >::eval
static result_t & eval(result_t &result, kernel_base< stokes_2d_T_kernel > const &kernel, field_base< TestField > const &test_field, field_base< TrialField > const &trial_field, element_match const &)
evaluate singular integral
Definition: stokes_singular_integrals.hpp:258