BEM++  2.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Groups Pages
shape_transformation_functor_wrappers.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_shape_transformation_functor_wrappers_hpp
22 #define fiber_shape_transformation_functor_wrappers_hpp
23 
24 #include "basis_data.hpp"
25 #include "geometrical_data.hpp"
26 #include "collection_of_3d_arrays.hpp"
27 
28 namespace Fiber
29 {
30 
31 // ElementaryFunctor must be default-constructible
32 template <typename ElementaryFunctor>
34 {
35 public:
36  typedef typename ElementaryFunctor::CoordinateType CoordinateType;
37 
38  size_t transformationCount() const {
39  return 1;
40  }
41 
42  int argumentDimension() const {
43  return m_functor.argumentDimension();
44  }
45 
46  int resultDimension(size_t transformationIndex) const {
47  assert(transformationIndex == 0);
48  return m_functor.resultDimension();
49  }
50 
51  void addDependencies(size_t& basisDeps, size_t& geomDeps) const {
52  m_functor.addDependencies(basisDeps, geomDeps);
53  }
54 
55  template <typename ValueType>
56  void evaluate(
57  const ConstBasisDataSlice<ValueType>& basisData,
60  m_functor.evaluate(basisData, geomData, result[0].self());
61  }
62 
63 private:
64  ElementaryFunctor m_functor;
65 };
66 
67 // ElementaryFunctors must be default-constructible
68 template <typename ElementaryFunctor0, typename ElementaryFunctor1>
70 {
71 public:
72  typedef typename ElementaryFunctor0::CoordinateType CoordinateType;
73  // TODO: check that ElementaryFunctor1 has the same CoordinateType
74 
75  int transformationCount() const {
76  return 2;
77  }
78 
79  int argumentDimension() const {
80  int result = m_functor0.argumentDimension();
81  assert(result == m_functor1.argumentDimension());
82  return result;
83  }
84 
85  int resultDimension(int transformationIndex) const {
86  switch (transformationIndex) {
87  case 0: return m_functor0.resultDimension();
88  case 1: return m_functor1.resultDimension();
89  default: throw std::invalid_argument(
90  "BasisFunctionTransformationElementaryFunctorPairWrapper::"
91  "resultDimension(): invalid transformation index");
92  }
93  }
94 
95  void addDependencies(size_t& basisDeps, size_t& geomDeps) const {
96  m_functor0.addDependencies(basisDeps, geomDeps);
97  m_functor1.addDependencies(basisDeps, geomDeps);
98  }
99 
100  template <typename ValueType>
101  void evaluate(
102  const ConstBasisDataSlice<ValueType>& basisData,
105  m_functor0.evaluate(basisData, geomData, result[0].self());
106  m_functor1.evaluate(basisData, geomData, result[1].self());
107  }
108 
109 private:
110  ElementaryFunctor0 m_functor0;
111  ElementaryFunctor1 m_functor1;
112 };
113 
114 } // namespace Fiber
115 
116 #endif
Definition: shape_transformation_functor_wrappers.hpp:33
Definition: shape_transformation_functor_wrappers.hpp:69
Definition: collection_of_3d_arrays.hpp:121
Access to slices of geometrical data.
Definition: geometrical_data.hpp:88
Access to values and/or derivatives of shape functions.
Definition: basis_data.hpp:91