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(3); 00011 00012 ex p0 = lst(0.0,0.0,0.0); 00013 ex p1 = lst(1.0,0.0,0.0); 00014 ex p2 = lst(0.0,1.0,0.0); 00015 00016 00017 cout <<"\n\nThe reference triangle in 3D"<<endl; 00018 Triangle triangle(p0,p1,p2); 00019 cout <<triangle.str()<<endl; 00020 ex repr = triangle.repr(); 00021 cout <<"repr "<<repr<<endl; 00022 00023 cout <<"\n\nThe reference triangle in 3D by using Simplex"<<endl; 00024 lst vertices(p0,p1,p2); 00025 Simplex simplex(vertices); 00026 cout <<simplex.str()<<endl; 00027 repr = simplex.repr(); 00028 cout <<"repr "<<repr<<endl; 00029 00030 cout <<"\n\nThe sub-simplices (lines) on the reference triangle simplex in 3D"<<endl; 00031 for (unsigned int i=0; i<3; i++) { 00032 Simplex sub_simplex = simplex.sub_simplex(i); 00033 cout <<"\nsub simplex: "<<i<<"\n\t"<<sub_simplex.str() <<"\n\trepr "<< sub_simplex.repr()<<endl; 00034 for (unsigned int k=0; k< sub_simplex.no_vertices(); k++) { 00035 cout <<"\tv"<<k<<" "<<sub_simplex.vertex(k); 00036 } 00037 } 00038 00039 00040 00041 cout <<"\n\nThe reference tetrahedron"<<endl; 00042 ex p3 = lst(0.0,0.0,1.0); 00043 Tetrahedron tetrahedron(p0,p1,p2,p3); 00044 cout <<tetrahedron.str()<<endl; 00045 cout <<"repr "<<tetrahedron.repr()<<endl; 00046 00047 cout <<"\n\nThe reference tetrahedron represented by Simplex"<<endl; 00048 Simplex simplex3(lst(p0,p1,p2,p3)); 00049 cout <<simplex3.str()<<endl; 00050 cout <<"repr "<<simplex3.repr()<<endl; 00051 00052 00053 cout <<"\n\nThe integral of 1 over the reference tetrahedron represented by Simplex"<<endl; 00054 ex f = 1; 00055 std::cout <<" simplex3.integrate(f) = "<< simplex3.integrate(f) <<std::endl; 00056 00057 initSyFi(4); 00058 00059 ex q0 = lst(0.0,0.0,0.0,0.0); 00060 ex q1 = lst(1.0,0.0,0.0,0.0); 00061 ex q2 = lst(0.0,1.0,0.0,0.0); 00062 ex q3 = lst(0.0,0.0,1.0,0.0); 00063 ex q4 = lst(0.0,0.0,0.0,1.0); 00064 00065 cout <<"\n\nThe reference simplex in 4D"<<endl; 00066 Simplex simplex4(lst(q0,q1,q2,q3, q4)); 00067 cout <<simplex4.str()<<endl; 00068 cout <<"repr "<<simplex4.repr()<<endl; 00069 00070 cout <<"\n\nThe integral of 1 over the reference simplex in 4D"<<endl; 00071 std::cout <<" simplex4.integrate(f) = "<< simplex4.integrate(f) <<std::endl; 00072 00073 00074 00075 00076 initSyFi(5); 00077 00078 ex r0 = lst(0.0,0.0,0.0,0.0,0.0); 00079 ex r1 = lst(1.0,0.0,0.0,0.0,0.0); 00080 ex r2 = lst(0.0,1.0,0.0,0.0,0.0); 00081 ex r3 = lst(0.0,0.0,1.0,0.0,0.0); 00082 ex r4 = lst(0.0,0.0,0.0,1.0,0.0); 00083 ex r5 = lst(0.0,0.0,0.0,0.0,1.0); 00084 00085 cout <<"\n\nThe reference simplex in 4D"<<endl; 00086 Simplex simplex5(lst(r0,r1,r2,r3,r4,r5)); 00087 cout <<simplex5.str()<<endl; 00088 cout <<"repr "<<simplex5.repr()<<endl; 00089 00090 cout <<"\n\nThe integral of 1 over the reference simplex in 5D"<<endl; 00091 std::cout <<" simplex5.integrate(f) = "<< simplex5.integrate(f) <<std::endl; 00092 00093 00094 00095 00096 00097 00098 00099 } 00100 00101