basis_symbolic.h
Go to the documentation of this file.
#ifndef _RHEO_BASIS_SYMBOLIC_H
#define _RHEO_BASIS_SYMBOLIC_H
#include <ginac/ginac.h>
#include "rheolef/point.h"
#include "rheolef/reference_element.h"
namespace rheolef {
class basis_symbols {
public:
// allocator:
basis_symbols() : x("x"), y("y"), z("z") {}
// data:
GiNaC::symbol x, y, z;
};
class basis_symbolic_nodal_on_geo: public basis_symbols {
public:
// typedefs:
typedef std::vector<int>::size_type size_type;
typedef GiNaC::ex polynom_type;
typedef GiNaC::ex value_type;
struct end_type {};
// allocators:
basis_symbolic_nodal_on_geo()
: basis_symbols(), _name("unnamed"),
_hat_K(), _node(0), _poly(0),
_basis(), _grad_basis() {}
// accessors:
size_type size() const { return _node.size(); }
size_type dimension() const { return _hat_K.dimension(); }
const reference_element& hat_K() const { return _hat_K; }
std::string name() const { return _name; }
const point_basic<GiNaC::ex>& node (size_type i) const { return _node[i]; }
const polynom_type& polynom (size_type i) const { return _poly[i]; }
// modifiers:
void set_name(std::string str) { _name = str; }
void set_hat_K(reference_element::variant_type t) {
_hat_K.set_variant(t); }
point_basic<GiNaC::ex>& node (size_type i) { return _node[i]; }
polynom_type& polynom (size_type i) { return _poly[i]; }
void resize(size_type n) {
_node.resize(n); _poly.resize(n);
_basis.resize(n); _grad_basis.resize(n); }
void add_polynom (const polynom_type& p) { _poly.push_back(p); }
basis_symbolic_nodal_on_geo& operator<< (const polynom_type& p) {
add_polynom (p); return *this; }
void add_node (const point_basic<GiNaC::ex>& x) { _node.push_back(x); }
void add_node (const Float& x0, const Float& x1=0, const Float& x2=0) {
add_node(point_basic<GiNaC::ex>(x0,x1,x2)); }
basis_symbolic_nodal_on_geo& operator<< (const point_basic<GiNaC::ex>& x) {
add_node (x); return *this; }
void make_node_basis ();
basis_symbolic_nodal_on_geo& operator<< (end_type(*)()) {
make_node_basis(); return *this; }
// method:
value_type eval (const polynom_type& p,
const point_basic<polynom_type>& x, size_type d = 3) const;
GiNaC::matrix vandermonde_matrix (
const std::vector<polynom_type>& p, size_type d = 3) const;
// outputs:
void put_cxx_header (std::ostream& out) const;
void put_cxx_body (std::ostream& out) const;
// utility:
polynom_type indexed_symbol (const polynom_type& expr0) const;
// data:
protected:
std::string _name;
reference_element _hat_K;
std::vector<point_basic<GiNaC::ex> > _node;
std::vector<polynom_type> _poly;
std::vector<polynom_type> _basis;
std::vector<point_basic<polynom_type> > _grad_basis;
};
class basis_symbolic_nodal
: public basis_symbols, public std::vector<basis_symbolic_nodal_on_geo> {
public:
// typedefs:
typedef basis_symbolic_nodal_on_geo::size_type size_type;
typedef basis_symbolic_nodal_on_geo::polynom_type polynom_type;
typedef basis_symbolic_nodal_on_geo::end_type end_type;
// allocators:
basis_symbolic_nodal(std::string nam, size_type deg)
: basis_symbols(),
std::vector<basis_symbolic_nodal_on_geo>(reference_element::max_variant),
_name(nam),
_family_name(),
_degree(deg),
_have_index_parameter(false),
_have_continuous_feature(false)
{
GiNaC::Digits = 2*std::numeric_limits<Float>::digits10;
for (size_type i = 0; i < reference_element::max_variant; i++) {
operator[](i).x = x;
operator[](i).y = y;
operator[](i).z = z;
operator[](i).set_hat_K(reference_element::variant_type(i));
operator[](i).set_name(nam);
}
}
// accessors:
size_type degree() const { return _degree; }
bool have_index_parameter() const { return _have_index_parameter; }
bool have_continuous_feature() const { return _have_continuous_feature; }
const basis_symbolic_nodal_on_geo& on(
reference_element::variant_type t) const {
return operator[] (t);
}
basis_symbolic_nodal_on_geo& on(
reference_element::variant_type t) {
return operator[] (t);
}
basis_symbolic_nodal_on_geo& on(char t) {
reference_element hat_K;
hat_K.set_name(t);
return operator[] (hat_K.variant()); }
std::string name() const { return _name; }
std::string family_name() const { return _family_name; }
// modifiers:
void set_name(std::string str) { _name = str; }
void set_degree_parameter (bool dp = true) { _have_index_parameter = dp; }
void set_continuous_feature (bool cf = true) { _have_continuous_feature = cf; }
// syntax helpers:
static polynom_type poly (const polynom_type& p) { return p; }
static point_basic<GiNaC::ex> node (const point_basic<GiNaC::ex>& x) {
return x; }
static point_basic<GiNaC::ex> node (
const GiNaC::ex& x0, const GiNaC::ex& x1=0, const GiNaC::ex& x2=0) {
return point_basic<GiNaC::ex>(x0,x1,x2); }
static end_type end () { return end_type(); }
// outputs:
void put_cxx_header(std::ostream& out) const;
void put_cxx_body (std::ostream& out) const;
void put_cxx_main (int argc, char **argv) const;
// data:
protected:
std::string _name;
std::string _family_name;
size_type _degree;
bool _have_index_parameter;
bool _have_continuous_feature;
};
}// namespace rheolef
#endif // _RHEO_BASIS_SYMBOLIC_H
rheolef::basis_symbolic_nodal_on_geo::_poly
std::vector< polynom_type > _poly
Definition: basis_symbolic.h:113
rheolef::basis_symbolic_nodal_on_geo::name
std::string name() const
Definition: basis_symbolic.h:61
rheolef::io::out
@ out
Definition: rheostream.h:167
rheolef::basis_symbolic_nodal_on_geo::add_node
void add_node(const point_basic< GiNaC::ex > &x)
Definition: basis_symbolic.h:81
rheolef::basis_symbolic_nodal_on_geo::make_node_basis
void make_node_basis()
Definition: basis_symbolic.cc:80
rheolef::point_basic
Definition: point.h:87
rheolef::basis_symbolic_nodal_on_geo::_hat_K
reference_element _hat_K
Definition: basis_symbolic.h:111
rheolef::basis_symbolic_nodal::_have_index_parameter
bool _have_index_parameter
Definition: basis_symbolic.h:197
rheolef::basis_symbolic_nodal_on_geo::eval
value_type eval(const polynom_type &p, const point_basic< polynom_type > &x, size_type d=3) const
Definition: basis_symbolic.cc:28
rheolef::basis_symbolic_nodal::on
basis_symbolic_nodal_on_geo & on(reference_element::variant_type t)
Definition: basis_symbolic.h:158
rheolef::basis_symbolic_nodal::have_index_parameter
bool have_index_parameter() const
Definition: basis_symbolic.h:151
rheolef::basis_symbolic_nodal_on_geo::set_hat_K
void set_hat_K(reference_element::variant_type t)
Definition: basis_symbolic.h:68
rheolef::basis_symbolic_nodal_on_geo::polynom_type
GiNaC::ex polynom_type
Definition: basis_symbolic.h:45
rheolef::basis_symbolic_nodal::end
static end_type end()
Definition: basis_symbolic.h:184
rheolef::basis_symbolic_nodal_on_geo::vandermonde_matrix
GiNaC::matrix vandermonde_matrix(const std::vector< polynom_type > &p, size_type d=3) const
Definition: basis_symbolic.cc:40
rheolef::basis_symbolic_nodal_on_geo::set_name
void set_name(std::string str)
Definition: basis_symbolic.h:67
rheolef::basis_symbolic_nodal_on_geo::add_node
void add_node(const Float &x0, const Float &x1=0, const Float &x2=0)
Definition: basis_symbolic.h:82
rheolef::basis_symbolic_nodal::polynom_type
basis_symbolic_nodal_on_geo::polynom_type polynom_type
Definition: basis_symbolic.h:124
rheolef::basis_symbolic_nodal_on_geo::polynom
polynom_type & polynom(size_type i)
Definition: basis_symbolic.h:71
rheolef::basis_symbolic_nodal::name
std::string name() const
Definition: basis_symbolic.h:167
rheolef::basis_symbolic_nodal::size_type
basis_symbolic_nodal_on_geo::size_type size_type
Definition: basis_symbolic.h:123
p
Definition: sphere.icc:25
rheolef::reference_element
see the reference_element page for the full documentation
Definition: reference_element.h:66
rheolef::basis_symbolic_nodal::poly
static polynom_type poly(const polynom_type &p)
Definition: basis_symbolic.h:178
rheolef::basis_symbolic_nodal_on_geo::_basis
std::vector< polynom_type > _basis
Definition: basis_symbolic.h:114
rheolef::basis_symbolic_nodal_on_geo::_grad_basis
std::vector< point_basic< polynom_type > > _grad_basis
Definition: basis_symbolic.h:115
rheolef::basis_symbolic_nodal::on
const basis_symbolic_nodal_on_geo & on(reference_element::variant_type t) const
Definition: basis_symbolic.h:154
rheolef::reference_element::variant_type
size_type variant_type
Definition: reference_element.h:72
rheolef::basis_symbolic_nodal_on_geo::operator<<
basis_symbolic_nodal_on_geo & operator<<(const polynom_type &p)
Definition: basis_symbolic.h:78
rheolef::basis_symbols::z
GiNaC::symbol z
Definition: basis_symbolic.h:37
rheolef::basis_symbolic_nodal_on_geo
Definition: basis_symbolic.h:39
rheolef::basis_symbolic_nodal::put_cxx_body
void put_cxx_body(std::ostream &out) const
Definition: basis_symbolic_cxx.cc:225
rheolef::basis_symbolic_nodal_on_geo::_name
std::string _name
Definition: basis_symbolic.h:110
rheolef::reference_element::variant
variant_type variant() const
Definition: reference_element.h:99
rheolef::basis_symbolic_nodal_on_geo::resize
void resize(size_type n)
Definition: basis_symbolic.h:73
rheolef::basis_symbolic_nodal_on_geo::put_cxx_header
void put_cxx_header(std::ostream &out) const
Definition: basis_symbolic_cxx.cc:69
rheolef::basis_symbolic_nodal::have_continuous_feature
bool have_continuous_feature() const
Definition: basis_symbolic.h:152
rheolef::basis_symbolic_nodal_on_geo::dimension
size_type dimension() const
Definition: basis_symbolic.h:59
rheolef::basis_symbols::x
GiNaC::symbol x
Definition: basis_symbolic.h:37
rheolef::basis_symbolic_nodal::node
static point_basic< GiNaC::ex > node(const GiNaC::ex &x0, const GiNaC::ex &x1=0, const GiNaC::ex &x2=0)
Definition: basis_symbolic.h:181
rheolef
This file is part of Rheolef.
Definition: compiler_eigen.h:37
rheolef::basis_symbolic_nodal_on_geo::polynom
const polynom_type & polynom(size_type i) const
Definition: basis_symbolic.h:63
rheolef::basis_symbolic_nodal_on_geo::hat_K
const reference_element & hat_K() const
Definition: basis_symbolic.h:60
rheolef::basis_symbols::y
GiNaC::symbol y
Definition: basis_symbolic.h:37
rheolef::basis_symbolic_nodal::end_type
basis_symbolic_nodal_on_geo::end_type end_type
Definition: basis_symbolic.h:125
rheolef::basis_symbolic_nodal::basis_symbolic_nodal
basis_symbolic_nodal(std::string nam, size_type deg)
Definition: basis_symbolic.h:129
Float
see the Float page for the full documentation
rheolef::basis_symbolic_nodal::on
basis_symbolic_nodal_on_geo & on(char t)
Definition: basis_symbolic.h:162
rheolef::reference_element::max_variant
static const variant_type max_variant
Definition: reference_element.h:82
rheolef::basis_symbolic_nodal::set_name
void set_name(std::string str)
Definition: basis_symbolic.h:172
rheolef::basis_symbolic_nodal_on_geo::indexed_symbol
polynom_type indexed_symbol(const polynom_type &expr0) const
Definition: basis_symbolic_cxx.cc:54
mkgeo_ball.d
d
Definition: mkgeo_ball.sh:154
rheolef::reference_element::dimension
size_type dimension() const
Definition: reference_element.h:101
rheolef::reference_element::set_name
void set_name(char name)
Definition: reference_element.cc:59
rheolef::basis_symbolic_nodal_on_geo::add_polynom
void add_polynom(const polynom_type &p)
Definition: basis_symbolic.h:77
rheolef::basis_symbolic_nodal::_degree
size_type _degree
Definition: basis_symbolic.h:196
rheolef::basis_symbolic_nodal::family_name
std::string family_name() const
Definition: basis_symbolic.h:168
rheolef::basis_symbolic_nodal::node
static point_basic< GiNaC::ex > node(const point_basic< GiNaC::ex > &x)
Definition: basis_symbolic.h:179
rheolef::basis_symbolic_nodal::set_continuous_feature
void set_continuous_feature(bool cf=true)
Definition: basis_symbolic.h:174
rheolef::basis_symbols
Definition: basis_symbolic.h:29
rheolef::space_constant::vector
@ vector
Definition: space_constant.h:137
mkgeo_ball.n
n
Definition: mkgeo_ball.sh:150
rheolef::basis_symbolic_nodal::set_degree_parameter
void set_degree_parameter(bool dp=true)
Definition: basis_symbolic.h:173
rheolef::reference_element::set_variant
void set_variant(variant_type x)
Definition: reference_element.h:93
size_type
field::size_type size_type
Definition: branch.cc:425
rheolef::basis_symbolic_nodal::_name
std::string _name
Definition: basis_symbolic.h:194
rheolef::basis_symbolic_nodal::_have_continuous_feature
bool _have_continuous_feature
Definition: basis_symbolic.h:198
rheolef::basis_symbolic_nodal::put_cxx_main
void put_cxx_main(int argc, char **argv) const
Definition: basis_symbolic_cxx.cc:421
rheolef::basis_symbolic_nodal_on_geo::put_cxx_body
void put_cxx_body(std::ostream &out) const
Definition: basis_symbolic_cxx.cc:85
rheolef::basis_symbolic_nodal_on_geo::node
point_basic< GiNaC::ex > & node(size_type i)
Definition: basis_symbolic.h:70
rheolef::basis_symbolic_nodal::put_cxx_header
void put_cxx_header(std::ostream &out) const
Definition: basis_symbolic_cxx.cc:148
rheolef::basis_symbolic_nodal_on_geo::node
const point_basic< GiNaC::ex > & node(size_type i) const
Definition: basis_symbolic.h:62
rheolef::basis_symbolic_nodal::_family_name
std::string _family_name
Definition: basis_symbolic.h:195
rheolef::basis_symbolic_nodal_on_geo::size_type
std::vector< int >::size_type size_type
Definition: basis_symbolic.h:44
rheolef::basis_symbolic_nodal
Definition: basis_symbolic.h:117
rheolef::std
Definition: vec_expr_v2.h:391
rheolef::basis_symbolic_nodal_on_geo::basis_symbolic_nodal_on_geo
basis_symbolic_nodal_on_geo()
Definition: basis_symbolic.h:51
rheolef::basis_symbolic_nodal::degree
size_type degree() const
Definition: basis_symbolic.h:150
rheolef::basis_symbols::basis_symbols
basis_symbols()
Definition: basis_symbolic.h:34
rheolef::basis_symbolic_nodal_on_geo::value_type
GiNaC::ex value_type
Definition: basis_symbolic.h:46
rheolef::basis_symbolic_nodal_on_geo::end_type
Definition: basis_symbolic.h:47
rheolef::basis_symbolic_nodal_on_geo::_node
std::vector< point_basic< GiNaC::ex > > _node
Definition: basis_symbolic.h:112
rheolef::basis_symbolic_nodal_on_geo::size
size_type size() const
Definition: basis_symbolic.h:58