00001 #include "Bubble.h"
00002
00003 void Bubble:: compute_basis_functions() {
00004
00005 if ( p == NULL ) {
00006 cout <<"You need to set a polygon before the basisfunctions can be computed"<<endl;
00007 return;
00008 }
00009
00010
00011 if (p->str() == "ReferenceLine") {
00012 Ns.insert(Ns.end(), x*(1-x));
00013 } else if (p->str() == "ReferenceTriangle" || p->str() == "Triangle" ) {
00014
00015 GiNaC::ex b = barycenter_triangle(p->vertex(0), p->vertex(1), p->vertex(2));
00016 GiNaC::ex N = GiNaC::numeric(1);
00017 for (int d=0; d< b.nops(); d++) {
00018 N = N*b.op(d).rhs();
00019 }
00020 cout <<"N "<<N<<endl;
00021 Ns.insert(Ns.end(), N);
00022
00023 } else if (p->str() == "ReferenceTetrahedron" || p->str() == "Tetrahedron" ) {
00024 GiNaC::ex b = barycenter_tetrahedron(p->vertex(0), p->vertex(1),
00025 p->vertex(2), p->vertex(3));
00026 GiNaC::ex N = GiNaC::numeric(1);
00027 for (int d=0; d< b.nops(); d++) {
00028 N = N*b.op(d).rhs();
00029 }
00030 cout <<"N "<<N<<endl;
00031 Ns.insert(Ns.end(), N);
00032 }
00033
00034
00035
00036 GiNaC::lst midpoint = GiNaC::lst();
00037 for (int d=0; d< p->vertex(1).nops(); d++) {
00038 midpoint.append(GiNaC::numeric(0));
00039 }
00040 for (int i=1; i<= p->no_vertices(); i++) {
00041 for (int d=0; d< p->vertex(i-1).nops(); d++) {
00042 midpoint.let_op(d) += p->vertex(i-1).op(d);
00043 }
00044 }
00045
00046 for (int d=0; d< p->vertex(1).nops(); d++) {
00047 midpoint.let_op(d) = midpoint.op(d)/p->no_vertices();
00048 }
00049
00050 dofs.insert(dofs.end(), midpoint);
00051 }