BEM++  2.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Groups Pages
modified_helmholtz_3d_double_layer_potential_kernel_interpolated_functor.hpp
1 // Copyright (C) 2011-2012 by the BEM++ Authors
2 //
3 // Permission is hereby granted, free of charge, to any person obtaining a copy
4 // of this software and associated documentation files (the "Software"), to deal
5 // in the Software without restriction, including without limitation the rights
6 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 // copies of the Software, and to permit persons to whom the Software is
8 // furnished to do so, subject to the following conditions:
9 //
10 // The above copyright notice and this permission notice shall be included in
11 // all copies or substantial portions of the Software.
12 //
13 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19 // THE SOFTWARE.
20 
21 #ifndef fiber_modified_helmholtz_3d_double_layer_potential_kernel_interpolated_functor_hpp
22 #define fiber_modified_helmholtz_3d_double_layer_potential_kernel_interpolated_functor_hpp
23 
24 #include "../common/common.hpp"
25 
26 #include "geometrical_data.hpp"
27 #include "hermite_interpolator.hpp"
28 #include "initialize_interpolator_for_modified_helmholtz_3d_kernels.hpp"
29 #include "scalar_traits.hpp"
30 
31 #include "../common/complex_aux.hpp"
32 
33 namespace Fiber
34 {
35 
51 template <typename ValueType_>
53 {
54 public:
55  typedef ValueType_ ValueType;
56  typedef typename ScalarTraits<ValueType>::RealType CoordinateType;
57 
59  ValueType waveNumber,
60  CoordinateType maxDist, int interpPtsPerWavelength) :
61  m_waveNumber(waveNumber)
62  {
63  initializeInterpolatorForModifiedHelmholtz3dKernels(
64  waveNumber, maxDist, interpPtsPerWavelength, m_interpolator);
65  }
66 
67  int kernelCount() const { return 1; }
68  int kernelRowCount(int /* kernelIndex */) const { return 1; }
69  int kernelColCount(int /* kernelIndex */) const { return 1; }
70 
71  void addGeometricalDependencies(size_t& testGeomDeps, size_t& trialGeomDeps) const {
72  testGeomDeps |= GLOBALS;
73  trialGeomDeps |= GLOBALS | NORMALS;
74  }
75 
76  ValueType waveNumber() const { return m_waveNumber; }
77 
78  template <template <typename T> class CollectionOf2dSlicesOfNdArrays>
79  void evaluate(
81  const ConstGeometricalDataSlice<CoordinateType>& trialGeomData,
82  CollectionOf2dSlicesOfNdArrays<ValueType>& result) const {
83  const int coordCount = 3;
84 
85  CoordinateType numeratorSum = 0., distSq = 0.;
86  for (int coordIndex = 0; coordIndex < coordCount; ++coordIndex)
87  {
88  CoordinateType diff = trialGeomData.global(coordIndex) -
89  testGeomData.global(coordIndex);
90  distSq += diff * diff;
91  numeratorSum += diff * trialGeomData.normal(coordIndex);
92  }
93  CoordinateType dist = sqrt(distSq);
94  ValueType v = m_interpolator.evaluate(dist);
95  result[0](0, 0) = numeratorSum /
96  (static_cast<CoordinateType>(-4.0 * M_PI) * distSq * dist) *
97  (m_waveNumber * dist + static_cast<CoordinateType>(1.0)) * v;
98  }
99 
100  CoordinateType estimateRelativeScale(CoordinateType distance) const {
101  // This function is called rarely, invoking exp() here does little harm.
102  return exp(-realPart(m_waveNumber) * distance);
103  }
104 
105 private:
107  ValueType m_waveNumber;
108  HermiteInterpolator<ValueType> m_interpolator;
110 };
111 
112 } // namespace Fiber
113 
114 #endif
Traits of scalar types.
Definition: scalar_traits.hpp:40
Definition: hermite_interpolator.hpp:15
Double-layer-potential kernel functor for the modified Helmholtz equation in 3D.
Definition: modified_helmholtz_3d_double_layer_potential_kernel_interpolated_functor.hpp:52
Access to slices of geometrical data.
Definition: geometrical_data.hpp:88