BEM++  2.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Groups Pages
component_lists_cache.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 bempp_component_lists_cache_hpp
22 #define bempp_component_lists_cache_hpp
23 
24 #include "../common/common.hpp"
25 #include "../common/shared_ptr.hpp"
26 #include "../common/types.hpp"
27 
28 #include <tbb/concurrent_unordered_map.h>
29 #include <vector>
30 #include <iostream>
31 
32 namespace Bempp
33 {
34 
36 template <typename BasisFunctionType> class Space;
44 {
45  std::vector<int> pointIndices;
46  std::vector<std::vector<int> > componentIndices;
47  std::vector<std::vector<int> > arrayIndices;
48 };
49 
54 {
55 public:
56  ComponentListsCache(const std::vector<unsigned int>& p2o,
57  int componentCount);
59 
62  shared_ptr<const ComponentLists> get(
63  int start, int indexCount);
64 
65 private:
66  void findComponents(
67  int start,
68  int indexCount,
69  std::vector<int>& pointIndices,
70  std::vector<std::vector<int> >& componentIndices,
71  std::vector<std::vector<int> >& arrayIndices) const;
72 
73  void findComponents(
74  int index,
75  std::vector<int>& pointIndices,
76  std::vector<std::vector<int> >& componentIndices,
77  std::vector<std::vector<int> >& arrayIndices) const;
78 
79 private:
81  const std::vector<unsigned int>& m_p2o;
82  int m_componentCount;
83 
84  typedef tbb::concurrent_unordered_map<std::pair<int, int>,
85  const ComponentLists*> ComponentListsMap;
86  ComponentListsMap m_map;
88 };
89 
90 } // namespace Bempp
91 
92 #endif
Data used by PotentialOperatorAcaAssemblyHelper to convert between H-matrix indices, point and component indices.
Definition: component_lists_cache.hpp:43
Cache of ComponentLists objects.
Definition: component_lists_cache.hpp:53