BEM++  2.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Groups Pages
potential_operator_aca_assembly_helper.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_potential_operator_aca_assembly_helper_hpp
22 #define bempp_potential_operator_aca_assembly_helper_hpp
23 
24 #include "../common/common.hpp"
25 
26 #include "ahmed_aux_fwd.hpp"
27 #include "../common/armadillo_fwd.hpp"
28 #include "../common/shared_ptr.hpp"
29 #include "../common/types.hpp"
30 #include "../fiber/scalar_traits.hpp"
31 
32 #include <tbb/atomic.h>
33 #include <vector>
34 
36 class cluster;
39 namespace Fiber
40 {
41 
43 template <typename ResultType> class LocalAssemblerForPotentialOperators;
46 } // namespace Fiber
47 
48 namespace Bempp
49 {
50 
52 class EvaluationOptions;
53 class ComponentListsCache;
54 template <typename ResultType> class DiscreteBoundaryOperator;
55 template <typename BasisFunctionType> class LocalDofListsCache;
56 template <typename BasisFunctionType> class Space;
62 template <typename BasisFunctionType, typename ResultType>
64 {
65 public:
68  typedef typename Fiber::ScalarTraits<ResultType>::RealType CoordinateType;
69  typedef CoordinateType MagnitudeType;
70  typedef typename AhmedTypeTraits<ResultType>::Type AhmedResultType;
71 
73  const arma::Mat<CoordinateType>& points,
74  const Space<BasisFunctionType>& trialSpace,
75  const std::vector<unsigned int>& p2oPoints,
76  const std::vector<unsigned int>& p2oTrialDofs,
77  const std::vector<LocalAssembler*>& assemblers,
78  const std::vector<ResultType>& termMultipliers,
79  const EvaluationOptions& options);
80 
85  void cmpbl(unsigned b1, unsigned n1, unsigned b2, unsigned n2,
86  AhmedResultType* data,
87  const cluster* c1 = 0, const cluster* c2 = 0,
88  bool countAccessedEntries = true) const;
89 
94  void cmpblsym(unsigned b1, unsigned n1, AhmedResultType* data,
95  const cluster* c1 = 0,
96  bool countAccessedEntries = true) const;
97 
99  MagnitudeType scale(unsigned b1, unsigned n1, unsigned b2, unsigned n2,
100  const cluster* c1 = 0, const cluster* c2 = 0) const;
101 
104  MagnitudeType relativeScale(unsigned b1, unsigned n1, unsigned b2, unsigned n2,
105  const cluster* c1 = 0, const cluster* c2 = 0) const;
106 
109  size_t accessedEntryCount() const;
110 
114 
115 private:
116  MagnitudeType estimateMinimumDistance(
117  const cluster* c1, const cluster* c2) const;
118 
119 private:
121  const arma::Mat<CoordinateType>& m_points;
122  const Space<BasisFunctionType>& m_trialSpace;
123  const std::vector<unsigned int>& m_p2oPoints;
124  const std::vector<unsigned int>& m_p2oTrialDofs;
125  const std::vector<LocalAssembler*>& m_assemblers;
126  const std::vector<ResultType>& m_termMultipliers;
127  const EvaluationOptions& m_options;
128  bool m_indexWithGlobalDofs; // redundant (stored also in m_options),
129  // but often needed
130  unsigned int m_componentCount;
131 
132  shared_ptr<ComponentListsCache> m_componentListsCache;
133  shared_ptr<LocalDofListsCache<BasisFunctionType> >
134  m_trialDofListsCache;
135 
136  mutable tbb::atomic<size_t> m_accessedEntryCount;
138 };
139 
140 } // namespace Bempp
141 
142 #endif
Traits of scalar types.
Definition: scalar_traits.hpp:40
size_t accessedEntryCount() const
Return the number of entries in the matrix that have been accessed so far.
Definition: potential_operator_aca_assembly_helper.cpp:375
Options controlling evaluation of potentials.
Definition: evaluation_options.hpp:44
MagnitudeType scale(unsigned b1, unsigned n1, unsigned b2, unsigned n2, const cluster *c1=0, const cluster *c2=0) const
Expected size of the entries in this block.
Definition: potential_operator_aca_assembly_helper.cpp:327
Function space.
Definition: assembled_potential_operator.hpp:35
void resetAccessedEntryCount()
Reset the number of entries in the matrix that have been accessed so far.
Definition: potential_operator_aca_assembly_helper.cpp:383
Abstract interface of a local assembler for potential operators.
Definition: local_assembler_for_potential_operators.hpp:54
MagnitudeType relativeScale(unsigned b1, unsigned n1, unsigned b2, unsigned n2, const cluster *c1=0, const cluster *c2=0) const
Expected magnitude of the largest entry in this block relative to that of the largest entry in the wh...
Definition: potential_operator_aca_assembly_helper.cpp:358
Class whose methods are called by Ahmed during assembly in the ACA mode.
Definition: potential_operator_aca_assembly_helper.hpp:63
Discrete boundary operator.
Definition: assembled_potential_operator.hpp:33
void cmpblsym(unsigned b1, unsigned n1, AhmedResultType *data, const cluster *c1=0, bool countAccessedEntries=true) const
Evaluate entries of a symmetric block.
Definition: potential_operator_aca_assembly_helper.cpp:307
void cmpbl(unsigned b1, unsigned n1, unsigned b2, unsigned n2, AhmedResultType *data, const cluster *c1=0, const cluster *c2=0, bool countAccessedEntries=true) const
Evaluate entries of a general block.
Definition: potential_operator_aca_assembly_helper.cpp:127