NiHu  2.0
p2p_integral.hpp
Go to the documentation of this file.
1 
7 #ifndef NIHU_P2P_INTEGRAL_HPP_INCLUDED
8 #define NIHU_P2P_INTEGRAL_HPP_INCLUDED
9 
10 #include "fmm_operator.hpp"
12 #include "identity_p2p_operator.h"
13 #include "local_operator.hpp"
14 
15 #include "../core/double_integral.hpp"
16 #include "../core/single_integral.hpp"
17 
18 #include "../util/matrix_traits.hpp"
19 #include "../util/type2tag.hpp"
20 
21 #include <type_traits>
22 
23 namespace NiHu
24 {
25 namespace fmm
26 {
27 
28 template <class Operator, class TestField, class TrialField>
30 
31 template <class Operator, class TestField, class TrialField>
32 struct is_local_operator<p2p_integral<Operator, TestField, TrialField > >
33  : public is_local_operator<typename std::decay<Operator>::type> {};
34 
35 template <class Operator, class TestField, class TrialField>
36 struct integral_operator_expression_traits<p2p_integral<Operator, TestField, TrialField> >
37 {
38  typedef TestField test_input_t;
39  typedef TrialField trial_input_t;
40 
41  typedef typename NiHu::double_integral<
42  typename std::decay<Operator>::type::kernel_t,
43  TestField,
44  TrialField
45  >::result_t result_t;
46 };
47 
48 
49 template <class TestField, class TrialField>
51 {
52  typedef TestField test_input_t;
53  typedef TrialField trial_input_t;
54  typedef typename NiHu::single_integral<
55  TestField,
56  TrialField
57  >::result_t result_t;
58 };
59 
60 
61 template <class Operator, class TestField, class TrialField>
62 class p2p_integral
63  : public integral_operator_expression<p2p_integral<Operator, TestField, TrialField> >
64  , public fmm_operator<typename std::decay<Operator>::type::fmm_tag>
65 {
66 public:
68 
69  typedef typename base_t::test_input_t test_input_t;
70  typedef typename base_t::trial_input_t trial_input_t;
71  typedef typename base_t::result_t result_t;
72 
73  typedef typename std::decay<Operator>::type operator_t;
74  typedef TestField test_field_t;
75  typedef TrialField trial_field_t;
76 
77  typedef typename operator_t::kernel_t kernel_t;
79 
80  p2p_integral(Operator &&op, bool sing_check)
81  : m_kernel(op.get_kernel())
82  , m_singular_check(sing_check)
83  {
84  }
85 
86  size_t rows(test_input_t const &tsi) const
87  {
89  }
90 
91  size_t cols(trial_input_t const &tri) const
92  {
93  return num_cols<result_t>::value;
94  }
95 
96  result_t operator()(test_input_t const &x, trial_input_t const &y) const
97  {
98  if (m_singular_check)
99  return double_integral_t::eval(
100  m_kernel, x, y,
101  std::true_type());
102  else
103  return double_integral_t::eval(
104  m_kernel, x, y,
105  std::false_type());
106  }
107 
108 private:
109  kernel_t m_kernel;
110  bool const m_singular_check;
111 };
112 
113 
114 template <class TestField, class TrialField>
115 class p2p_integral<identity_p2p_operator, TestField, TrialField>
116  : public integral_operator_expression<p2p_integral<identity_p2p_operator, TestField, TrialField> >
117  , public fmm_operator<typename identity_p2p_operator::fmm_tag>
118 {
119 public:
121 
122  typedef typename base_t::test_input_t test_input_t;
123  typedef typename base_t::trial_input_t trial_input_t;
124  typedef typename base_t::result_t result_t;
125 
126  typedef TestField test_field_t;
127  typedef TrialField trial_field_t;
128 
130 
132  {
133  }
134 
135  size_t rows(test_input_t const &tsi) const
136  {
138  }
139 
140  size_t cols(trial_input_t const &tri) const
141  {
143  }
144 
145  result_t operator()(test_input_t const &x, trial_input_t const &y) const
146  {
148  bool on_same_elem = &x.get_elem() == &y.get_elem();
149  if (on_same_elem)
150  return single_integral_t::eval(x, y);
151  return result_t::Zero();
152  }
153 };
154 
155 
156 
157 template <class Operator, class TestTag, class TrialTag>
158 auto create_p2p_integral(Operator &&op, TestTag, TrialTag, bool sing_check)
159 {
160  typedef typename tag2type<TestTag>::type test_field_t;
161  typedef typename tag2type<TrialTag>::type trial_field_t;
162  return p2p_integral<Operator, test_field_t, trial_field_t>(std::forward<Operator>(op), sing_check);
163 }
164 
165 template <class TestTag, class TrialTag>
166 auto create_identity_p2p_integral(TestTag, TrialTag)
167 {
168  typedef typename tag2type<TestTag>::type test_field_t;
169  typedef typename tag2type<TrialTag>::type trial_field_t;
170  return p2p_integral<identity_p2p_operator, test_field_t, trial_field_t>(identity_p2p_operator());
171 }
172 
173 } // end of namespace fmm
174 } // namespace NiHu
175 
176 #endif /* NIHU_P2P_INTEGRAL_HPP_INCLUDED */
NiHu::fmm::is_local_operator
Metafunction to tell if an operator is local.
Definition: local_operator.hpp:25
fmm_operator.hpp
FMM operator types and tags.
NiHu::double_integral
class evaluating double integrals of the weighted residual approach
Definition: double_integral.hpp:133
NiHu::tag2type
Metafunction recovering the type from a tag.
Definition: type2tag.hpp:28
identity_p2p_operator.h
Definition of class NiHu::fmm::identity_p2p_operator.
NiHu::fmm::integral_operator_expression
the base class of every integral operator
Definition: integral_operator_expression.hpp:28
NiHu::exponential_covariance_kernel
Definition: covariance_kernel.hpp:42
NiHu::fmm::p2p_integral< identity_p2p_operator, TestField, TrialField >::operator()
result_t operator()(test_input_t const &x, trial_input_t const &y) const
Definition: p2p_integral.hpp:145
NiHu::fmm::p2p_integral
Definition: p2p_integral.hpp:29
NiHu::num_rows
metafunction returning the number of compile time rows
Definition: matrix_traits.hpp:16
NiHu::single_integral
single integral for different element types
Definition: single_integral.hpp:209
NiHu::fmm::fmm_operator
Operator defining its tag type.
Definition: fmm_operator.hpp:85
NiHu::fmm::integral_operator_expression_traits
the traits structure of an integral operator
Definition: integral_operator_expression.hpp:33
local_operator.hpp
Interface of local operator.
integral_operator_expression.hpp
Arithmetics of integral operators.
NiHu::num_cols
metafunction returning the number of compile time columns
Definition: matrix_traits.hpp:41
NiHu::fmm::identity_p2p_operator
Identity operator.
Definition: identity_p2p_operator.h:21