BEM++  2.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Groups Pages
nonseparable_numerical_test_kernel_trial_integrator.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_nonseparable_numerical_test_kernel_trial_integrator_hpp
22 #define fiber_nonseparable_numerical_test_kernel_trial_integrator_hpp
23 
24 #include "../common/common.hpp"
25 
26 #include "test_kernel_trial_integrator.hpp"
27 
28 #include <tbb/concurrent_unordered_map.h>
29 #include <tbb/enumerable_thread_specific.h>
30 
31 namespace Fiber
32 {
33 
35 class OpenClHandler;
36 template <typename CoordinateType> class CollectionOfShapesetTransformations;
37 template <typename ValueType> class CollectionOfKernels;
38 template <typename CoordinateType> class RawGridGeometry;
39 template <typename BasisFunctionType, typename KernelType, typename ResultType>
40 class TestKernelTrialIntegral;
44 template <typename BasisFunctionType, typename KernelType,
45  typename ResultType, typename GeometryFactory>
47  public TestKernelTrialIntegrator<BasisFunctionType, KernelType, ResultType>
48 {
49 public:
51  typedef typename Base::CoordinateType CoordinateType;
52  typedef typename Base::ElementIndexPair ElementIndexPair;
53 
55  const arma::Mat<CoordinateType>& localTestQuadPoints,
56  const arma::Mat<CoordinateType>& localTrialQuadPoints,
57  const std::vector<CoordinateType> quadWeights,
58  const GeometryFactory& testGeometryFactory,
59  const GeometryFactory& trialGgeometryFactory,
60  const RawGridGeometry<CoordinateType>& testRawGeometry,
61  const RawGridGeometry<CoordinateType>& trialRawGeometry,
62  const CollectionOfShapesetTransformations<CoordinateType>& testTransformations,
63  const CollectionOfKernels<KernelType>& kernel,
64  const CollectionOfShapesetTransformations<CoordinateType>& trialTransformations,
66  const OpenClHandler& openClHandler);
68 
69  virtual void integrate(
70  CallVariant callVariant,
71  const std::vector<int>& elementIndicesA,
72  int elementIndexB,
73  const Shapeset<BasisFunctionType>& basisA,
74  const Shapeset<BasisFunctionType>& basisB,
75  LocalDofIndex localDofIndexB,
76  const std::vector<arma::Mat<ResultType>*>& result) const;
77 
78  virtual void integrate(
79  const std::vector<ElementIndexPair>& elementIndexPairs,
80  const Shapeset<BasisFunctionType>& testShapeset,
81  const Shapeset<BasisFunctionType>& trialShapeset,
82  const std::vector<arma::Mat<ResultType>*>& result) const;
83 
84 private:
85  enum ElementType {TEST, TRIAL};
86 
88  basisData(ElementType type, const Shapeset<BasisFunctionType>& shapeset) const;
89 
90  arma::Mat<CoordinateType> m_localTestQuadPoints;
91  arma::Mat<CoordinateType> m_localTrialQuadPoints;
92  std::vector<CoordinateType> m_quadWeights;
93 
94  const GeometryFactory& m_testGeometryFactory;
95  const GeometryFactory& m_trialGeometryFactory;
96  const RawGridGeometry<CoordinateType>& m_testRawGeometry;
97  const RawGridGeometry<CoordinateType>& m_trialRawGeometry;
98 
99  const CollectionOfShapesetTransformations<CoordinateType>& m_testTransformations;
100  const CollectionOfKernels<KernelType>& m_kernels;
101  const CollectionOfShapesetTransformations<CoordinateType>& m_trialTransformations;
103 
104  typedef tbb::concurrent_unordered_map<const Shapeset<BasisFunctionType>*,
105  BasisData<BasisFunctionType>* > BasisDataCache;
106  mutable BasisDataCache m_cachedTestBasisData;
107  mutable BasisDataCache m_cachedTrialBasisData;
108 
109  const OpenClHandler& m_openClHandler;
110  // thread-local static data for integrate() -- allocation and deallocation of GeometricalData
111  // is very time-consuming due to the presence of arma::Cube objects.
112  mutable tbb::enumerable_thread_specific<GeometricalData<CoordinateType> >
113  m_testGeomData, m_trialGeomData;
114 };
115 
116 } // namespace Fiber
117 
118 #include "nonseparable_numerical_test_kernel_trial_integrator_imp.hpp"
119 
120 #endif
Integration over pairs of elements.
Definition: test_kernel_trial_integrator.hpp:42
Integration over pairs of elements on non-tensor-product point grids.
Definition: nonseparable_numerical_test_kernel_trial_integrator.hpp:46
Collection of shape functions defined on a reference element.
Definition: default_local_assembler_for_operators_on_surfaces_utilities.hpp:34
Definition: default_local_assembler_for_operators_on_surfaces_utilities.hpp:35
Storage of values and/or derivatives of shape functions.
Definition: basis_data.hpp:44
Definition: opencl_handler.hpp:208