NiHu  2.0
gauss_field_view.hpp
1 #ifndef NIHU_GAUSS_FIELD_VIEW_HPP_INCLUDED
2 #define NIHU_GAUSS_FIELD_VIEW_HPP_INCLUDED
3 
4 #include "core/field.hpp"
5 
6 #include "line_1_gauss_field.hpp"
7 #include "quad_1_gauss_shape_set.hpp"
8 #include "tria_1_gauss_shape_set.hpp"
9 
10 namespace NiHu
11 {
12 
17 namespace field_option
18 {
20  struct gauss {};
21 } // namespace NiHu::field_option
22 
23 namespace field_traits
24 {
25 
26 namespace internal
27 {
31  template <class Domain>
32  struct assign_gauss_shape;
33 
34  template <>
35  struct assign_gauss_shape<line_domain>
36  {
37  typedef line_1_gauss_shape_set type;
38  };
39 
40  template <>
41  struct assign_gauss_shape<tria_domain>
42  {
43  typedef tria_1_gauss_shape_set type;
44  };
45 
46  template <>
47  struct assign_gauss_shape<quad_domain>
48  {
49  typedef quad_1_gauss_shape_set type;
50  };
51 } // namespace NiHu::field_traits::internal
52 
53 
57 template <class ElemType, class Dimension>
58 struct nset_type<field_view<ElemType, field_option::gauss, Dimension> >
59 {
60  typedef typename internal::assign_gauss_shape<typename ElemType::domain_t>::type type;
61 };
62 } // namespace NiHu::field_traits
63 
69 template <class ElemType, class Dimension>
70 class field_impl<field_view<ElemType, field_option::gauss, Dimension> > :
71  public ElemType
72 {
74  typedef typename field_traits::dof_vector_type<Derived>::type dofs_t;
75  typedef typename field_traits::dof_vector_return_type<Derived>::type dofs_return_t;
76  typedef typename field_traits::eval_return_type<Derived>::type eval_return_t;
77  typedef typename field_traits::nset_type<Derived>::type nset_t;
78  typedef typename ElemType::xi_t xi_t;
79 public:
80 
81  eval_return_t eval(xi_t const &xi) const
82  {
83  return nset_t::template eval_shape<0>(xi);
84  }
85 
86 
88  ElemType const &get_elem() const
89  {
90  return *this; // static cast
91  }
92 
94  dofs_return_t get_dofs() const
95  {
96  // TODO: in an inhomogeneous mesh, dof assignment is more complex!
97  enum { D = Dimension::value * shape_set_traits::num_nodes<nset_t>::value };
98  return dofs_t::LinSpaced(D, ElemType::get_id()(0)*D, ElemType::get_id()(0)*D + D - 1);
99  }
100 };
101 
102 template <class Elem, class Dimension = field_dimension::_1d>
103 field_view<Elem, field_option::gauss, Dimension> const &
104 gauss_view(element_base<Elem> const &e, Dimension dim = Dimension())
105 {
106  return create_field_view(e, field_option::gauss(), dim);
107 }
108 
109 } // namespace NiHu
110 
111 #endif /* NIHU_GAUSS_FIELD_VIEW_HPP_INCLUDED */
NiHu::line_1_gauss_shape_set
Definition: line_1_gauss_shape_set.hpp:77
NiHu::field_impl
implementation class of a general field
Definition: field.hpp:170
NiHu::field_traits::dof_vector_return_type
assign the DOF vector return type to the field type
Definition: field.hpp:94
NiHu::field_impl< field_view< ElemType, field_option::gauss, Dimension > >::get_elem
const ElemType & get_elem() const
return underlying element
Definition: gauss_field_view.hpp:88
NiHu::field_option::gauss
tag to describe a gauss field
Definition: gauss_field_view.hpp:20
NiHu::field_traits::nset_type
assigns the N-set type to the field
Definition: field.hpp:56
NiHu::line_domain
a 1D line domain
Definition: lib_domain.hpp:53
field.hpp
implementation of fields and field views
NiHu::field_view
Field automatically generated from an element using a field generation option.
Definition: field.hpp:222
NiHu::shape_set_traits::num_nodes
Defines the number of shape functions in the set.
Definition: shapeset.hpp:110
NiHu::field_impl< field_view< ElemType, field_option::gauss, Dimension > >::get_dofs
dofs_return_t get_dofs() const
return DOF vector
Definition: gauss_field_view.hpp:94