SyFi  0.3
fe_ex2.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 int main() {
00009 
00010     initSyFi(2); 
00011 
00012     Triangle T(lst(0,0), lst(1,0), lst(0,1), "t"); 
00013     int order = 2; 
00014 
00015     std::map<std::pair<int,int>, ex> A;
00016     std::pair<int,int> index;
00017     Lagrange fe; 
00018     fe.set_order(order); 
00019     fe.set_polygon(T); 
00020     fe.compute_basis_functions(); 
00021     for (unsigned int i=0; i< fe.nbf() ; i++) {
00022         index.first = i; 
00023         for (unsigned int j=0; j< fe.nbf() ; j++) {
00024             index.second = j; 
00025             ex nabla = inner(grad(fe.N(i)), grad(fe.N(j))); 
00026             ex Aij = T.integrate(nabla);   
00027             A[index] = Aij;  
00028         }
00029     }
00030 
00031     map<std::pair<int,int>,ex>::iterator iter; 
00032     for (iter = A.begin(); iter != A.end() ; iter++) {
00033         cout <<"A["<<(*iter).first.first<<","<<(*iter).first.second<<"]="<<(*iter).second<<endl; 
00034     }
00035 
00036 
00037     // regression test 
00038     archive ar; 
00039     for (iter = A.begin(); iter != A.end() ; iter++) {
00040         ar.archive_ex((*iter).second, istr("A", (*iter).first.first, (*iter).first.second).c_str()); 
00041     }
00042     ofstream vfile("fe_ex2.gar.v"); 
00043     vfile << ar; vfile.close(); 
00044     if(!compare_archives("fe_ex2.gar.v", "fe_ex2.gar.r")) { 
00045             cerr << "Failure!" << endl;
00046             return -1;
00047     }
00048 
00049     return 0; 
00050 }
00051 
00052 
00053 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator