Rheolef  7.2
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"+std::to_string(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_internal,
65  base::_ndof_on_subgeo,
66  base::_nnod_on_subgeo_internal,
67  base::_nnod_on_subgeo,
68  base::_first_idof_by_dimension_internal,
69  base::_first_idof_by_dimension,
70  base::_first_inod_by_dimension_internal,
71  base::_first_inod_by_dimension);
72 }
73 template<class T>
74 const Eigen::Matrix<point_basic<T>,Eigen::Dynamic,1>&
76 {
77  base::_initialize_data_guard (hat_K);
78  return _hat_node [hat_K.variant()];
79 }
80 template<class T>
81 const Eigen::Matrix<T,Eigen::Dynamic,Eigen::Dynamic>&
83 {
84  base::_initialize_data_guard (hat_K);
85  return _vdm [hat_K.variant()];
86 }
87 template<class T>
88 const Eigen::Matrix<T,Eigen::Dynamic,Eigen::Dynamic>&
90 {
91  base::_initialize_data_guard (hat_K);
92  return _inv_vdm [hat_K.variant()];
93 }
94 template<class T>
95 void
97 {
98  // initialization is similar to Pk-Lagrange
99  size_type k = degree();
100  size_type variant = hat_K.variant();
101 
102  // nodes:
103  switch (base::_sopt.get_node()) {
105  pointset_lagrange_equispaced (hat_K, k, _hat_node[variant]);
106  break;
108  pointset_lagrange_warburton (hat_K, k, _hat_node[variant]); break;
109  default: error_macro ("unsupported node set: "<<base::_sopt.get_node_name());
110  }
111  // vdm:
112  details::basis_on_pointset_evaluate (_raw_basis, hat_K, _hat_node[variant], _vdm[variant]);
113  check_macro (invert(_vdm[variant], _inv_vdm[variant]),
114  "unisolvence failed for " << base::name() <<"(" << hat_K.name() << ") basis");
115 }
116 // evaluation of all basis functions at hat_x:
117 template<class T>
118 void
120  reference_element hat_K,
121  const point_basic<T>& hat_x,
122  Eigen::Matrix<T,Eigen::Dynamic,1>& value) const
123 {
124  base::_initialize_data_guard (hat_K);
125  _raw_basis.evaluate (hat_K, hat_x, value);
126 }
127 // evaluate the gradient:
128 template<class T>
129 void
131  reference_element hat_K,
132  const point_basic<T>& hat_x,
133  Eigen::Matrix<point_basic<T>,Eigen::Dynamic,1>& value) const
134 {
135  base::_initialize_data_guard (hat_K);
136  _raw_basis.grad_evaluate (hat_K, hat_x, value);
137 }
138 // dofs for a scalar-valued function
139 template<class T>
140 void
142  reference_element hat_K,
143  const Eigen::Matrix<T,Eigen::Dynamic,1>& f_xnod,
144  Eigen::Matrix<T,Eigen::Dynamic,1>& dof) const
145 {
146  base::_initialize_data_guard (hat_K);
147  dof = _inv_vdm[hat_K.variant()]*f_xnod;
148 }
149 // ----------------------------------------------------------------------------
150 // instanciation in library
151 // ----------------------------------------------------------------------------
152 #define _RHEOLEF_instanciation(T) \
153 template class basis_fem_Pk_bernstein<T>;
154 
156 
157 }// 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_internal, 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_internal, 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_internal, 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_internal, 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:424
basis_option _sopt
Definition: basis.h:423
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:422
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:230
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
_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