Rheolef  7.2
an efficient C++ finite element environment
basis_raw_monomial.cc
Go to the documentation of this file.
1 #include "basis_raw_monomial.h"
22 #include "monomial.icc"
23 
24 namespace rheolef {
25 using namespace std;
26 
27 // =========================================================================
28 // basis raw monomial members
29 // =========================================================================
30 template<class T>
32 {
33 }
34 template<class T>
36  : basis_raw_rep<T> (name),
37  _power_index(),
38  _hat_x_pow(),
39  _hat_x_ad_pow()
40 {
41 trace_macro ("basis_raw_monomial: name="<<name);
42  if ((name.length()) > 0 && (name[0] == 'M')) {
43  // TODO: check also that name fits "Mk" where is an k integer
44  base::_degree = atoi(name.c_str()+1);
45  } else if (name.length() > 0) { // missing 'M' !
46  error_macro ("invalid polynomial name `"<<name<<"' for the Mk polynomial set");
47  } else {
48  // empty name : default cstor
49  base::_degree = 0;
50  }
51 trace_macro ("basis_raw_monomial: name()="<<base::name());
52 }
53 template<class T>
56 {
57  return reference_element::n_node (hat_K.variant(), base::_degree);
58 }
59 template<class T>
60 void
62 {
63  // for each monomial with index loc_idof:
64  // p(x,y) = x^a*y^b
65  // power_index[loc_idof] contains the set of power indexes (a,b)
66  // note: power_index is computed here one time for all
67  // as it does not depend upon hat_x but onlhy upon (hat_K,degree)
68  make_power_indexes_sorted_by_degrees (hat_K, base::_degree, _power_index[hat_K.variant()]);
69  // note: hat_x_pow depends upon hat_x, but is here allocated
70  // one time for all, as a working array,
71  // as its size does not depend upon hat_x but only upon (hat_K,degree)
72  _hat_x_pow [hat_K.variant()].resize (base::_degree+1);
73  _hat_x_ad_pow[hat_K.variant()].resize (base::_degree+1);
74 }
75 // evaluation of all basis functions at hat_x:
76 template<class T>
77 void
79  reference_element hat_K,
80  const point_basic<T>& hat_x,
81  Eigen::Matrix<T,Eigen::Dynamic,1>& value) const
82 {
83 trace_macro ("basis_raw_monomial: evaluate (name="<<base::name()<<")...");
84  base::_initialize_guard (hat_K);
85  size_t d = hat_K.dimension();
86  // each x^a and y^b are computed first
87  // for all a,b=0..degree in the _hat_x_pow array
88  // => this avoid imbricated loops
89  precompute_power_monomial (hat_K, d, hat_x, base::_degree, _hat_x_pow[hat_K.variant()]);
90  size_t loc_ndof = _power_index[hat_K.variant()].size();
91  value.resize(loc_ndof);
92  for (size_t loc_idof = 0; loc_idof < loc_ndof; loc_idof++) {
93  value[loc_idof] = eval_monomial_internal (hat_K, d, _hat_x_pow[hat_K.variant()], _power_index[hat_K.variant()][loc_idof]);
94  }
95 trace_macro ("basis_raw_monomial: evaluate (name="<<base::name()<<") done");
96 }
97 template<class T>
98 void
100  reference_element hat_K,
101  const point_basic<T>& hat_x,
102  Eigen::Matrix<point_basic<T>,Eigen::Dynamic,1>& value) const
103 {
104  base::_initialize_guard (hat_K);
105  point_basic<ad3_basic<T> > hat_x_ad = ad3::point (hat_x);
106  size_t d = hat_K.dimension();
107  precompute_power_monomial (hat_K, d, hat_x_ad, base::_degree, _hat_x_ad_pow[hat_K.variant()]);
108  size_t loc_ndof = _power_index[hat_K.variant()].size();
109  value.resize(loc_ndof);
110  for (size_t loc_idof = 0; loc_idof < loc_ndof; loc_idof++) {
111  ad3_basic<T> bx = eval_monomial_internal (hat_K, d, _hat_x_ad_pow[hat_K.variant()], _power_index[hat_K.variant()][loc_idof]);
112  value[loc_idof] = bx.grad();
113  }
114 }
115 // ----------------------------------------------------------------------------
116 // instanciation in library
117 // ----------------------------------------------------------------------------
118 #define _RHEOLEF_instanciation(T) \
119 template class basis_raw_monomial<T>;
120 
122 
123 }// namespace rheolef
see the Float page for the full documentation
const point_basic< T > & grad() const
Definition: ad3.h:160
size_type ndof(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
basis_raw_monomial(std::string name)
void _initialize(reference_element hat_K) const
std::string name() const
Definition: basis_raw.h:49
see the reference_element page for the full documentation
variant_type variant() const
static size_type n_node(variant_type variant, size_type order)
rheolef::std value
#define trace_macro(message)
Definition: dis_macros.h:111
#define error_macro(message)
Definition: dis_macros.h:49
Expr1::float_type T
Definition: field_expr.h:230
This file is part of Rheolef.
_RHEOLEF_instanciation(Float, sequential, std::allocator< Float >) _RHEOLEF_instanciation(Float