BEM++  2.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Groups Pages
surface_curl_3d_functor.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_surface_curl_3d_functor_hpp
22 #define fiber_surface_curl_3d_functor_hpp
23 
24 #include "../common/common.hpp"
25 
26 #include "basis_data.hpp"
27 #include "geometrical_data.hpp"
28 #include "collection_of_3d_arrays.hpp"
29 #include "shape_transformation_functor_wrappers.hpp"
30 
31 #include <boost/array.hpp>
32 
33 namespace Fiber
34 {
35 
36 template <typename CoordinateType_>
38 {
39 public:
40  typedef CoordinateType_ CoordinateType;
41 
42  int argumentDimension() const { return 1; }
43  int resultDimension() const { return 3; }
44 
45  void addDependencies(size_t& basisDeps, size_t& geomDeps) const {
46  basisDeps |= DERIVATIVES;
47  geomDeps |= NORMALS | JACOBIAN_INVERSES_TRANSPOSED;
48  }
49 
50  template <typename ValueType>
51  void evaluate(
52  const ConstBasisDataSlice<ValueType>& basisData,
54  _1dSliceOf3dArray<ValueType>& result) const {
55  assert(basisData.componentCount() == 1);
56  assert(geomData.dimWorld() == 3);
57 
58  // vec := gradient of the shape function extended outside
59  // the surface so that its normal derivative on the surf. is zero
60  boost::array<ValueType, 3> vec;
61  vec[0] = basisData.derivatives(0, 0) * geomData.jacobianInverseTransposed(0, 0) +
62  basisData.derivatives(0, 1) * geomData.jacobianInverseTransposed(0, 1);
63  vec[1] = basisData.derivatives(0, 0) * geomData.jacobianInverseTransposed(1, 0) +
64  basisData.derivatives(0, 1) * geomData.jacobianInverseTransposed(1, 1);
65  vec[2] = basisData.derivatives(0, 0) * geomData.jacobianInverseTransposed(2, 0) +
66  basisData.derivatives(0, 1) * geomData.jacobianInverseTransposed(2, 1);
67 
68  // result := n \times vec
69  result(0) = geomData.normal(1) * vec[2] - geomData.normal(2) * vec[1];
70  result(1) = geomData.normal(2) * vec[0] - geomData.normal(0) * vec[2];
71  result(2) = geomData.normal(0) * vec[1] - geomData.normal(1) * vec[0];
72  }
73 };
74 
75 // Note: in C++11 we'll be able to make a "template typedef", or more precisely
76 // a using declaration, instead of this spurious inheritance
79 template <typename CoordinateType_>
82  SurfaceCurl3dElementaryFunctor<CoordinateType_> >
83 {
84 public:
85  typedef CoordinateType_ CoordinateType;
86 };
87 
88 } // namespace Fiber
89 
90 #endif
Definition: shape_transformation_functor_wrappers.hpp:33
int componentCount() const
Return the number of components of the function.
Definition: basis_data.hpp:111
Functor calculating the surface curl of a scalar field in 3D.
Definition: surface_curl_3d_functor.hpp:80
Definition: surface_curl_3d_functor.hpp:37
Lightweight encapsulation of a 1D slice of a 3D array.
Definition: _3d_array.hpp:155
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
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