fe_ex1.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 void example_of_use(FE& fe) {
00009 ex Ni;
00010 ex gradNi;
00011 ex dofi;
00012 for (int i=0; i< fe.nbf() ; i++) {
00013 Ni = fe.N(i);
00014 gradNi = grad(Ni);
00015 dofi = fe.dof(i);
00016 cout <<"The basis function, N("<<i<<")="<<Ni<<endl;
00017 cout <<"The gradient of N("<<i<<")="<<gradNi<<endl;
00018 cout <<"The corresponding dof, L("<<i<<")="<<dofi<<endl;
00019 }
00020 }
00021
00022
00023
00024 int main(){
00025
00026 initSyFi(2);
00027
00028 int order = 1;
00029 Triangle triangle(lst(0,0), lst(1,0), lst(0,1));
00030 Lagrange fe;
00031 fe.set_order(order);
00032 fe.set_polygon(triangle);
00033 fe.compute_basis_functions();
00034
00035 example_of_use(fe);
00036
00037
00038
00039 archive ar;
00040 for (int i=0; i< fe.nbf(); i++) {
00041 ar.archive_ex(fe.N(i) , istr("N",i).c_str());
00042 ar.archive_ex(fe.dof(i) , istr("D",i).c_str());
00043 }
00044
00045 ofstream vfile("fe_ex1.gar.v");
00046 vfile << ar; vfile.close();
00047 if(!compare_archives("fe_ex1.gar.v", "fe_ex1.gar.r")) {
00048 cerr << "Failure!" << endl;
00049 return -1;
00050 }
00051
00052 return 0;
00053 }
00054
00055