NiHu  2.0
laplace_3d_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 
22 #ifndef LAPLACE_3D_SINGULAR_INTEGRALS_HPP_INCLUDED
23 #define LAPLACE_3D_SINGULAR_INTEGRALS_HPP_INCLUDED
24 
25 #include "../core/match_types.hpp"
26 #include "../core/singular_integral_shortcut.hpp"
27 #include "../util/math_functions.hpp"
28 #include "field_type_helpers.hpp"
29 #include "guiggiani_1992.hpp"
30 #include "lib_element.hpp"
31 #include "laplace_kernel.hpp"
32 #include "normal_derivative_singular_integrals.hpp"
33 #include "plane_element_helper.hpp"
34 #include "quadrature_store_helper.hpp"
35 
36 #include <boost/math/constants/constants.hpp>
37 
38 #define NIHU_PRINT_DEBUG
39 #ifdef NIHU_PRINT_DEBUG
40 #include <iostream>
41 #endif
42 
43 namespace NiHu
44 {
45 
48 {
49 public:
56  template <class elem_t>
57  static double eval(elem_t const &elem, typename elem_t::x_t const &x0)
58  {
59  using namespace boost::math::double_constants;
60 
61 #ifdef NIHU_PRINT_DEBUG
62  static bool printed = false;
63  if (!printed) {
64  std::cout << "Using laplace_3d_SLP_collocation_constant_plane" << std::endl;
65  printed = true;
66  }
67 #endif
68 
69  enum { N = elem_t::domain_t::num_corners };
70  double r[N], theta[N], alpha[N], result = 0.;
71  plane_element_helper(elem, x0, r, theta, alpha);
72 
73  for (unsigned i = 0; i < N; ++i)
74  result += r[i] * std::sin(alpha[i]) *
75  std::log(std::tan((alpha[i] + theta[i]) / 2.) / std::tan(alpha[i] / 2.));
76 
77  return result / (4. * pi);
78  }
79 };
80 
81 
84 {
85 public:
92  template <class elem_t>
93  static double eval(elem_t const &elem, typename elem_t::x_t const &x0)
94  {
95  using namespace boost::math::double_constants;
96 
97 #ifdef NIHU_PRINT_DEBUG
98  static bool printed = false;
99  if (!printed) {
100  std::cout << "Using laplace_3d_HSP_collocation_constant_plane" << std::endl;
101  printed = true;
102  }
103 #endif
104 
105  enum { N = elem_t::domain_t::num_corners };
106  double r[N], theta[N], alpha[N], result = 0.;
107  plane_element_helper(elem, x0, r, theta, alpha);
108 
109  for (unsigned i = 0; i < N; ++i)
110  result += (std::cos(alpha[i] + theta[i]) - std::cos(alpha[i])) / (r[i] * std::sin(alpha[i]));
111 
112  return result / (4. * pi);
113  }
114 };
115 
116 
121 template <class TestField, class TrialField>
123  laplace_3d_SLP_kernel, TestField, TrialField, match::match_2d_type,
124  typename std::enable_if<
125  is_collocational<TestField, TrialField>::value &&
126  is_constant_tria<TrialField>::value
127  >::type
128 >
129 {
130 public:
136  template <class result_t>
137  static result_t &eval(
138  result_t &result,
140  field_base<TestField> const &,
141  field_base<TrialField> const &trial_field,
142  element_match const &)
143  {
145  trial_field.get_elem(),
146  trial_field.get_elem().get_center());
147  return result;
148  }
149 };
150 
151 
156 template <class TestField, class TrialField>
158  laplace_3d_HSP_kernel, TestField, TrialField, match::match_2d_type,
159  typename std::enable_if<
160  is_collocational<TestField, TrialField>::value &&
161  is_constant_tria<TrialField>::value
162  >::type
163 >
164 {
165 public:
171  template <class result_t>
172  static result_t &eval(
173  result_t &result,
175  field_base<TestField> const &,
176  field_base<TrialField> const &trial_field,
177  element_match const &)
178  {
180  trial_field.get_elem(),
181  trial_field.get_elem().get_center());
182  return result;
183  }
184 };
185 
186 
191 template <class TestField, class TrialField>
193  laplace_3d_Gxx_kernel, TestField, TrialField, match::match_2d_type,
194  typename std::enable_if<
195  is_collocational<TestField, TrialField>::value &&
196  is_constant_tria<TrialField>::value
197  >::type
198 >
199 {
200 public:
206  template <class result_t>
207  static result_t &eval(
208  result_t &result,
210  field_base<TestField> const &,
211  field_base<TrialField> const &trial_field,
212  element_match const &)
213  {
214 
216  trial_field.get_elem(),
217  trial_field.get_elem().get_center());
218  return result;
219  }
220 };
221 
222 
227 template <class TestField, class TrialField>
229  laplace_3d_HSP_kernel, TestField, TrialField, match::match_2d_type,
230  typename std::enable_if<
231  is_collocational<TestField, TrialField>::value &&
232  !is_constant_tria<TrialField>::value
233  >::type
234 >
235 {
236 public:
243  template <class result_t>
244  static result_t &eval(
245  result_t &result,
247  field_base<TestField> const &,
248  field_base<TrialField> const &trial_field,
249  element_match const &)
250  {
251 #ifdef NIHU_PRINT_DEBUG
252  static bool printed = false;
253  if (!printed) {
254  std::cout << "Using guiggiani for laplace_3d_HSP_kernel" << std::endl;
255  printed = true;
256  }
257 #endif
259  auto const &elem = trial_field.get_elem();
260  guiggiani_t gui(elem, kernel.derived());
261  for (unsigned r = 0; r < TestField::num_dofs; ++r)
262  {
263  auto const &xi0 = TestField::nset_t::corner_at(r);
264  gui.integrate(result.row(r), xi0, elem.get_normal(xi0));
265  }
266  return result;
267  }
268 };
269 
270 } // namespace NiHu
271 
272 #endif /* LAPLACE_3D_SINGULAR_INTEGRALS_HPP_INCLUDED */
273 
NiHu::plane_element_helper
void plane_element_helper(elem_t const &elem, typename elem_t::x_t const &x0, typename elem_t::scalar_t r[], typename elem_t::scalar_t theta[], typename elem_t::scalar_t alpha[])
compute angles and radii in a plane element
Definition: plane_element_helper.hpp:40
NiHu::volume_element
class describing a volume element that has no normal vector
Definition: element.hpp:455
laplace_kernel.hpp
implementation of kernels of the Laplace equation
plane_element_helper.hpp
helper functions to compute analytical integrals over plane elements
NiHu::volume_element::x_t
element_traits::location_value_type< Derived, 0 >::type x_t
type of the element's physical location variable
Definition: element.hpp:220
NiHu::laplace_3d_SLP_collocation_constant_plane::eval
static double eval(elem_t const &elem, typename elem_t::x_t const &x0)
Evaluate the integral.
Definition: laplace_3d_singular_integrals.hpp:57
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::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::singular_integral_shortcut< laplace_3d_Gxx_kernel, TestField, TrialField, match::match_2d_type, typename std::enable_if< is_collocational< TestField, TrialField >::value &&is_constant_tria< TrialField >::value >::type >::eval
static result_t & eval(result_t &result, kernel_base< laplace_3d_Gxx_kernel > const &, field_base< TestField > const &, field_base< TrialField > const &trial_field, element_match const &)
evaluate singular integral
Definition: laplace_3d_singular_integrals.hpp:207
NiHu::singular_integral_shortcut
a shortcut for the user to define customised singular integral methods
Definition: double_integral.hpp:709
NiHu::singular_integral_shortcut< laplace_3d_HSP_kernel, TestField, TrialField, match::match_2d_type, typename std::enable_if< is_collocational< TestField, TrialField >::value &&!is_constant_tria< TrialField >::value >::type >::eval
static result_t & eval(result_t &result, kernel_base< laplace_3d_HSP_kernel > const &kernel, field_base< TestField > const &, field_base< TrialField > const &trial_field, element_match const &)
evaluate singular integral
Definition: laplace_3d_singular_integrals.hpp:244
NiHu::field_base::get_elem
const elem_t & get_elem() const
return underlying element
Definition: field.hpp:149
NiHu::singular_integral_shortcut< laplace_3d_HSP_kernel, TestField, TrialField, match::match_2d_type, typename std::enable_if< is_collocational< TestField, TrialField >::value &&is_constant_tria< TrialField >::value >::type >::eval
static result_t & eval(result_t &result, kernel_base< laplace_3d_HSP_kernel > const &, field_base< TestField > const &, field_base< TrialField > const &trial_field, element_match const &)
evaluate singular integral
Definition: laplace_3d_singular_integrals.hpp:172
NiHu::field_base
CRTP base class of all fields.
Definition: field.hpp:111
NiHu::laplace_3d_HSP_collocation_constant_plane::eval
static double eval(elem_t const &elem, typename elem_t::x_t const &x0)
Evaluate the integral.
Definition: laplace_3d_singular_integrals.hpp:93
NiHu::laplace_3d_HSP_collocation_constant_plane
Collocational singular integral of the 3D Laplace HSP kernel over a constant planar element.
Definition: laplace_3d_singular_integrals.hpp:83
NiHu::normal_derivative_kernel
Normal derivative of a distance dependent kernel.
Definition: normal_derivative_kernel.hpp:26
lib_element.hpp
NiHu::singular_integral_shortcut< laplace_3d_SLP_kernel, TestField, TrialField, match::match_2d_type, typename std::enable_if< is_collocational< TestField, TrialField >::value &&is_constant_tria< TrialField >::value >::type >::eval
static result_t & eval(result_t &result, kernel_base< laplace_3d_SLP_kernel > const &, field_base< TestField > const &, field_base< TrialField > const &trial_field, element_match const &)
evaluate singular integral
Definition: laplace_3d_singular_integrals.hpp:137
NiHu::laplace_3d_SLP_collocation_constant_plane
Collocational singular integral of the 3D Laplace SLP kernel over a constant plane element.
Definition: laplace_3d_singular_integrals.hpp:47
NiHu::guiggiani
Implementation of Guiggiani's method.
Definition: guiggiani_1992.hpp:84