BEM++  2.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Groups Pages
modified_helmholtz_3d_hypersingular_integrand_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_integrand_functor_hpp
22 #define fiber_modified_helmholtz_3d_hypersingular_integrand_functor_hpp
23 
24 #include "../common/common.hpp"
25 #include "../common/deprecated.hpp"
26 
27 #include "collection_of_3d_arrays.hpp"
28 #include "geometrical_data.hpp"
29 #include "conjugate.hpp"
30 #include "geometrical_data.hpp"
31 
32 #include <cassert>
33 
34 namespace Fiber
35 {
36 
42 template <typename BasisFunctionType_, typename KernelType_,
43  typename ResultType_>
45 {
46 public:
47  typedef BasisFunctionType_ BasisFunctionType;
48  typedef KernelType_ KernelType;
49  typedef ResultType_ ResultType;
50  typedef typename ScalarTraits<ResultType>::RealType CoordinateType;
51 
53  KernelType waveNumber) :
54  m_waveNumber(waveNumber)
55  {}
56 
57  void addGeometricalDependencies(size_t& testGeomDeps, size_t& trialGeomDeps) const {
58  testGeomDeps |= NORMALS;
59  trialGeomDeps |= NORMALS;
60  }
61 
62  KernelType waveNumber() const { return m_waveNumber; }
63 
64  // It is possible that this function could be generalised to
65  // multiple shape transformations or kernels and that the additional
66  // loops could be optimised away by the compiler.
67  template <template <typename T> class CollectionOf2dSlicesOfConstNdArrays>
68  ResultType BEMPP_DEPRECATED evaluate(
70  const ConstGeometricalDataSlice<CoordinateType>& trialGeomData,
73  const CollectionOf2dSlicesOfConstNdArrays<KernelType>& kernelValues) const {
74  const int dimWorld = 3;
75 
76  // Assert that there is at least one scalar-valued kernel
77  assert(kernelValues.size() >= 1);
78  assert(kernelValues[0].extent(0) == 1);
79  assert(kernelValues[0].extent(1) == 1);
80 
81  // Assert that there are at least two test and trial transformations
82  // (function value and surface curl) of correct dimensions
83  assert(testTransfValues.size() >= 2);
84  assert(trialTransfValues.size() >= 2);
85  _1dSliceOfConst3dArray<BasisFunctionType> testValues = testTransfValues[0];
86  _1dSliceOfConst3dArray<BasisFunctionType> trialValues = trialTransfValues[0];
87  _1dSliceOfConst3dArray<BasisFunctionType> testSurfaceCurls = testTransfValues[1];
88  _1dSliceOfConst3dArray<BasisFunctionType> trialSurfaceCurls = trialTransfValues[1];
89  assert(testValues.extent(0) == 1);
90  assert(trialValues.extent(0) == 1);
91  assert((int)testSurfaceCurls.extent(0) == dimWorld);
92  assert((int)trialSurfaceCurls.extent(0) == dimWorld);
93 
94  // K(x, y) [kappa^2 u*(x) v(y) n(x) . n(y) + curl u*(x) . curl v(y)]
95 
96  ResultType result = 0.;
97  for (int dim = 0; dim < dimWorld; ++dim)
98  result += testGeomData.normal(dim) * trialGeomData.normal(dim);
99  result *= m_waveNumber * m_waveNumber *
100  conjugate(testValues(0)) * trialValues(0);
101  for (int dim = 0; dim < dimWorld; ++dim)
102  result += conjugate(testSurfaceCurls(dim)) *
103  trialSurfaceCurls(dim);
104  result *= kernelValues[0](0, 0);
105  return result;
106  }
107 
108 private:
109  KernelType m_waveNumber;
110 };
111 
112 } // namespace Fiber
113 
114 #endif
Traits of scalar types.
Definition: scalar_traits.hpp:40
Definition: collection_of_3d_arrays.hpp:151
Lightweight encapsulation of a 1D slice of a constant 3D array.
Definition: _3d_array.hpp:185
#define BEMPP_DEPRECATED
Macro used to mark deprecated functions or classes.
Definition: deprecated.hpp:41
Functor evaluating the integrand of the hypersingular operator for the modified Helmholtz equation in...
Definition: modified_helmholtz_3d_hypersingular_integrand_functor.hpp:44
Access to slices of geometrical data.
Definition: geometrical_data.hpp:88