NiHu  2.0
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 
25 #ifndef KERNEL_HPP_INCLUDED
26 #define KERNEL_HPP_INCLUDED
27 
28 #include "complexity_estimator.hpp"
29 #include "asymptotic_types.hpp"
30 #include "../util/crtp_base.hpp"
31 #include "../library/interval_estimator.hpp"
32 #include "../library/distance_kernel_intervals.hpp"
33 
34 namespace NiHu
35 {
36 
38 namespace kernel_traits_ns
39 {
41  template <class Derived> struct space;
43  template <class Derived> struct test_input;
45  template <class Derived> struct trial_input;
47  template <class Derived> struct result;
49  template <class Derived> struct quadrature_family;
51  template <class Derived> struct far_field_behaviour;
52 
54  template <class Derived> struct is_symmetric;
56  template <class Derived> struct is_singular;
57 
59  template <class Derived> struct singularity_type;
61  template <class Derived> struct singular_quadrature_order;
63  template <class Derived> struct singular_core;
64 }
65 
70 template <class Derived>
72 {
85 
87  enum {
92  };
93 };
94 
95 
100 template <class Derived>
102 {
107 
109  enum {
112  };
113 };
114 
115 
116 
117 template <class Derived>
119 {
120  typedef interval_estimator<
121  typename distance_kernel_interval<
123  >::type
124  > type;
125 };
126 
127 
132 template <class Derived>
134 {
135 public:
137 
140 
142  typedef typename traits_t::test_input_t test_input_t;
144  typedef typename traits_t::trial_input_t trial_input_t;
146  static_assert(std::is_same<typename test_input_t::space_t, typename trial_input_t::space_t>::value,
147  "The test and trial kernel inputs must define the same coordinate space");
149  typedef typename traits_t::result_t result_t;
150 
152  typedef typename test_input_t::space_t space_t;
154  typedef typename space_t::location_t x_t;
156  typedef typename space_t::scalar_t scalar_t;
157 
159  typedef typename traits_t::quadrature_family_t quadrature_family_t;
160 
162  static bool const is_symmetric = traits_t::is_symmetric;
163 
165  static bool const is_sungular = traits_t::is_singular;
166 
168  typedef typename traits_t::far_field_behaviour_t far_field_behaviour_t;
169 
172 
175  {
176  public:
182  : m_kernel(kernel.derived()), m_test_input(x)
183  {
184  }
185 
191  {
192  return m_kernel(m_test_input, y);
193  }
194 
195  private:
197  Derived const &m_kernel;
199  test_input_t const &m_test_input;
200  };
201 
206  kernel_bind bind(test_input_t const &x) const
207  {
208  return kernel_bind(*this, x);
209  }
210 
217  result_t operator()(test_input_t const &x, trial_input_t const &y) const
218  {
219  return derived()(x, y);
220  }
221 };
222 
223 } // end of namespace NiHu
224 
225 #endif // KERNEL_HPP_INCLUDED
226 
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_ns::singularity_type
return the kernel's singularity type
Definition: kernel.hpp:59
NiHu::kernel_base::operator()
result_t operator()(test_input_t const &x, trial_input_t const &y) const
evaluate kernel at a given source and receiver position
Definition: kernel.hpp:217
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::kernel_traits_ns::result
return the kernel's result type
Definition: kernel.hpp:47
NiHu::kernel_traits::space_t
kernel_traits_ns::space< Derived >::type space_t
the kernel's coordinate space
Definition: kernel.hpp:74
NiHu::kernel_base::kernel_bind
the kernel bound at the test kernel input
Definition: kernel.hpp:174
NiHu::kernel_base::estimator_t
kernel_compl_estimator< Derived >::type estimator_t
the kernel complexity estimator class
Definition: kernel.hpp:171
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::kernel_base::bind
kernel_bind bind(test_input_t const &x) const
bind the kernel at its test input
Definition: kernel.hpp:206
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::distance_kernel_interval
define intervals for distance range and accuracy
Definition: distance_kernel_intervals.hpp:51
NiHu::kernel_traits_ns::singular_core
return the kernel's singular core type
Definition: kernel.hpp:63
NIHU_CRTP_HELPERS
#define NIHU_CRTP_HELPERS
define CRTP helper function
Definition: crtp_base.hpp:29
NiHu::kernel_traits::is_singular
@ is_singular
indicates if the kernel is singular
Definition: kernel.hpp:91
NiHu::kernel_traits_ns::is_singular
return whether the kernel is singular or not
Definition: kernel.hpp:56
NiHu::kernel_base
CRTP base class of all BEM kernels.
Definition: kernel.hpp:133
NiHu::kernel_base::scalar_t
space_t::scalar_t scalar_t
type of the scalar coordinate in the kernel's domain
Definition: kernel.hpp:156
NiHu::kernel_traits
traits class of a kernel
Definition: kernel.hpp:71
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::kernel_traits_ns::far_field_behaviour
return the far field asymptotic behaviour of the kernel
Definition: kernel.hpp:51
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::kernel_traits_ns::singular_quadrature_order
return the quadrature order the singular kernel needs to be integrated with
Definition: kernel.hpp:61
NiHu::kernel_base::is_sungular
static const bool is_sungular
true if the kernel is singular
Definition: kernel.hpp:165
NiHu::kernel_base::far_field_behaviour_t
traits_t::far_field_behaviour_t far_field_behaviour_t
the asymptotic (far field) behaviour of the kernel
Definition: kernel.hpp:168
NiHu::kernel_base::traits_t
NIHU_CRTP_HELPERS typedef kernel_traits< Derived > traits_t
the traits class
Definition: kernel.hpp:139
NiHu::kernel_traits_ns::is_symmetric
return whether the kernel is symmetric or not
Definition: kernel.hpp:54
NiHu::kernel_traits_ns::quadrature_family
return the quadrature family the kernel is integrated with
Definition: kernel.hpp:49
NiHu::kernel_base::trial_input_t
traits_t::trial_input_t trial_input_t
type of the second (trial) kernel input
Definition: kernel.hpp:144
NiHu::kernel_base::test_input_t
traits_t::test_input_t test_input_t
type of the first (test) kernel input
Definition: kernel.hpp:142
complexity_estimator.hpp
Estimate kernel complexity between two elements.
NiHu::kernel_traits_ns::trial_input
return the kernel's trial input
Definition: kernel.hpp:45
NiHu::kernel_base::space_t
test_input_t::space_t space_t
type of the kernel's domain space
Definition: kernel.hpp:152
NiHu::kernel_traits_ns::space
return the coordinate space where the kernel is defined
Definition: kernel.hpp:41
NiHu::kernel_base::result_t
traits_t::result_t result_t
compile time check if the two kernel inputs are compatible
Definition: kernel.hpp:147
NiHu::interval_estimator
specialisation of NiHu::complexity_estimator for the interval case
Definition: interval_estimator.hpp:38
NiHu::kernel_base::quadrature_family_t
traits_t::quadrature_family_t quadrature_family_t
the quadrature family the kernel is integrated with
Definition: kernel.hpp:159
NiHu::kernel_traits_ns::test_input
return the kernel's test input
Definition: kernel.hpp:43
NiHu::kernel_base::is_symmetric
static const bool is_symmetric
true if K(x,y) = K(y,x)
Definition: kernel.hpp:162
NiHu::kernel_base::kernel_bind::kernel_bind
kernel_bind(kernel_base< Derived > const &kernel, test_input_t const &x)
constructor
Definition: kernel.hpp:181
NiHu::kernel_traits::trial_input_t
kernel_traits_ns::trial_input< Derived >::type trial_input_t
kernel trial input type
Definition: kernel.hpp:78
asymptotic_types.hpp
definition of different asymptotic function behaviour types
NiHu::kernel_base::kernel_bind::operator()
result_t operator()(trial_input_t const &y) const
evaluate bound kernel
Definition: kernel.hpp:190
NiHu::kernel_base::x_t
space_t::location_t x_t
type of a location vector in the kernel's domain
Definition: kernel.hpp:154
NiHu::kernel_compl_estimator
Definition: kernel.hpp:118