BEM++  2.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Groups Pages
ahmed_aux.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_ahmed_aux_hpp
22 #define bempp_ahmed_aux_hpp
23 
24 #include "../common/common.hpp"
25 
26 // to ensure there are no inconsistent forward declarations
27 #include "ahmed_aux_fwd.hpp"
28 
29 #include "ahmed_leaf_cluster_array.hpp"
30 #include "ahmed_mblock_array_deleter.hpp"
31 #include "../common/types.hpp"
32 #include "../common/bounding_box.hpp"
33 
34 #include "../common/boost_scoped_array_fwd.hpp"
35 #include "../common/boost_shared_array_fwd.hpp"
36 #include <complex>
37 #include <iostream>
38 #include <memory>
39 #include <stdexcept>
40 
41 // Ahmed's include files
42 
43 #ifdef __INTEL_COMPILER
44 #pragma warning(disable:381)
45 #endif
46 
47 #include "ahmed_complex.hpp"
48 #include "extended_bem_cluster.hpp"
49 
50 #include <bbxbemblcluster.h>
51 #include <bllist.h>
52 // #include <matgen_sqntl.h>
53 // #define _OPENMP
54 // #include <matgen_omp.h>
55 // #undef _OPENMP
56 
57 bool multaHvec_omp(double d, blcluster* bl, mblock<double>** A, double* x,
58  double* y);
59 
60 #include <matrix.h>
61 #undef SIGN
62 #undef SQR
63 #undef MIN
64 #undef MAX
65 
66 template <typename T>
67 T MIN(T x, T y)
68 {
69  return std::min(x, y);
70 }
71 
72 template <typename T>
73 T MAX(T x, T y)
74 {
75  return std::max(x, y);
76 }
77 
78 #ifdef __INTEL_COMPILER
79 #pragma warning(default:381)
80 #endif
81 
82 
83 namespace Bempp
84 {
85 
87 template <typename CoordinateType>
88 // struct AhmedDofWrapper : public Point3D<CoordinateType>
89 struct AhmedDofWrapper : public BoundingBox<CoordinateType>
90 {
91  // Methods required by the AHMED clustering code
92 
93  CoordinateType getcenter(int i) const {
94  if (i == 0) return this->reference.x;
95  else if (i == 1) return this->reference.y;
96  else return this->reference.z;
97  }
98 
99  CoordinateType getlbound(int i) const {
100  if (i == 0) return this->lbound.x;
101  else if (i == 1) return this->lbound.y;
102  else return this->lbound.z;
103  }
104 
105  CoordinateType getubound(int i) const {
106  if (i == 0) return this->ubound.x;
107  else if (i == 1) return this->ubound.y;
108  else return this->ubound.z;
109  }
110 };
111 
112 template <typename ValueType>
113 boost::shared_array<mblock<typename AhmedTypeTraits<ValueType>::Type>*>
114 allocateAhmedMblockArray(size_t blockCount)
115 {
116  typedef mblock<typename AhmedTypeTraits<ValueType>::Type> AhmedMblock;
117  AhmedMblock** blocks = 0;
118  allocmbls(blockCount, blocks);
119  return boost::shared_array<AhmedMblock*>(
120  blocks, AhmedMblockArrayDeleter(blockCount));
121 }
122 
123 template <typename ValueType>
124 boost::shared_array<mblock<typename AhmedTypeTraits<ValueType>::Type>*>
125 allocateAhmedMblockArray(const blcluster* cluster)
126 {
127  return allocateAhmedMblockArray<ValueType>(cluster->nleaves());
128 }
129 
130 } // namespace Bempp
131 
132 #endif
Point3D< CoordinateType > ubound
Upper bound.
Definition: bounding_box.hpp:20
Point3D< CoordinateType > lbound
Lower bound.
Definition: bounding_box.hpp:18
Point3D< CoordinateType > reference
Reference point.
Definition: bounding_box.hpp:16
Bounding box with a reference point.
Definition: bounding_box.hpp:13
Definition: ahmed_mblock_array_deleter.hpp:35
An Ahmed-compatible degree-of-freedom type.
Definition: ahmed_aux.hpp:89