BEM++  2.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Groups Pages
basis_data.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_basis_data_hpp
22 #define fiber_basis_data_hpp
23 
24 #include "../common/common.hpp"
25 
26 #include "../common/armadillo_fwd.hpp"
27 #include "../common/multidimensional_arrays.hpp"
28 
29 namespace Fiber
30 {
31 
32 enum BasisDataType
33 {
34  VALUES = 0x0001,
35  DERIVATIVES = 0x0002
36 };
37 
39 template <typename ValueType> class ConstBasisDataSlice;
43 template <typename ValueType>
44 struct BasisData
45 {
52 
60 
62  int componentCount() const {
63  return std::max<int>(values.extent(0), derivatives.extent(0));
64  }
65 
67  int functionCount() const {
68  return std::max<int>(values.extent(1), derivatives.extent(2));
69  }
70 
73  int pointCount() const {
74  return std::max<int>(values.extent(2), derivatives.extent(3));
75  }
76 
79  ConstBasisDataSlice<ValueType> const_slice(int function, int point) const {
80  return ConstBasisDataSlice<ValueType>(*this, function, point);
81  }
82 
83 };
84 
90 template <typename ValueType>
92 {
93 public:
96  int function, int point) :
97  m_basisData(basisData), m_function(function), m_point(point) {}
98 
100  ValueType values(int dim) const {
101  return m_basisData.values(dim, m_function, m_point);
102  }
103 
106  ValueType derivatives(int dim, int direction) const {
107  return m_basisData.derivatives(dim, direction, m_function, m_point);
108  }
109 
111  int componentCount() const {
112  return m_basisData.componentCount();
113  }
114 
115 private:
116  const BasisData<ValueType>& m_basisData;
117  int m_function, m_point;
118 };
119 
120 } // namespace Fiber
121 
122 #endif // BASIS_DATA_TYPES_HPP
int functionCount() const
Return number of shape functions.
Definition: basis_data.hpp:67
_4dArray< ValueType > derivatives
Derivatives of shape functions.
Definition: basis_data.hpp:59
int componentCount() const
Return the number of components of the function.
Definition: basis_data.hpp:111
ConstBasisDataSlice< ValueType > const_slice(int function, int point) const
Return a constant slice of the data, corresponding to a given shape function and point.
Definition: basis_data.hpp:79
int pointCount() const
Return number of points at which the shape functions have been calculated.
Definition: basis_data.hpp:73
int componentCount() const
Return number of components of shape functions.
Definition: basis_data.hpp:62
_3dArray< ValueType > values
Values of shape functions.
Definition: basis_data.hpp:51
ValueType derivatives(int dim, int direction) const
Return the value of the dim&#39;th component of the derivative of the function in a given direction...
Definition: basis_data.hpp:106
ValueType values(int dim) const
Return the value of the dim&#39;th component of the function.
Definition: basis_data.hpp:100
ConstBasisDataSlice(const BasisData< ValueType > &basisData, int function, int point)
Constructor.
Definition: basis_data.hpp:95
Storage of values and/or derivatives of shape functions.
Definition: basis_data.hpp:44
Access to values and/or derivatives of shape functions.
Definition: basis_data.hpp:91