SyFi  0.3
hermite_ex1.cpp File Reference
#include <SyFi.h>
#include <fstream>

Go to the source code of this file.

Functions

int main ()

Function Documentation

int main ( )

Definition at line 8 of file hermite_ex1.cpp.

References SyFi::compare_archives(), SyFi::Hermite::compute_basis_functions(), compute_Poisson_element_matrix(), SyFi::initSyFi(), SyFi::istr(), SyFi::StandardFE::N(), SyFi::StandardFE::nbf(), print(), SyFi::StandardFE::set_polygon(), and SyFi::usage().

          { 

    initSyFi(2); 

    //---          2D Hermite element
    Triangle triangle(lst(0,0), lst(1,0), lst(0,1));   
    Hermite fe; 
    fe.set_polygon(triangle); 
    fe.compute_basis_functions(); 

    usage(fe); 

    Dof dof; 
    std::map<std::pair<unsigned int,unsigned int>, ex> A; 
    compute_Poisson_element_matrix(fe, dof, A); 
    print(A); 

    //---          3D Hermite element
    initSyFi(3); 

    Tetrahedron tetrahedron(lst(0,0,0), lst(1,0,0), lst(0,1,0), lst(0,0,1));   
    Hermite fe2; 
    fe2.set_polygon(tetrahedron); 
    fe2.compute_basis_functions(); 

    usage(fe2); 

    Dof dof2; 
    std::map<std::pair<unsigned int,unsigned int>, ex> A2; 
    compute_Poisson_element_matrix(fe2, dof2, A2); 
    print(A2); 

    // regression test 
    //

    archive ar; 
    for (unsigned int i=0; i<fe.nbf(); i++) {
            ar.archive_ex(fe.N(i), istr("N",i).c_str()); 
    }

    std::map<std::pair<unsigned int,unsigned int>, ex>::iterator iter; 
    for (iter = A.begin(); iter != A.end() ; iter++) {
            ar.archive_ex((*iter).second, istr("A", (*iter).first.first, (*iter).first.second).c_str());
    }

    for (unsigned int i=0; i<fe2.nbf(); i++) {
            ar.archive_ex(fe2.N(i), istr("N2_",i).c_str()); 
    }

    for (iter = A2.begin(); iter != A2.end() ; iter++) {
            ar.archive_ex((*iter).second, istr("A2_", (*iter).first.first, (*iter).first.second).c_str());
    }


    ofstream vfile("hermite_ex1.gar.v"); 
    vfile << ar; vfile.close(); 
    if(!compare_archives("hermite_ex1.gar.v", "hermite_ex1.gar.r")) { 
            cerr << "Failure!" << endl;
            return -1;
    }

    return 0;
}
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator