NiHu  2.0
convected_helmholtz_3d_nearly_singular_integrals.hpp
1 #ifndef NIHU_CONVECTED_HELMHOLTZ_3D_NEARLY_SINGULAR_INTEGRALS_HPP_INCLUDED
2 #define NIHU_CONVECTED_HELMHOLTZ_3D_NEARLY_SINGULAR_INTEGRALS_HPP_INCLUDED
3 
5 
6 #include "convected_helmholtz_3d_kernel.hpp"
7 #include "core/formalism.hpp"
8 #include "nearly_singular_collocational_telles.hpp"
9 
10 #define NIHU_MEX_DEBUGGING 0
11 
12 
13 #if NIHU_MEX_DEBUGGING
14 #include "mex.h"
15 #endif
16 
17 namespace NiHu
18 {
19 
20 // Convected 3D DLP
21 template <class TestField, class TrialField, class WaveNumber>
23  convected_helmholtz_3d_DLP_kernel<WaveNumber>, TestField, TrialField,
24  typename std::enable_if<
25  is_collocational<TestField, TrialField>::value
26  >::type
27 >
28 {
30  typedef typename kernel_t::test_input_t test_input_t;
31  typedef TestField test_field_t;
32  typedef typename test_field_t::nset_t test_nset_t;
33  static unsigned const num_test_nodes = test_nset_t::num_nodes;
34 
35 public:
36  static bool needed(
37  kernel_base<kernel_t> const &kernel,
38  field_base<TestField> const &test_field,
39  field_base<TrialField> const &trial_field
40  )
41  {
42  double const limit = 1.5;
43 
44  // distance between element centres
45  double d = (test_field.get_elem().get_center() - trial_field.get_elem().get_center()).norm();
46  double R = trial_field.get_elem().get_linear_size_estimate();
47 
48  return d/R < limit;
49  }
50 
51  template <class result_t>
52  static result_t &eval(
53  result_t &result,
54  kernel_base<kernel_t> const &kernel,
55  field_base<TestField> const &test_field,
56  field_base<TrialField> const &trial_field
57  )
58  {
60  nsc_t nsc(trial_field, kernel);
61 
62  #if NIHU_MEX_DEBUGGING
63  static bool printed = false;
64  if (!printed) {
65  mexPrintf("Nearly singular Telles for convected DLP\n");
66  printed = true;
67  }
68  #endif
69 
70  for (unsigned i = 0; i < num_test_nodes; ++i)
71  {
72  test_input_t tsti(test_field.get_elem(), test_nset_t::corner_at(i));
73  nsc.integrate(result.row(i), tsti);
74  }
75 
76  return result;
77  }
78 };
79 
80 
81 // Convected 3D DLPt
82 template <class TestField, class TrialField, class WaveNumber>
84  convected_helmholtz_3d_DLPt_kernel<WaveNumber>, TestField, TrialField,
85  typename std::enable_if<
86  is_collocational<TestField, TrialField>::value
87  >::type
88 >
89 {
91  typedef typename kernel_t::test_input_t test_input_t;
92  typedef TestField test_field_t;
93  typedef typename test_field_t::nset_t test_nset_t;
94  static unsigned const num_test_nodes = test_nset_t::num_nodes;
95 
96 public:
97  static bool needed(
98  kernel_base<kernel_t> const &kernel,
99  field_base<TestField> const &test_field,
100  field_base<TrialField> const &trial_field
101  )
102  {
103  double const limit = 1.5;
104 
105  // distance between element centres
106  double d = (test_field.get_elem().get_center() - trial_field.get_elem().get_center()).norm();
107  double R = trial_field.get_elem().get_linear_size_estimate();
108 
109  return d/R < limit;
110  }
111 
112  template <class result_t>
113  static result_t &eval(
114  result_t &result,
115  kernel_base<kernel_t> const &kernel,
116  field_base<TestField> const &test_field,
117  field_base<TrialField> const &trial_field
118  )
119  {
121  nsc_t nsc(trial_field, kernel);
122 
123  #if NIHU_MEX_DEBUGGING
124  static bool printed = false;
125  if (!printed) {
126  mexPrintf("Nearly singular Telles for convected DLPt\n");
127  printed = true;
128  }
129  #endif
130 
131 
132  for (unsigned i = 0; i < num_test_nodes; ++i)
133  {
134  test_input_t tsti(test_field.get_elem(), test_nset_t::corner_at(i));
135  nsc.integrate(result.row(i), tsti);
136  }
137 
138  return result;
139  }
140 };
141 
142 
143 // HSP
144 template <class TestField, class TrialField, class WaveNumber>
146  convected_helmholtz_3d_HSP_kernel<WaveNumber>, TestField, TrialField,
147  typename std::enable_if<
148  is_collocational<TestField, TrialField>::value
149  >::type
150 >
151 {
153  typedef typename kernel_t::test_input_t test_input_t;
154  typedef TestField test_field_t;
155  typedef typename test_field_t::nset_t test_nset_t;
156  static unsigned const num_test_nodes = test_nset_t::num_nodes;
157 
158 public:
159  static bool needed(
160  kernel_base<kernel_t> const &kernel,
161  field_base<TestField> const &test_field,
162  field_base<TrialField> const &trial_field
163  )
164  {
165  double const limit = 1.5;
166 
167  // distance between element centres
168  double d = (test_field.get_elem().get_center() - trial_field.get_elem().get_center()).norm();
169  double R = trial_field.get_elem().get_linear_size_estimate();
170 
171  return d/R < limit;
172  }
173 
174  template <class result_t>
175  static result_t &eval(
176  result_t &result,
177  kernel_base<kernel_t> const &kernel,
178  field_base<TestField> const &test_field,
179  field_base<TrialField> const &trial_field
180  )
181  {
183  nsc_t nsc(trial_field, kernel);
184 
185  #if NIHU_MEX_DEBUGGING
186  static bool printed = false;
187  if (!printed) {
188  mexPrintf("Nearly singular Telles for convected HSP\n");
189  printed = true;
190  }
191  #endif
192 
193  for (unsigned i = 0; i < num_test_nodes; ++i)
194  {
195  test_input_t tsti(test_field.get_elem(), test_nset_t::corner_at(i));
196  nsc.integrate(result.row(i), tsti);
197  }
198 
199  return result;
200  }
201 };
202 
203 } // namespace NiHu
204 
205 #endif /* NIHU_CONVECTED_HELMHOLTZ_3D_NEARLY_SINGULAR_INTEGRALS_HPP_INCLUDED */
formalism.hpp
return weak form formalism from the test and trial field types
NiHu::convected_helmholtz_3d_DLP_kernel
Definition: convected_helmholtz_3d_kernel.hpp:177
nearly_singular_integral.hpp
Nearly singular integral general case.
NiHu::kernel_base< kernel_t >
NiHu::nearly_singular_integral
Definition: nearly_singular_integral.hpp:27
NiHu::nearly_singular_collocational_telles
Definition: nearly_singular_collocational_telles.hpp:116
NiHu::convected_helmholtz_3d_DLPt_kernel
Definition: convected_helmholtz_3d_kernel.hpp:319
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::convected_helmholtz_3d_HSP_kernel
Definition: convected_helmholtz_3d_kernel.hpp:478