NiHu  2.0
quad_1_gauss_shape_set.hpp
1 #ifndef QUAD_1_GAUSS_SHAPE_SET_HPP_INCLUDED
2 #define QUAD_1_GAUSS_SHAPE_SET_HPP_INCLUDED
3 
4 #include "../core/shapeset.hpp"
5 #include "lib_domain.hpp"
6 
7 // define the new shape set's traits
8 namespace NiHu
9 {
10 
11 // predefine the new shape set
12 class quad_1_gauss_shape_set;
13 
14 namespace shape_set_traits
15 {
16  // the shape set is defined over the quad domain
17  template <>
19 
20  // it has 4 shapeset nodes
21  template <>
22  struct num_nodes<quad_1_gauss_shape_set> { enum { value = 4 }; };
23 
24  // if used as geometrical shape set, Jacobian is 1-st order in xi/eta
25  template <>
26  struct jacobian_order<quad_1_gauss_shape_set> { enum { value = 1 }; };
27 
28  // N(xi,eta) is first order
29  template <>
30  struct polynomial_order<quad_1_gauss_shape_set> { enum { value = 1 }; };
31 
32  // N(xi, eta) and its derivatives are computed on the fly
33  template <unsigned Order>
35  {
37  };
38 
39  // DOF locations are inside the element (2DOF)
40  template <>
42  {
44  };
45 
46  template <>
48  {
50  };
51 
52 } // end of namespace shape_set_traits
53 
54 
55 // define the new shape set class
57  : public shape_set_base<quad_1_gauss_shape_set>
58 {
60 public:
61 
62  using base_t::corner_at;
63 
64  // return iterator to corners
65  static corner_iterator_t corner_begin_impl()
66  {
67  return m_corners.cbegin();
68  }
69 
70 protected:
71  static const corners_t m_corners;
72 };
73 
74 // define expression for computing the zeroth order derivative N(xi, eta)
75 template <>
77 {
78  typedef shape_set_traits::shape_value_type<quad_1_gauss_shape_set, 0>::type shape_t;
80 public:
81  static shape_t eval(xi_t const &_xi)
82  {
83  auto xi = _xi[0], eta = _xi[1];
84  return ( quad_1_gauss_shape_set::shape_t() <<
85  (1.0 - std::sqrt(3.0)*xi) * (1.0 - std::sqrt(3.0)*eta),
86  (1.0 + std::sqrt(3.0)*xi) * (1.0 - std::sqrt(3.0)*eta),
87  (1.0 - std::sqrt(3.0)*xi) * (1.0 + std::sqrt(3.0)*eta),
88  (1.0 + std::sqrt(3.0)*xi) * (1.0 + std::sqrt(3.0)*eta)
89  ).finished() / 4.0;
90  }
91 };
92 
93 
94 // define expression for computing the first order derivative N(xi, eta)
95 template <>
97 {
98  typedef shape_set_traits::shape_value_type<quad_1_gauss_shape_set, 1>::type shape_t;
100 public:
101  static shape_t eval(xi_t const &_xi)
102  {
103  auto xi = _xi[0], eta = _xi[1];
104  return ( quad_1_gauss_shape_set::dshape_t() <<
105  -std::sqrt(3.0) * (1.0 - std::sqrt(3.0)*eta) , (1.0 - std::sqrt(3.0)*xi) * -std::sqrt(3.0),
106  +std::sqrt(3.0) * (1.0 - std::sqrt(3.0)*eta) , (1.0 + std::sqrt(3.0)*xi) * -std::sqrt(3.0),
107  -std::sqrt(3.0) * (1.0 + std::sqrt(3.0)*eta) , (1.0 - std::sqrt(3.0)*xi) * +std::sqrt(3.0),
108  +std::sqrt(3.0) * (1.0 + std::sqrt(3.0)*eta) , (1.0 + std::sqrt(3.0)*xi) * +std::sqrt(3.0)
109  ).finished() / 4.0;
110  }
111 };
112 
113 } // end of namespace NiHu
114 
115 #endif // QUAD_1_GAUSS_SHAPE_SET_HPP_INCLUDED
NiHu::shape_set_traits::domain
Defines the domain where the shape function set is defined.
Definition: shapeset.hpp:106
NiHu::shape_set_traits::position_dof_vector
defines the nodal degrees of freedoms of the shape functions
Definition: shapeset.hpp:164
tmp::vector
Compile time vector with an arbitrary number of arguments.
Definition: vector.hpp:42
NiHu::shape_set_base
Shapeset base class for CRTP.
Definition: shapeset.hpp:195
NiHu::shape_set_traits::corner_index_vector
Definition: shapeset.hpp:176
NiHu::quad_1_gauss_shape_set
Definition: quad_1_gauss_shape_set.hpp:56
NiHu::shape_set_traits::jacobian_order
Defines the polynomial order of the shape set's Jacobian.
Definition: shapeset.hpp:130
NiHu::matrix_function_complexity::general
the returned matrix should be computed on the fly
Definition: conditional_precompute.hpp:40
lib_domain.hpp
implementation of library domains
NiHu::shape_set_traits::polynomial_order
Defines the polynomial order of the shape set.
Definition: shapeset.hpp:124
NiHu::shape_set_traits::num_nodes
Defines the number of shape functions in the set.
Definition: shapeset.hpp:110
NiHu::quad_domain
a 2D quad domain
Definition: lib_domain.hpp:157
NiHu::shape_function
Definition: shapeset.hpp:82
NiHu::shape_set_base< quad_1_gauss_shape_set >::corner_at
static const xi_t & corner_at(size_t idx)
return corner at a given node number
Definition: shapeset.hpp:255
NiHu::shape_set_traits::shape_complexity
Defines the complexity to determine if the shape functions can be precomputed or not.
Definition: shapeset.hpp:134