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