Go to the documentation of this file.
28 #ifndef NIHU_FIELD_HPP_INCLUDED
29 #define NIHU_FIELD_HPP_INCLUDED
31 #include "../util/crtp_base.hpp"
32 #include "corner_angle.hpp"
34 #include "field_dimension.hpp"
40 namespace field_option
48 namespace field_traits
51 template <
class Derived>
55 template <
class Derived>
59 template <
class Derived>
63 template <
class Derived>
67 template <
class Derived>
71 template <
class Derived>
82 template <
class Derived>
85 typedef Eigen::Matrix<
93 template <
class Derived>
95 is_dof_vector_stored<Derived>::value,
96 typename dof_vector_type<Derived>::type const &,
97 typename dof_vector_type<Derived>::type
101 template <
class Derived>
110 template <
class Derived>
122 typedef typename elem_t::x_t
x_t;
128 typedef typename field_traits::dof_vector_type<Derived>::type
dofs_t;
132 typedef typename field_traits::eval_return_type<Derived>::type eval_return_t;
143 eval_return_t eval(
xi_t const &xi)
const
145 return derived().eval(xi);
151 return derived().get_elem();
157 return derived().get_dofs();
160 double get_corner_angle(
unsigned nset_corner_idx)
const
169 template <
class Derived>
174 template <
class Field>
177 namespace field_traits
179 template <
class Derived>
182 template <
class Derived>
185 template <
class Derived>
188 template <
class Derived>
196 template <
class Field>
215 using impl_t::get_elem;
216 using impl_t::get_dofs;
221 template <
class ElemType,
class FieldOption,
class Dimension = field_dimension::_1d>
224 namespace field_traits
227 template <
class ElemType,
class FieldOption,
class Dimension>
231 template <
class ElemType,
class Dimension>
234 typedef typename ElemType::lset_t type;
238 template <
class ElemType,
class Dimension>
245 template <
class ElemType,
class FieldOption,
class Dimension>
255 template <
class ElemType,
class Dimension>
260 typedef typename field_traits::dof_vector_type<Derived>::type dofs_t;
262 typedef typename field_traits::eval_return_type<Derived>::type eval_return_t;
264 typedef typename ElemType::xi_t xi_t;
267 eval_return_t eval(xi_t
const &xi)
const
269 return nset_t::template eval_shape<0>(xi);
282 enum { D = Dimension::value };
284 for (
unsigned n = 0; n < ElemType::num_nodes; ++n)
285 for (
unsigned d = 0; d < D; ++d)
286 dofs(n*D + d) = ElemType::get_nodes()(n)*D + d;
298 template <
class ElemType,
class Dimension>
304 typedef typename field_traits::dof_vector_type<Derived>::type dofs_t;
306 typedef typename field_traits::eval_return_type<Derived>::type eval_return_t;
308 typedef typename ElemType::xi_t xi_t;
311 eval_return_t eval(xi_t
const &xi)
const
313 return nset_t::template eval_shape<0>(xi);
325 enum { D = Dimension::value };
326 return dofs_t::LinSpaced(D, ElemType::get_id()(0)*D, ElemType::get_id()(0)*D + D - 1);
336 template <
class ElemType,
class Option,
class Dimension>
338 public field_base<field_view<ElemType, Option, Dimension> >,
339 public field_impl<field_view<ElemType, Option, Dimension> >
342 typedef field_base<field_view<ElemType, Option, Dimension> > crtp_base_t;
344 typedef field_impl<field_view<ElemType, Option, Dimension> > impl_t;
360 using impl_t::get_elem;
361 using impl_t::get_dofs;
366 template <
class ElemType,
class NSet,
class Dimension>
370 namespace field_traits
373 template <
class ElemType,
class NSet,
class Dimension>
377 template <
class ElemType,
class NSet,
class Dimension>
384 template <
class ElemType,
class NSet,
class Dimension>
394 template <
class ElemType,
class NSet,
class Dimension>
403 typedef typename ElemType::xi_t
xi_t;
405 typedef typename field_traits::dof_vector_type<Derived>::type
dofs_t;
409 typedef typename field_traits::eval_return_type<Derived>::type eval_return_t;
416 m_elem(elem.derived()), m_dofs(dofs)
420 eval_return_t eval(xi_t
const &xi)
const
422 return NSet::template eval_shape<0>(xi);
449 template <
class ElemType,
class NSet,
class Dimension = field_dimension::_1d>
451 public field_base<field<ElemType, NSet, Dimension> >,
452 public field_impl<field<ElemType, NSet, Dimension> >
482 template <
class Elem,
class Option,
class Dimension = field_dimension::_1d>
483 field_view<Elem, Option, Dimension>
const &
495 template <
class Field>
499 namespace field_traits
501 template <
class Field>
504 template <
class Field>
507 template <
class Field>
510 template <
class Field>
521 template <
class Field>
523 public field_base<directional_derivative_field<Field>>
550 template <
class Direction>
553 , m_direction(direction.derived())
564 double dx_xi = dx.col(0).norm();
565 double dx_eta = dx.col(1).norm();
566 x_t s = dx.col(0).normalized();
567 x_t t_eta = dx.col(1).normalized();
568 x_t n = s.cross(t_eta).normalized();
571 x_t const &m = m_direction;
572 double a = (s.dot(m) - s.dot(t_eta) / t.dot(t_eta) * t.dot(m)) / dx_xi;
573 double b = t.dot(m) / t.dot(t_eta) / dx_eta;
575 auto dN = nset_t::template eval_shape<1>(xi);
576 return a * dN.col(0) + b * dN.col(1);
582 return m_field.get_elem();
588 return m_field.get_dofs();
592 Field
const &m_field;
593 x_t const &m_direction;
602 template <
class Field,
class Direction>
603 directional_derivative_field<Field>
611 template <
class Elem,
class Dimension = field_dimension::_1d>
612 field_view<Elem, field_option::constant, Dimension>
const &
619 template <
class Elem,
class Dimension = field_dimension::_1d>
620 field_view<Elem, field_option::isoparametric, Dimension>
const &
627 template <
class Field>
628 dirac_field<Field>
const &
637 #endif // NIHU_FIELD_HPP_INCLUDED
field_traits::elem_type< Derived >::type elem_t
the element type
Field field_t
store the original field type for the iterator
crtp_base_t::nset_t nset_t
the field shape set type
dofs_return_t get_dofs() const
implementation class of a general field
tag to describe a constant field
ElemType::xi_t xi_t
the intrinsic location type
assign the DOF vector return type to the field type
crtp_base_t::dofs_return_t dofs_return_t
the return type for the dof vector
field< ElemType, NSet, Dimension > Derived
the derived field type
crtp_base_t::elem_t elem_t
the element type
const ElemType & get_elem() const
return underlying element
const elem_t & get_elem() const
return underlying element
const field_view< Elem, field_option::constant, Dimension > & constant_view(element_base< Elem > const &e, Dimension dim=Dimension())
constant field view factory
assign the DOF vector value type to the field type
field_impl(element_base< elem_t > const &elem, dofs_t const &dofs)
constructor from element and dof vector
field_impl< field< ElemType, NSet, Dimension > > impl_t
the implementation class type
indicate if the field stores its DOF vector or computes it on the fly
dirac_field type
self-returning metafunction
field class that computes the directional derivative of a field
field_view type
self-returning metafunction
field_impl< Field > impl_t
the implementation class type
assigns the N-set type to the field
#define NIHU_CRTP_HELPERS
define CRTP helper function
tag to describe an isoparametric field
field class that stores the dof vector and an element by value
assign a numeric ID to the field
dofs_return_t get_dofs() const
return DOF vector
field(element_base< elem_t > const &elem, dofs_t const &dofs)
constructor from element and dof vector
directional_derivative_field< Field > directional_derivative(field_base< Field > const &field, Eigen::MatrixBase< Direction > const &direction)
factory function to create a directional derivative field
field type
self-returning metafunction
const field_view< Elem, field_option::isoparametric, Dimension > & isoparametric_view(element_base< Elem > const &e, Dimension dim=Dimension())
isoparametric field view factory
assigns the dimensionality of the interpolated physical quantity
dofs_return_t get_dofs() const
return the dofs vector
the field class that stores the dof vector and the element by value
base_t::elem_t elem_t
the element type
const field_view< Elem, Option, Dimension > & create_field_view(element_base< Elem > const &e, Option, Dimension dim=Dimension())
field view factory
field_traits::dof_vector_type< Derived >::type dofs_t
the dof vector type
assigns the element type to the field
Constant interpolation functions.
ElemType elem_t
the element type
NIHU_CRTP_HELPERS typedef Derived type
self returning metafunction
crtp_base_t::eval_return_t eval_return_t
the return type of the eval function
elem_t m_elem
the element part by value
dofs_return_t get_dofs() const
return DOF vector
const elem_t & get_elem() const
return underlying element
CRTP base class of all fields.
field_traits::dof_vector_type< Derived >::type dofs_t
the dofs vector type
field_base< directional_derivative_field< Field > > crtp_base_t
the crtp base type
directional_derivative_field(Field const &field, Eigen::MatrixBase< Direction > const &direction)
contruct a directional derivative field instance
field_traits::dof_vector_return_type< Derived >::type dofs_return_t
the dof vector type
field_base< field< ElemType, NSet, Dimension > > base_t
the CRTP base type
elem_t::x_t x_t
the element location type
Declaration of element classes.
crtp_base_t::x_t x_t
the physical location type
Defines the return type of the shape function matrix.
crtp_base_t::elem_t elem_t
the element type shorthand
@ quantity_dimension
the quantity's dimensionality
dofs_return_t get_dofs() const
return DOF vector
domain_t::xi_t xi_t
type of the shape functions' independent variable
directional_derivative_field type
self-returning metafunction
field_traits::elem_type< dirac_field< Field > >::type elem_t
shorthand for the element type
Field automatically generated from an element using a field generation option.
crtp_base_t::xi_t xi_t
the intrinsic location type
base_t::dofs_t dofs_t
the dofs vector type
Defines the value type of the shape function matrix (and derivatives)
const ElemType & get_elem() const
return underlying element
field_traits::nset_type< Derived >::type nset_t
the nset type
const elem_t & get_elem() const
return the element
eval_return_t eval(xi_t const &xi) const
evaluate the directional derivative field
@ num_dofs
the number of dofs
return type of the eval method
The geometrical element representation.
const dirac_field< Field > & dirac(field_base< Field > const &f)
dirac field view factory
indicate if the field is a Dirac field or not
dofs_t m_dofs
the dofs vector part by value
elem_t::xi_t xi_t
the intrinsic coordinate type
field_traits::dof_vector_return_type< Derived >::type dofs_return_t
the dofs vector return type