BEM++  2.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Groups Pages
modified_helmholtz_3d_hypersingular_integrand_functor_2.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_2_hpp
22 #define fiber_modified_helmholtz_3d_hypersingular_integrand_functor_2_hpp
23 
24 #include "../common/common.hpp"
25 
26 #include <cassert>
27 #include "collection_of_3d_arrays.hpp"
28 #include "geometrical_data.hpp"
29 #include "conjugate.hpp"
30 
31 namespace Fiber
32 {
33 
36 template <typename BasisFunctionType_, typename KernelType_,
37  typename ResultType_>
39 {
40 public:
41  typedef BasisFunctionType_ BasisFunctionType;
42  typedef KernelType_ KernelType;
43  typedef ResultType_ ResultType;
44  typedef typename ScalarTraits<ResultType>::RealType CoordinateType;
45 
46  void addGeometricalDependencies(size_t& testGeomDeps, size_t& trialGeomDeps) const {
47  testGeomDeps |= NORMALS;
48  trialGeomDeps |= NORMALS;
49  }
50 
51  template <template <typename T> class CollectionOf2dSlicesOfConstNdArrays>
52  ResultType evaluate(
54  const ConstGeometricalDataSlice<CoordinateType>& trialGeomData,
57  const CollectionOf2dSlicesOfConstNdArrays<KernelType>& kernelValues) const {
58  const int dimWorld = 3;
59 
60  // Assert that there are at least two scalar-valued kernels
61  assert(kernelValues.size() >= 2);
62  assert(kernelValues[0].extent(0) == 1);
63  assert(kernelValues[0].extent(1) == 1);
64  assert(kernelValues[1].extent(0) == 1);
65  assert(kernelValues[1].extent(1) == 1);
66 
67  // Assert that there are at least two test and trial transformations
68  // (function value and surface curl) of correct dimensions
69  assert(testTransfValues.size() >= 2);
70  assert(trialTransfValues.size() >= 2);
71  _1dSliceOfConst3dArray<BasisFunctionType> testValues = testTransfValues[0];
72  _1dSliceOfConst3dArray<BasisFunctionType> trialValues = trialTransfValues[0];
73  _1dSliceOfConst3dArray<BasisFunctionType> testSurfaceCurls = testTransfValues[1];
74  _1dSliceOfConst3dArray<BasisFunctionType> trialSurfaceCurls = trialTransfValues[1];
75  assert(testValues.extent(0) == 1);
76  assert(trialValues.extent(0) == 1);
77  assert((int)testSurfaceCurls.extent(0) == dimWorld);
78  assert((int)trialSurfaceCurls.extent(0) == dimWorld);
79 
80  // Let K_0(x, y) = K(x, y) and K_1(x, y) = kappa^2 K(x, y).
81  // Return
82  // K_0(x, y) curl u*(x) . curl v(y) + K_1(x, y) u*(x) v(y) n(x) . n(y)
83 
84  BasisFunctionType dotProduct0 = 0.;
85  for (int dim = 0; dim < dimWorld; ++dim)
86  dotProduct0 += conjugate(testSurfaceCurls(dim)) * trialSurfaceCurls(dim);
87  ResultType term0 = kernelValues[0](0, 0) * dotProduct0;
88  CoordinateType dotProduct1 = 0.;
89  for (int dim = 0; dim < dimWorld; ++dim)
90  dotProduct1 += testGeomData.normal(dim) * trialGeomData.normal(dim);
91  ResultType term1 = kernelValues[1](0, 0) *
92  (dotProduct1 * conjugate(testValues(0)) * trialValues(0));
93  return term0 + term1;
94  }
95 };
96 
97 } // namespace Fiber
98 
99 #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
Functor evaluating the integrand of the hypersingular operator for the modified Helmholtz equation in...
Definition: modified_helmholtz_3d_hypersingular_integrand_functor_2.hpp:38
Access to slices of geometrical data.
Definition: geometrical_data.hpp:88