Rheolef  7.1
an efficient C++ finite element environment
basis_symbolic.h
Go to the documentation of this file.
1 #ifndef _RHEO_BASIS_SYMBOLIC_H
2 #define _RHEO_BASIS_SYMBOLIC_H
23 
24 #include <ginac/ginac.h>
25 #include "rheolef/point.h"
26 #include "rheolef/reference_element.h"
27 namespace rheolef {
28 
30 public:
31 
32 // allocator:
33 
34  basis_symbols() : x("x"), y("y"), z("z") {}
35 
36 // data:
37  GiNaC::symbol x, y, z;
38 };
40 public:
41 
42 // typedefs:
43 
45  typedef GiNaC::ex polynom_type;
46  typedef GiNaC::ex value_type;
47  struct end_type {};
48 
49 // allocators:
50 
52  : basis_symbols(), _name("unnamed"),
53  _hat_K(), _node(0), _poly(0),
54  _basis(), _grad_basis() {}
55 
56 // accessors:
57 
58  size_type size() const { return _node.size(); }
59  size_type dimension() const { return _hat_K.dimension(); }
60  const reference_element& hat_K() const { return _hat_K; }
61  std::string name() const { return _name; }
62  const point_basic<GiNaC::ex>& node (size_type i) const { return _node[i]; }
63  const polynom_type& polynom (size_type i) const { return _poly[i]; }
64 
65 // modifiers:
66 
67  void set_name(std::string str) { _name = str; }
69  _hat_K.set_variant(t); }
71  polynom_type& polynom (size_type i) { return _poly[i]; }
72 
73  void resize(size_type n) {
74  _node.resize(n); _poly.resize(n);
75  _basis.resize(n); _grad_basis.resize(n); }
76 
77  void add_polynom (const polynom_type& p) { _poly.push_back(p); }
79  add_polynom (p); return *this; }
80 
81  void add_node (const point_basic<GiNaC::ex>& x) { _node.push_back(x); }
82  void add_node (const Float& x0, const Float& x1=0, const Float& x2=0) {
83  add_node(point_basic<GiNaC::ex>(x0,x1,x2)); }
85  add_node (x); return *this; }
86 
87  void make_node_basis ();
89  make_node_basis(); return *this; }
90 
91 // method:
92 
93  value_type eval (const polynom_type& p,
94  const point_basic<polynom_type>& x, size_type d = 3) const;
95  GiNaC::matrix vandermonde_matrix (
96  const std::vector<polynom_type>& p, size_type d = 3) const;
97 
98 // outputs:
99 
100  void put_cxx_header (std::ostream& out) const;
101  void put_cxx_body (std::ostream& out) const;
102 
103 // utility:
104 
105  polynom_type indexed_symbol (const polynom_type& expr0) const;
106 
107 // data:
108 
109 protected:
110  std::string _name;
112  std::vector<point_basic<GiNaC::ex> > _node;
113  std::vector<polynom_type> _poly;
114  std::vector<polynom_type> _basis;
115  std::vector<point_basic<polynom_type> > _grad_basis;
116 };
118  : public basis_symbols, public std::vector<basis_symbolic_nodal_on_geo> {
119 public:
120 
121 // typedefs:
122 
126 
127 // allocators:
128 
129  basis_symbolic_nodal(std::string nam, size_type deg)
130  : basis_symbols(),
132  _name(nam),
133  _family_name(),
134  _degree(deg),
135  _have_index_parameter(false),
137  {
138  GiNaC::Digits = 2*std::numeric_limits<Float>::digits10;
139  for (size_type i = 0; i < reference_element::max_variant; i++) {
140  operator[](i).x = x;
141  operator[](i).y = y;
142  operator[](i).z = z;
143  operator[](i).set_hat_K(reference_element::variant_type(i));
144  operator[](i).set_name(nam);
145  }
146  }
147 
148 // accessors:
149 
150  size_type degree() const { return _degree; }
153 
156  return operator[] (t);
157  }
160  return operator[] (t);
161  }
163  reference_element hat_K;
164  hat_K.set_name(t);
165  return operator[] (hat_K.variant()); }
166 
167  std::string name() const { return _name; }
168  std::string family_name() const { return _family_name; }
169 
170 // modifiers:
171 
172  void set_name(std::string str) { _name = str; }
173  void set_degree_parameter (bool dp = true) { _have_index_parameter = dp; }
174  void set_continuous_feature (bool cf = true) { _have_continuous_feature = cf; }
175 
176 // syntax helpers:
177 
178  static polynom_type poly (const polynom_type& p) { return p; }
180  return x; }
182  const GiNaC::ex& x0, const GiNaC::ex& x1=0, const GiNaC::ex& x2=0) {
183  return point_basic<GiNaC::ex>(x0,x1,x2); }
184  static end_type end () { return end_type(); }
185 
186 // outputs:
187 
188  void put_cxx_header(std::ostream& out) const;
189  void put_cxx_body (std::ostream& out) const;
190  void put_cxx_main (int argc, char **argv) const;
191 
192 // data:
193 protected:
194  std::string _name;
195  std::string _family_name;
199 };
200 }// namespace rheolef
201 #endif // _RHEO_BASIS_SYMBOLIC_H
field::size_type size_type
Definition: branch.cc:425
see the Float page for the full documentation
std::vector< polynom_type > _poly
point_basic< GiNaC::ex > & node(size_type i)
const point_basic< GiNaC::ex > & node(size_type i) const
polynom_type indexed_symbol(const polynom_type &expr0) const
std::vector< point_basic< polynom_type > > _grad_basis
const polynom_type & polynom(size_type i) const
std::vector< point_basic< GiNaC::ex > > _node
basis_symbolic_nodal_on_geo & operator<<(const polynom_type &p)
const reference_element & hat_K() const
std::vector< polynom_type > _basis
polynom_type & polynom(size_type i)
void add_node(const Float &x0, const Float &x1=0, const Float &x2=0)
void add_node(const point_basic< GiNaC::ex > &x)
value_type eval(const polynom_type &p, const point_basic< polynom_type > &x, size_type d=3) const
void set_hat_K(reference_element::variant_type t)
void put_cxx_body(std::ostream &out) const
void add_polynom(const polynom_type &p)
std::vector< int >::size_type size_type
void put_cxx_header(std::ostream &out) const
GiNaC::matrix vandermonde_matrix(const std::vector< polynom_type > &p, size_type d=3) const
const basis_symbolic_nodal_on_geo & on(reference_element::variant_type t) const
void put_cxx_main(int argc, char **argv) const
static point_basic< GiNaC::ex > node(const point_basic< GiNaC::ex > &x)
basis_symbolic_nodal_on_geo & on(reference_element::variant_type t)
void set_name(std::string str)
basis_symbolic_nodal_on_geo::size_type size_type
static point_basic< GiNaC::ex > node(const GiNaC::ex &x0, const GiNaC::ex &x1=0, const GiNaC::ex &x2=0)
basis_symbolic_nodal_on_geo & on(char t)
basis_symbolic_nodal_on_geo::polynom_type polynom_type
void set_continuous_feature(bool cf=true)
basis_symbolic_nodal(std::string nam, size_type deg)
basis_symbolic_nodal_on_geo::end_type end_type
static polynom_type poly(const polynom_type &p)
void put_cxx_body(std::ostream &out) const
void set_degree_parameter(bool dp=true)
std::string family_name() const
void put_cxx_header(std::ostream &out) const
see the reference_element page for the full documentation
void set_variant(variant_type x)
static const variant_type max_variant
variant_type variant() const
This file is part of Rheolef.
Definition: sphere.icc:25