Loading [MathJax]/extensions/tex2jax.js
NiHu  2.0
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
lenoir_salles_2012.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 
28 #ifndef LENOIR_SALLES_2012_HPP_INCLUDED
29 #define LENOIR_SALLES_2012_HPP_INCLUDED
30 
31 #include "laplace_kernel.hpp"
32 #include "lib_element.hpp"
33 
34 #include "../core/integral_operator.hpp"
35 
36 #include <boost/math/constants/constants.hpp>
37 
38 #include <cmath>
39 
40 namespace NiHu
41 {
42 
48 template <class TestField, class TrialField>
50  laplace_3d_SLP_kernel, TestField, TrialField, match::match_2d_type,
51  typename std::enable_if<
52  std::is_same<typename get_formalism<TestField, TrialField>::type, formalism::general>::value &&
53  std::is_same<typename TrialField::lset_t, tria_1_shape_set>::value &&
54  std::is_same<typename TrialField::nset_t, tria_0_shape_set>::value &&
55  std::is_same<typename TestField::nset_t, tria_0_shape_set>::value
56  >::type
57 >
58 {
59 public:
68  template <class scalar_t>
69  static void gamma_splus_sminus(
70  tria_1_elem const &elem,
71  scalar_t gamma[],
72  scalar_t splus[],
73  scalar_t sminus[])
74  {
75  auto const &C = elem.get_coords();
76  unsigned const N = tria_1_elem::num_nodes;
77 
78  for (unsigned i = 0; i < N; ++i)
79  {
80  auto a = C.col(i);
81  auto b = C.col((i+1)%N);
82  auto c = C.col((i+2)%N);
83  auto d = c-b; // opposite side vector
84  auto unit_d = d / d.norm(); // unit vector
85  auto x = (a-b).dot(unit_d)*unit_d + b; // projection
86  gamma[i] = (x-a).norm(); // distance from projection
87  sminus[i] = (x-b).dot(unit_d); // signed distance
88  splus[i] = (x-c).dot(unit_d); // signed distance
89  }
90  }
91 
99  template <class result_t>
100  static result_t &eval(
101  result_t &result,
103  field_base<TestField> const &,
104  field_base<TrialField> const &trial_field,
105  element_match const &)
106  {
107  using namespace boost::math::double_constants;
108 
109  unsigned const N = tria_1_elem::num_nodes;
110  auto const &elem = trial_field.get_elem();
111 
112  // compute geometrical helper values
113  double gamma[N], splus[N], sminus[N];
114  gamma_splus_sminus(elem, gamma, splus, sminus);
115 
116  // element area
117  auto S = elem.get_normal().norm()/2.0;
118 
119  // the famous integral expression from Lenoir-Salles
120  for (unsigned i = 0; i < N; ++i)
121  result(0,0) -= gamma[i] * (
122  std::asinh<double>(splus[i]/gamma[i]) - std::asinh<double>(sminus[i]/gamma[i])
123  ).real();
124 
125  result(0,0) *= 2.0/3.0 * S / (4.0*pi);
126 
127  return result;
128  }
129 };
130 
131 } // end of namespace NiHu
132 
133 #endif /* LENOIR_SALLES_2012_HPP_INCLUDED */
NiHu::field_base::get_elem
const elem_t & get_elem() const
return underlying element
Definition: field.hpp:149
NiHu::kernel_base
CRTP base class of all BEM kernels.
Definition: kernel.hpp:133
NiHu::singular_integral_shortcut
a shortcut for the user to define customised singular integral methods
Definition: double_integral.hpp:709
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::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::singular_integral_shortcut< laplace_3d_SLP_kernel, TestField, TrialField, match::match_2d_type, typename std::enable_if< std::is_same< typename get_formalism< TestField, TrialField >::type, formalism::general >::value &&std::is_same< typename TrialField::lset_t, tria_1_shape_set >::value &&std::is_same< typename TrialField::nset_t, tria_0_shape_set >::value &&std::is_same< typename TestField::nset_t, tria_0_shape_set >::value >::type >::gamma_splus_sminus
static void gamma_splus_sminus(tria_1_elem const &elem, scalar_t gamma[], scalar_t splus[], scalar_t sminus[])
helper function to compute geometrical parameters of a triangle
Definition: lenoir_salles_2012.hpp:69
lib_element.hpp
NiHu::element_match
class describing the adjacency (match) state of two elements
Definition: element_match.hpp:39
laplace_kernel.hpp
implementation of kernels of the Laplace equation
NiHu::singular_integral_shortcut< laplace_3d_SLP_kernel, TestField, TrialField, match::match_2d_type, typename std::enable_if< std::is_same< typename get_formalism< TestField, TrialField >::type, formalism::general >::value &&std::is_same< typename TrialField::lset_t, tria_1_shape_set >::value &&std::is_same< typename TrialField::nset_t, tria_0_shape_set >::value &&std::is_same< typename TestField::nset_t, tria_0_shape_set >::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: lenoir_salles_2012.hpp:100
NiHu::normal_derivative_kernel
Normal derivative of a distance dependent kernel.
Definition: normal_derivative_kernel.hpp:26
C
Definition: bbfmm_covariance.cpp:47