SyFi  0.3
crouzeixraviart_ex.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 int check_CrouzeixRaviart() {
00010 
00011     initSyFi(2); 
00012 
00013     cout <<"2D ----------------------------"<<endl; 
00014     ReferenceTriangle triangle; 
00015     CrouzeixRaviart fe; 
00016     fe.set_polygon(triangle); 
00017     fe.compute_basis_functions(); 
00018 
00019     usage(fe); 
00020 
00021     Dof dof; 
00022     std::map<std::pair<unsigned int,unsigned int>, ex> A;
00023     compute_Poisson_element_matrix(fe, dof, A);  
00024     print(A); 
00025 
00026 
00027     initSyFi(3); 
00028 
00029     cout <<"3D ----------------------------"<<endl; 
00030     ReferenceTetrahedron tetrahedron; 
00031     CrouzeixRaviart fe2; 
00032     fe2.set_polygon(tetrahedron); 
00033     fe2.compute_basis_functions(); 
00034     usage(fe2); 
00035 
00036     Dof dof2; 
00037     std::map<std::pair<unsigned int,unsigned int>, ex> A2;
00038     compute_Poisson_element_matrix(fe2, dof2, A2);  
00039     print(A); 
00040 
00041 
00042     // regression test 
00043 
00044     archive ar; 
00045     for (unsigned int i=0; i<fe.nbf(); i++) {
00046             ar.archive_ex(fe.N(i), istr("N",i).c_str()); 
00047     }
00048 
00049     std::map<std::pair<unsigned int,unsigned int>, ex>::iterator iter; 
00050     for (iter = A.begin(); iter != A.end() ; iter++) {
00051             ar.archive_ex((*iter).second, istr("A", (*iter).first.first, (*iter).first.second).c_str());
00052     }
00053 
00054     for (unsigned int i=0; i<fe2.nbf(); i++) {
00055             ar.archive_ex(fe2.N(i), istr("N2_",i).c_str()); 
00056     }
00057 
00058     for (iter = A2.begin(); iter != A2.end() ; iter++) {
00059             ar.archive_ex((*iter).second, istr("A2_", (*iter).first.first, (*iter).first.second).c_str());
00060     }
00061 
00062 
00063 
00064     ofstream vfile("crouzeixraviart_ex.gar.v"); 
00065     vfile << ar; vfile.close(); 
00066     if(!compare_archives("crouzeixraviart_ex.gar.v", "crouzeixraviart_ex.gar.r")) { 
00067             cerr << "Failure!" << endl;
00068             return -1;
00069     }
00070 
00071     return 0; 
00072 }
00073 
00074 
00075 int main() {
00076     return check_CrouzeixRaviart(); 
00077 }
00078 
00079 
00080 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator