BEM++  2.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Groups Pages
modified_helmholtz_3d_hypersingular_off_diagonal_interpolated_kernel_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_hypersingular_off_diagonal_interpolated_kernel_functor_hpp
22 #define fiber_modified_helmholtz_3d_hypersingular_off_diagonal_interpolated_kernel_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 
52 template <typename ValueType_>
54 {
55 public:
56  typedef ValueType_ ValueType;
57  typedef typename ScalarTraits<ValueType>::RealType CoordinateType;
58 
60  ValueType waveNumber,
61  CoordinateType maxDist, int interpPtsPerWavelength) :
62  m_waveNumber(waveNumber)
63  {
64  initializeInterpolatorForModifiedHelmholtz3dKernels(
65  waveNumber, maxDist, interpPtsPerWavelength, m_interpolator);
66  }
67 
68  int kernelCount() const { return 1; }
69  int kernelRowCount(int /* kernelIndex */) const { return 1; }
70  int kernelColCount(int /* kernelIndex */) const { return 1; }
71 
72  void addGeometricalDependencies(size_t& testGeomDeps, size_t& trialGeomDeps) const {
73  testGeomDeps |= GLOBALS | NORMALS;
74  trialGeomDeps |= GLOBALS | NORMALS;
75  }
76 
77  ValueType waveNumber() const { return m_waveNumber; }
78 
79  template <template <typename T> class CollectionOf2dSlicesOfNdArrays>
80  void evaluate(
82  const ConstGeometricalDataSlice<CoordinateType>& trialGeomData,
83  CollectionOf2dSlicesOfNdArrays<ValueType>& result) const {
84  const int coordCount = 3;
85  const ValueType waveNumber = m_waveNumber;
86 
87  CoordinateType distanceSq = 0.;
88  CoordinateType nTest_diff = 0;
89  CoordinateType nTrial_diff = 0;
90  CoordinateType nTest_nTrial = 0.;
91  for (int coordIndex = 0; coordIndex < coordCount; ++coordIndex) {
92  CoordinateType diff = trialGeomData.global(coordIndex) -
93  testGeomData.global(coordIndex);
94  distanceSq += diff * diff;
95  nTest_diff += diff * testGeomData.normal(coordIndex);
96  nTrial_diff += diff * trialGeomData.normal(coordIndex);
97  nTest_nTrial += testGeomData.normal(coordIndex) *
98  trialGeomData.normal(coordIndex);
99  }
100  CoordinateType distance = sqrt(distanceSq);
101  ValueType kr = waveNumber * distance;
102  ValueType v = m_interpolator.evaluate(distance);
103  const CoordinateType ONE = 1., THREE = 3.;
104  result[0](0, 0) =
105  static_cast<CoordinateType>(1.0 / (4.0 * M_PI)) /
106  (distance * distanceSq * distanceSq) *
107  (-distanceSq * nTest_nTrial * (ONE + kr) +
108  nTest_diff * nTrial_diff *
109  (THREE + THREE * kr + kr * kr)) * v;
110  }
111 
112  CoordinateType estimateRelativeScale(CoordinateType distance) const {
113  return exp(-realPart(m_waveNumber) * distance);
114  }
115 
116 private:
118  ValueType m_waveNumber;
119  HermiteInterpolator<ValueType> m_interpolator;
121 };
122 
123 } // namespace Fiber
124 
125 #endif
Traits of scalar types.
Definition: scalar_traits.hpp:40
Kernel functor for the hypersingular operator associated with the modified Helmholtz equation in 3D...
Definition: modified_helmholtz_3d_hypersingular_off_diagonal_interpolated_kernel_functor.hpp:53
Definition: hermite_interpolator.hpp:15
Access to slices of geometrical data.
Definition: geometrical_data.hpp:88