BEM++  2.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Groups Pages
weak_form_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_weak_form_aca_assembly_helper_hpp
22 #define bempp_weak_form_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 <tbb/concurrent_unordered_map.h>
34 #include <vector>
35 
37 class cluster;
40 namespace Fiber
41 {
42 
44 template <typename ResultType> class LocalAssemblerForIntegralOperators;
47 } // namespace Fiber
48 
49 namespace Bempp
50 {
51 
53 class AssemblyOptions;
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 typename Fiber::ScalarTraits<ResultType>::RealType MagnitudeType;
70  typedef typename AhmedTypeTraits<ResultType>::Type AhmedResultType;
71 
73  const Space<BasisFunctionType>& trialSpace,
74  const std::vector<unsigned int>& p2oTestDofs,
75  const std::vector<unsigned int>& p2oTrialDofs,
76  const std::vector<LocalAssembler*>& assemblers,
77  const std::vector<const DiscreteLinOp*>& sparseTermsToAdd,
78  const std::vector<ResultType>& denseTermsMultipliers,
79  const std::vector<ResultType>& sparseTermsMultipliers,
80  const AssemblyOptions& options);
81 
86  void cmpbl(unsigned b1, unsigned n1, unsigned b2, unsigned n2,
87  AhmedResultType* data,
88  const cluster* c1 = 0, const cluster* c2 = 0,
89  bool countAccessedEntries = true) const;
90 
95  void cmpblsym(unsigned b1, unsigned n1, AhmedResultType* data,
96  const cluster* c1 = 0,
97  bool countAccessedEntries = true) const;
98 
100  MagnitudeType scale(unsigned b1, unsigned n1, unsigned b2, unsigned n2,
101  const cluster* c1 = 0, const cluster* c2 = 0) const;
102 
105  MagnitudeType relativeScale(unsigned b1, unsigned n1, unsigned b2, unsigned n2,
106  const cluster* c1 = 0, const cluster* c2 = 0) const;
107 
110  size_t accessedEntryCount() const;
111 
115 
116 private:
117  MagnitudeType estimateMinimumDistance(
118  const cluster* c1, const cluster* c2) const;
119 
120 private:
122  const Space<BasisFunctionType>& m_testSpace;
123  const Space<BasisFunctionType>& m_trialSpace;
124  const std::vector<unsigned int>& m_p2oTestDofs;
125  const std::vector<unsigned int>& m_p2oTrialDofs;
126  const std::vector<LocalAssembler*>& m_assemblers;
127  const std::vector<const DiscreteLinOp*>& m_sparseTermsToAdd;
128  const std::vector<ResultType>& m_denseTermsMultipliers;
129  const std::vector<ResultType>& m_sparseTermsMultipliers;
130  const AssemblyOptions& m_options;
131  bool m_indexWithGlobalDofs;
132  bool m_uniformQuadratureOrder;
133 
134  shared_ptr<LocalDofListsCache<BasisFunctionType> >
135  m_testDofListsCache, m_trialDofListsCache;
136 
137  mutable tbb::atomic<size_t> m_accessedEntryCount;
138 
139  typedef tbb::concurrent_unordered_map<
140  std::pair<const cluster*, const cluster*>, CoordinateType> DistanceMap;
141  mutable DistanceMap m_distancesCache;
142 
144 };
145 
146 } // namespace Bempp
147 
148 #endif
Traits of scalar types.
Definition: scalar_traits.hpp:40
void cmpblsym(unsigned b1, unsigned n1, AhmedResultType *data, const cluster *c1=0, bool countAccessedEntries=true) const
Evaluate entries of a symmetric block.
Definition: weak_form_aca_assembly_helper.cpp:387
Class whose methods are called by Ahmed during assembly in the ACA mode.
Definition: weak_form_aca_assembly_helper.hpp:63
Function space.
Definition: assembled_potential_operator.hpp:35
size_t accessedEntryCount() const
Return the number of entries in the matrix that have been accessed so far.
Definition: weak_form_aca_assembly_helper.cpp:454
MagnitudeType scale(unsigned b1, unsigned n1, unsigned b2, unsigned n2, const cluster *c1=0, const cluster *c2=0) const
Expected magnitude of the entries in this block.
Definition: weak_form_aca_assembly_helper.cpp:407
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: weak_form_aca_assembly_helper.cpp:145
Abstract interface of a local assembler for integral operators.
Definition: local_assembler_for_integral_operators.hpp:48
Discrete boundary operator.
Definition: assembled_potential_operator.hpp:33
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: weak_form_aca_assembly_helper.cpp:437
void resetAccessedEntryCount()
Reset the number of entries in the matrix that have been accessed so far.
Definition: weak_form_aca_assembly_helper.cpp:462
Options determining how weak-form assembly is done.
Definition: assembly_options.hpp:43