2
/// This file is part of Rheolef.
4
/// Copyright (C) 2000-2009 Pierre Saramito <Pierre.Saramito@imag.fr>
6
/// Rheolef is free software; you can redistribute it and/or modify
7
/// it under the terms of the GNU General Public License as published by
8
/// the Free Software Foundation; either version 2 of the License, or
9
/// (at your option) any later version.
11
/// Rheolef is distributed in the hope that it will be useful,
12
/// but WITHOUT ANY WARRANTY; without even the implied warranty of
13
/// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
/// GNU General Public License for more details.
16
/// You should have received a copy of the GNU General Public License
17
/// along with Rheolef; if not, write to the Free Software
18
/// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20
/// =========================================================================
24
#include "rheolef/rheostream.h"
25
#include "basis_symbolic.h"
26
#include "basis_symbolic.h"
27
using namespace rheolef;
29
using namespace GiNaC;
31
class Pk_symbolic : public basis_symbolic_nodal
33
typedef basis_symbolic_nodal::size_type size_type;
35
Pk_symbolic (size_type k);
37
Pk_symbolic::Pk_symbolic (size_type degree)
38
: basis_symbolic_nodal("P"+itos(degree),degree)
40
typedef point_basic<size_type> ilat;
41
std::vector<point_basic<ex> > hat_xnod;
42
// ------------------------------------
43
on('p') << node(0) << poly (1) << end;
44
// ------------------------------------
45
hat_xnod.resize (reference_element::n_node(reference_element::e, degree));
46
for (size_type i = 0; i <= degree; i++) {
47
on('e') << poly (pow(x,i));
48
size_type loc_idof = reference_element_e::ilat2loc_inod (degree, ilat(i));
49
hat_xnod [loc_idof] = point_basic<ex> ((ex(i))/ex(degree));
51
for (size_type loc_idof = 0, loc_ndof = hat_xnod.size(); loc_idof < loc_ndof; loc_idof++) {
52
on('e') << hat_xnod [loc_idof];
55
// ------------------------------------
56
hat_xnod.resize (reference_element::n_node(reference_element::t, degree));
57
for (size_type j = 0; j <= degree; j++) {
58
for (size_type i = 0; i+j <= degree; i++) {
59
on('t') << poly (pow(x,i)*pow(y,j));
60
size_type loc_idof = reference_element_t::ilat2loc_inod (degree, ilat(i,j));
61
hat_xnod [loc_idof] = point_basic<ex> ((ex(i))/ex(degree), ex(j)/ex(degree));
64
for (size_type loc_idof = 0, loc_ndof = hat_xnod.size(); loc_idof < loc_ndof; loc_idof++) {
65
on('t') << hat_xnod [loc_idof];
68
// ------------------------------------
69
hat_xnod.resize (reference_element::n_node(reference_element::q, degree));
70
for (size_type j = 0; j <= degree; j++) {
71
for (size_type i = 0; i <= degree; i++) {
72
on('q') << poly (pow(x,i)*pow(y,j));
73
size_type loc_idof = reference_element_q::ilat2loc_inod (degree, ilat(i,j));
74
hat_xnod [loc_idof] = point_basic<ex> (-1+2*(ex(i))/ex(degree), -1+2*ex(j)/ex(degree));
77
for (size_type loc_idof = 0, loc_ndof = hat_xnod.size(); loc_idof < loc_ndof; loc_idof++) {
78
on('q') << hat_xnod [loc_idof];
81
// -----------------------------------------
82
if (degree >= 5) return; // too big: not yet
83
// ------------------------------------
84
hat_xnod.resize (reference_element::n_node(reference_element::T, degree));
85
for (size_type k = 0; k <= degree; k++) {
86
for (size_type j = 0; j+k <= degree; j++) {
87
for (size_type i = 0; i+j+k <= degree; i++) {
88
on('T') << poly (pow(x,i)*pow(y,j)*pow(z,k));
89
size_type loc_idof = reference_element_T::ilat2loc_inod (degree, ilat(i,j,k));
90
hat_xnod [loc_idof] = point_basic<ex> ((ex(i))/ex(degree), ex(j)/ex(degree), ex(k)/ex(degree));
94
for (size_type loc_idof = 0, loc_ndof = hat_xnod.size(); loc_idof < loc_ndof; loc_idof++) {
95
on('T') << hat_xnod [loc_idof];
98
// -----------------------------------------
99
hat_xnod.resize (reference_element::n_node(reference_element::P, degree));
100
for (size_type k = 0; k <= degree; k++) {
101
for (size_type j = 0; j <= degree; j++) {
102
for (size_type i = 0; i+j <= degree; i++) {
103
on('P') << poly (pow(x,i)*pow(y,j)*pow(z,k));
104
size_type loc_idof = reference_element_P::ilat2loc_inod (degree, ilat(i,j,k));
105
hat_xnod [loc_idof] = point_basic<ex> ((ex(i))/ex(degree), ex(j)/ex(degree), -1+2*ex(k)/ex(degree));
109
for (size_type loc_idof = 0, loc_ndof = hat_xnod.size(); loc_idof < loc_ndof; loc_idof++) {
110
on('P') << hat_xnod [loc_idof];
113
// ------------------------------------
114
hat_xnod.resize (reference_element::n_node(reference_element::H, degree));
115
for (size_type k = 0; k <= degree; k++) {
116
for (size_type j = 0; j <= degree; j++) {
117
for (size_type i = 0; i <= degree; i++) {
118
on('H') << poly (pow(x,i)*pow(y,j)*pow(z,k));
119
size_type loc_idof = reference_element_H::ilat2loc_inod (degree, ilat(i,j,k));
120
hat_xnod [loc_idof] = point_basic<ex> (-1+2*(ex(i))/ex(degree), -1+2*ex(j)/ex(degree), -1+2*ex(k)/ex(degree));
124
for (size_type loc_idof = 0, loc_ndof = hat_xnod.size(); loc_idof < loc_ndof; loc_idof++) {
125
on('H') << hat_xnod [loc_idof];
129
int main (int argc, char **argv) {
131
cerr << "Pk_symbolic: usage: Pk_symbolic [-h|-c] degree" << endl;
134
size_t degree = atoi (argv[2]);
135
Pk_symbolic Pk (degree);
136
Pk.put_cxx_main (argc,argv);