Rheolef  7.2
an efficient C++ finite element environment
 
Loading...
Searching...
No Matches
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"
27namespace rheolef {
28
30public:
31
32// allocator:
33
34 basis_symbols() : x("x"), y("y"), z("z") {}
35
36// data:
37 GiNaC::symbol x, y, z;
38};
40public:
41
42// typedefs:
43
44 typedef std::vector<int>::size_type size_type;
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; }
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); }
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)); }
86
87 void make_node_basis ();
90
91// method:
92
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
109protected:
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> {
119public:
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),
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:
193protected:
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:430
see the Float page for the full documentation
const reference_element & hat_K() const
std::vector< polynom_type > _poly
point_basic< GiNaC::ex > & node(size_type i)
polynom_type indexed_symbol(const polynom_type &expr0) const
const polynom_type & polynom(size_type i) const
const point_basic< GiNaC::ex > & node(size_type i) const
std::vector< point_basic< polynom_type > > _grad_basis
basis_symbolic_nodal_on_geo & operator<<(const polynom_type &p)
std::vector< point_basic< GiNaC::ex > > _node
std::vector< polynom_type > _basis
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
polynom_type & polynom(size_type i)
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
static point_basic< GiNaC::ex > node(const GiNaC::ex &x0, const GiNaC::ex &x1=0, const GiNaC::ex &x2=0)
void put_cxx_main(int argc, char **argv) const
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
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)
const basis_symbolic_nodal_on_geo & on(reference_element::variant_type t) const
std::string family_name() const
void put_cxx_header(std::ostream &out) const
basis_symbolic_nodal_on_geo & on(char t)
static point_basic< GiNaC::ex > node(const point_basic< GiNaC::ex > &x)
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.
STL namespace.
Definition sphere.icc:25