SyFi  0.3
fe_ex4.cpp
Go to the documentation of this file.
00001 #include <SyFi.h>
00002 #include <fstream>
00003 
00004 using namespace GiNaC; 
00005 using namespace SyFi; 
00006 using namespace std; 
00007 
00008 
00009 
00010 
00011 
00012 int main(){ 
00013 
00014     initSyFi(2); 
00015 
00016     //matrix in terms of rational numbers 
00017     int order = 1; 
00018     Triangle triangle(lst(0,0), lst(1,0), lst(0,1));   
00019     Lagrange fe; 
00020     fe.set_order(order); 
00021     fe.set_polygon(triangle); 
00022     fe.compute_basis_functions(); 
00023 
00024     Dof dof; 
00025     std::map<std::pair<unsigned int,unsigned int>, ex> A; 
00026     compute_Poisson_element_matrix(fe, dof, A); 
00027     print(A); 
00028 
00029     //matrix in terms of symbols 
00030     symbol x0("x0", "x_0"), x1("x1", "x_1"), x2("x2", "x_2");  
00031     symbol y0("y0", "y_0"), y1("y1", "y_1"), y2("y2", "y_2");  
00032     Triangle triangle2(lst(x0,y0), lst(x1,y1), lst(x2,y2));   
00033 
00034     Lagrange fe2; 
00035     fe2.set_order(order); 
00036     fe2.set_polygon(triangle2); 
00037     fe2.compute_basis_functions(); 
00038 
00039     Dof dof2; 
00040     std::map<std::pair<unsigned int,unsigned int>, ex> A2; 
00041     compute_Poisson_element_matrix(fe2, dof2, A2); 
00042 
00043     cout <<"standard format on output"<<endl; 
00044     print(A2); 
00045     cout <<"LaTeX format on output "<<endl; 
00046     cout <<latex; 
00047     print(A2); 
00048     cout <<"C code format on output "<<endl; 
00049     cout <<csrc; 
00050     print(A2); 
00051 
00052 
00053     /*
00054     // regression test 
00055     archive ar; 
00056     map<std::pair<int,int>,ex>::iterator iter; 
00057     for (iter = A.begin(); iter != A.end() ; iter++) {
00058       ar.archive_ex((*iter).second, istr("A", (*iter).first.first, (*iter).first.second).c_str()); 
00059     }
00060 
00061     for (iter = A2.begin(); iter != A2.end() ; iter++) {
00062       ar.archive_ex((*iter).second, istr("A2_", (*iter).first.first, (*iter).first.second).c_str()); 
00063     }
00064     ofstream vfile("fe_ex4.gar.v"); 
00065     vfile << ar; vfile.close(); 
00066     if(!compare_archives("fe_ex4.gar.v", "fe_ex4.gar.r")) { 
00067       cerr << "Failure!" << endl;
00068       return -1;
00069     }
00070     */
00071 
00072     return 0; 
00073 }
00074 
00075 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator