Rheolef  7.1
an efficient C++ finite element environment
basis_fem_Pk_bernstein.cc
Go to the documentation of this file.
22 #include "basis_fem_Pk_lagrange.h"
23 #include "piola_fem_lagrange.h"
24 #include "rheolef/rheostream.h"
25 #include "equispaced.icc"
26 #include "warburton.icc"
27 #include "eigen_util.h"
29 
30 namespace rheolef {
31 using namespace std;
32 
33 // =========================================================================
34 // basis members
35 // =========================================================================
36 template<class T>
38 {
39 }
40 template<class T>
42  : basis_rep<T> (sopt),
43  _raw_basis("B"+itos(degree)),
44  _hat_node(),
45  _vdm(),
46  _inv_vdm()
47 {
48  // Bezier nodes are equispaced => forced
52 
53  // piola FEM transformation:
54  typedef piola_fem_lagrange<T> piola_fem_type;
55  base::_piola_fem.piola_fem<T>::base::operator= (new_macro(piola_fem_type));
56 }
57 template<class T>
58 void
60 {
62  degree(),
63  base::is_continuous(),
64  base::_ndof_on_subgeo,
65  base::_nnod_on_subgeo,
66  base::_first_idof_by_dimension,
67  base::_first_inod_by_dimension);
68 }
69 template<class T>
70 const Eigen::Matrix<point_basic<T>,Eigen::Dynamic,1>&
72 {
73  base::_initialize_data_guard (hat_K);
74  return _hat_node [hat_K.variant()];
75 }
76 template<class T>
77 const Eigen::Matrix<T,Eigen::Dynamic,Eigen::Dynamic>&
79 {
80  base::_initialize_data_guard (hat_K);
81  return _vdm [hat_K.variant()];
82 }
83 template<class T>
84 const Eigen::Matrix<T,Eigen::Dynamic,Eigen::Dynamic>&
86 {
87  base::_initialize_data_guard (hat_K);
88  return _inv_vdm [hat_K.variant()];
89 }
90 template<class T>
91 void
93 {
94  // initialization is similar to Pk-Lagrange
95  size_type k = degree();
96  size_type variant = hat_K.variant();
97 
98  // nodes:
99  switch (base::_sopt.get_node()) {
101  pointset_lagrange_equispaced (hat_K, k, _hat_node[variant]);
102  break;
104  pointset_lagrange_warburton (hat_K, k, _hat_node[variant]); break;
105  default: error_macro ("unsupported node set: "<<base::_sopt.get_node_name());
106  }
107  // vdm:
108  details::basis_on_pointset_evaluate (_raw_basis, hat_K, _hat_node[variant], _vdm[variant]);
109  check_macro (invert(_vdm[variant], _inv_vdm[variant]),
110  "unisolvence failed for " << base::name() <<"(" << hat_K.name() << ") basis");
111 }
112 // evaluation of all basis functions at hat_x:
113 template<class T>
114 void
116  reference_element hat_K,
117  const point_basic<T>& hat_x,
118  Eigen::Matrix<T,Eigen::Dynamic,1>& value) const
119 {
120  base::_initialize_data_guard (hat_K);
121  _raw_basis.evaluate (hat_K, hat_x, value);
122 }
123 // evaluate the gradient:
124 template<class T>
125 void
127  reference_element hat_K,
128  const point_basic<T>& hat_x,
129  Eigen::Matrix<point_basic<T>,Eigen::Dynamic,1>& value) const
130 {
131  base::_initialize_data_guard (hat_K);
132  _raw_basis.grad_evaluate (hat_K, hat_x, value);
133 }
134 // dofs for a scalar-valued function
135 template<class T>
136 void
138  reference_element hat_K,
139  const Eigen::Matrix<T,Eigen::Dynamic,1>& f_xnod,
140  Eigen::Matrix<T,Eigen::Dynamic,1>& dof) const
141 {
142  base::_initialize_data_guard (hat_K);
143  dof = _inv_vdm[hat_K.variant()]*f_xnod;
144 }
145 // ----------------------------------------------------------------------------
146 // instanciation in library
147 // ----------------------------------------------------------------------------
148 #define _RHEOLEF_instanciation(T) \
149 template class basis_fem_Pk_bernstein<T>;
150 
152 
153 }// namespace rheolef
see the Float page for the full documentation
basis_fem_Pk_bernstein(size_type degree, const basis_option &sopt)
const Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic > & vdm(reference_element hat_K) const
void evaluate(reference_element hat_K, const point_basic< T > &hat_x, Eigen::Matrix< T, Eigen::Dynamic, 1 > &value) const
void grad_evaluate(reference_element hat_K, const point_basic< T > &hat_x, Eigen::Matrix< point_basic< T >, Eigen::Dynamic, 1 > &value) const
void _compute_dofs(reference_element hat_K, const Eigen::Matrix< T, Eigen::Dynamic, 1 > &f_xnod, Eigen::Matrix< T, Eigen::Dynamic, 1 > &dof) const
const Eigen::Matrix< point_basic< T >, Eigen::Dynamic, 1 > & hat_node(reference_element hat_K) const
const Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic > & inv_vdm(reference_element hat_K) const
void _initialize_data(reference_element hat_K) const
static void initialize_local_first(size_type k, bool is_continuous, std::array< std::array< size_type, reference_element::max_variant >, 4 > &ndof_on_subgeo, std::array< std::array< size_type, reference_element::max_variant >, 4 > &nnod_on_subgeo, std::array< std::array< size_type, 5 >, reference_element::max_variant > &first_idof_by_dimension, std::array< std::array< size_type, 5 >, reference_element::max_variant > &first_inod_by_dimension)
see the basis_option page for the full documentation
Definition: basis_option.h:93
void set_node(node_type type)
Definition: basis_option.h:257
reference_element::size_type size_type
Definition: basis.h:214
piola_fem< T > _piola_fem
Definition: basis.h:394
basis_option _sopt
Definition: basis.h:393
static std::string standard_naming(std::string family_name, size_t degree, const basis_option &sopt)
Definition: basis_rep.cc:44
std::string _name
Definition: basis.h:392
see the reference_element page for the full documentation
variant_type variant() const
rheolef::std value
#define error_macro(message)
Definition: dis_macros.h:49
Expr1::float_type T
Definition: field_expr.h:261
check_macro(expr1.have_homogeneous_space(Xh1), "dual(expr1,expr2); expr1 should have homogeneous space. HINT: use dual(interpolate(Xh, expr1),expr2)")
void basis_on_pointset_evaluate(const Basis &b, const reference_element &hat_K, const Eigen::Matrix< point_basic< T >, Eigen::Dynamic, 1 > &hat_x, Eigen::Matrix< Value, Eigen::Dynamic, Eigen::Dynamic > &vdm)
This file is part of Rheolef.
void pointset_lagrange_equispaced(reference_element hat_K, size_t order_in, Eigen::Matrix< point_basic< T >, Eigen::Dynamic, 1 > &hat_xnod, size_t internal=0)
Definition: equispaced.icc:44
void pointset_lagrange_warburton(reference_element hat_K, size_t degree, Eigen::Matrix< point_basic< T >, Eigen::Dynamic, 1 > &hat_xnod, bool map_on_reference_element=true)
Definition: warburton.icc:574
std::string itos(std::string::size_type i)
itos: see the rheostream page for the full documentation
_RHEOLEF_instanciation(Float, sequential, std::allocator< Float >) _RHEOLEF_instanciation(Float
void invert(tiny_matrix< T > &a, tiny_matrix< T > &inv_a)
Definition: tiny_lu.h:127