BEM++  2.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Groups Pages
modified_maxwell_3d_double_layer_operators_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_maxwell_3d_double_layer_operators_kernel_functor_hpp
22 #define fiber_modified_maxwell_3d_double_layer_operators_kernel_functor_hpp
23 
24 #include "../common/common.hpp"
25 #include "../common/complex_aux.hpp"
26 
27 #include "geometrical_data.hpp"
28 #include "scalar_traits.hpp"
29 
30 #include "modified_helmholtz_3d_single_layer_potential_kernel_functor.hpp"
31 
32 namespace Fiber
33 {
34 
51 template <typename ValueType_>
53 {
54 public:
55  typedef ValueType_ ValueType;
56  typedef typename ScalarTraits<ValueType>::RealType CoordinateType;
57 
59  ValueType waveNumber) :
60  m_waveNumber(waveNumber)
61  {}
62 
63  int kernelCount() const { return 1; }
64  int kernelRowCount(int /* kernelIndex */) const { return 3; }
65  int kernelColCount(int /* kernelIndex */) const { return 1; }
66 
67  void addGeometricalDependencies(size_t& testGeomDeps, size_t& trialGeomDeps) const {
68  testGeomDeps |= GLOBALS;
69  trialGeomDeps |= GLOBALS;
70  }
71 
72  ValueType waveNumber() const { return m_waveNumber; }
73 
74  template <template <typename T> class CollectionOf2dSlicesOfNdArrays>
75  void evaluate(
77  const ConstGeometricalDataSlice<CoordinateType>& trialGeomData,
78  CollectionOf2dSlicesOfNdArrays<ValueType>& result) const {
79  const int coordCount = 3;
80 
81  CoordinateType distanceSq = 0;
82  for (int coordIndex = 0; coordIndex < coordCount; ++coordIndex) {
83  CoordinateType diff = testGeomData.global(coordIndex) -
84  trialGeomData.global(coordIndex);
85  distanceSq += diff * diff;
86  }
87  const CoordinateType distance = sqrt(distanceSq);
88  const ValueType commonFactor =
89  static_cast<CoordinateType>(-1. / (4. * M_PI)) *
90  (static_cast<CoordinateType>(1.) + m_waveNumber * distance) /
91  (distance * distanceSq) *
92  exp(-m_waveNumber * distance);
93  for (int coordIndex = 0; coordIndex < coordCount; ++coordIndex)
94  result[0](coordIndex, 0) = commonFactor *
95  (testGeomData.global(coordIndex) -
96  trialGeomData.global(coordIndex));
97  }
98 
99  CoordinateType estimateRelativeScale(CoordinateType distance) const {
100  return exp(-realPart(m_waveNumber) * distance);
101  }
102 
103 private:
105  ValueType m_waveNumber;
107 };
108 
109 } // namespace Fiber
110 
111 #endif
Traits of scalar types.
Definition: scalar_traits.hpp:40
Kernel collection functor for the DLP of the modified Maxwell equations in 3D.
Definition: modified_maxwell_3d_double_layer_operators_kernel_functor.hpp:52
Access to slices of geometrical data.
Definition: geometrical_data.hpp:88