BEM++  2.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Groups Pages
lagrange_scalar_shapeset.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_lagrange_scalar_shapeset_hpp
22 #define fiber_lagrange_scalar_shapeset_hpp
23 
24 #include "../common/common.hpp"
25 
26 #include "basis.hpp"
27 
28 #include "basis_data.hpp"
29 #include "dune_basis_helper.hpp"
30 
31 #include <dune/localfunctions/lagrange/pk2d/pk2dlocalbasis.hh>
32 
33 namespace Fiber
34 {
35 
36 // So far, this shapeset is only implemented for triangular elements.
37 // In future it may be extended to quadrilaterals and lines.
38 
39 template <int elementVertexCount, typename CoordinateType, typename ValueType,
40  int polynomialOrder>
42 {
43 };
44 
45 // Triangle
46 template <typename CoordinateType, typename ValueType, int polynomialOrder>
47 struct LagrangeScalarBasisTraits<3, CoordinateType, ValueType, polynomialOrder>
48 {
49 public:
50  typedef Dune::Pk2DLocalBasis<CoordinateType, ValueType, polynomialOrder>
51  DuneShapeset;
52  typedef DuneShapeset DuneBasis;
53 };
54 
56 template <int elementVertexCount, typename ValueType, int polynomialOrder>
57 class LagrangeScalarShapeset : public Basis<ValueType>
58 {
59 public:
60  typedef typename Basis<ValueType>::CoordinateType CoordinateType;
61 
62 private:
63  typedef typename LagrangeScalarBasisTraits<
64  elementVertexCount, CoordinateType, ValueType, polynomialOrder>::DuneShapeset
65  DuneBasis;
66  DuneBasis m_duneBasis;
67 
68 public:
69  virtual int size() const {
70  return m_duneBasis.size();
71  }
72 
73  virtual int order() const {
74  return polynomialOrder;
75  }
76 
77  virtual void evaluate(size_t what,
78  const arma::Mat<CoordinateType>& points,
79  LocalDofIndex localDofIndex,
80  BasisData<ValueType>& data) const {
81  if (localDofIndex != ALL_DOFS &&
82  (localDofIndex < 0 || size() <= localDofIndex))
83  throw std::invalid_argument("LagrangeScalarShapeset::"
84  "evaluate(): Invalid localDofIndex");
85 
86  if (what & VALUES)
87  evaluateShapeFunctionsWithDune<CoordinateType, ValueType, DuneBasis>(
88  points, localDofIndex, data.values, m_duneBasis);
89  if (what & DERIVATIVES)
90  evaluateShapeFunctionDerivativesWithDune<
91  CoordinateType, ValueType, DuneBasis>(
92  points, localDofIndex, data.derivatives, m_duneBasis);
93  }
94 };
95 
96 } // namespace Fiber
97 
98 #endif
_4dArray< ValueType > derivatives
Derivatives of shape functions.
Definition: basis_data.hpp:59
virtual int order() const
Return the maximum polynomial order of shape functions.
Definition: lagrange_scalar_shapeset.hpp:73
Definition: lagrange_scalar_shapeset.hpp:41
_3dArray< ValueType > values
Values of shape functions.
Definition: basis_data.hpp:51
virtual int size() const
Return the number of shape functions.
Definition: lagrange_scalar_shapeset.hpp:69
Collection of shape functions defined on a reference element.
Definition: basis.hpp:36
Storage of values and/or derivatives of shape functions.
Definition: basis_data.hpp:44
Shapeset composed of the Lagrange polynomials up to a specified order.
Definition: lagrange_scalar_shapeset.hpp:57
virtual void evaluate(size_t what, const arma::Mat< CoordinateType > &points, LocalDofIndex localDofIndex, BasisData< ValueType > &data) const
Evaluate the shape functions making up this shapeset and/or their derivatives at specified points...
Definition: lagrange_scalar_shapeset.hpp:77