BEM++  2.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Groups Pages
modified_helmholtz_3d_single_layer_potential_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_single_layer_potential_kernel_functor_hpp
22 #define fiber_modified_helmholtz_3d_single_layer_potential_kernel_functor_hpp
23 
24 #include "../common/common.hpp"
25 
26 #include "geometrical_data.hpp"
27 #include "scalar_traits.hpp"
28 
29 #include "../common/complex_aux.hpp"
30 
31 namespace Fiber
32 {
33 
47 template <typename ValueType_>
49 {
50 public:
51  typedef ValueType_ ValueType;
52  typedef typename ScalarTraits<ValueType>::RealType CoordinateType;
53 
54  explicit ModifiedHelmholtz3dSingleLayerPotentialKernelFunctor(ValueType waveNumber) :
55  m_waveNumber(waveNumber)
56  {}
57 
58  int kernelCount() const { return 1; }
59  int kernelRowCount(int /* kernelIndex */) const { return 1; }
60  int kernelColCount(int /* kernelIndex */) const { return 1; }
61 
62  void addGeometricalDependencies(size_t& testGeomDeps, size_t& trialGeomDeps) const {
63  testGeomDeps |= GLOBALS;
64  trialGeomDeps |= GLOBALS;
65  }
66 
67  ValueType waveNumber() const { return m_waveNumber; }
68 
69  template <template <typename T> class CollectionOf2dSlicesOfNdArrays>
70  void evaluate(
72  const ConstGeometricalDataSlice<CoordinateType>& trialGeomData,
73  CollectionOf2dSlicesOfNdArrays<ValueType>& result) const {
74  const int coordCount = 3;
75 
76  CoordinateType sum = 0;
77  for (int coordIndex = 0; coordIndex < coordCount; ++coordIndex)
78  {
79  CoordinateType diff = testGeomData.global(coordIndex) -
80  trialGeomData.global(coordIndex);
81  sum += diff * diff;
82  }
83  CoordinateType distance = sqrt(sum);
84  result[0](0, 0) =
85  static_cast<CoordinateType>(1.0 / (4.0 * M_PI)) / distance *
86  exp(-m_waveNumber * distance);
87  }
88 
89  CoordinateType estimateRelativeScale(CoordinateType distance) const {
90  return exp(-realPart(m_waveNumber) * distance);
91  }
92 
93 private:
94  ValueType m_waveNumber;
95 };
96 
97 } // namespace Fiber
98 
99 #endif
Traits of scalar types.
Definition: scalar_traits.hpp:40
Single-layer-potential kernel functor for the modified Helmholtz equation in 3D.
Definition: modified_helmholtz_3d_single_layer_potential_kernel_functor.hpp:48
Access to slices of geometrical data.
Definition: geometrical_data.hpp:88