예제 #1
0
파일: read_gmsh2.c 프로젝트: onlyacan/fsc
/*
  read_gmsh: read the gmsh II file and output a pointer to mesh structure 
  ckecked: ok
*/
mesh *read_gmsh(const char *fname)
{

    id i; // index cell 
    id j; // index for face in all faces 
    id k; // index for faces in one cell 
    gmsh_raw *gmsh; 
    mesh *m; 

    // open mesh file and allocate gmsh strucut
    fp = sfopen(fname, "in read_gmsh() for fp");     
    gmsh = smalloc(sizeof(gmsh_raw)*1, "in read_gmsh, for gmsh");
    
    /*find the opening mark, and read the text blocks*/
    while(fgets(line, MAXLINE, fp) != NULL){ // read line by line 
        if (sscanf(line, "%s", w) == 1){
            if (strcmp(w, "$PhysicalNames") == 0) read_physicalNames(fp, gmsh);  
            if (strcmp(w, "$Nodes") == 0)         read_nodes(fp, gmsh);  
            if (strcmp(w, "$Elements") == 0)      read_elems(fp, gmsh);  
        }
    }

    /* construct mesh from elements*/
    m = elems_to_mesh(gmsh);

    /* sort the faces according to its 3 types: boundary, salve, nb*/ 
    sort_faces();

    /*clean up*/
    fclose(fp);
    free(facetypes);

    return m;
}
예제 #2
0
파일: mesh.cpp 프로젝트: melmi/shuncu
mesh::mesh(std::string vfile_name, std::string sfile_name, std::string efile_name)
{
    std::ifstream vfile(vfile_name.c_str()), sfile(sfile_name.c_str()), efile(efile_name.c_str());

    vfile >> nv;
    sfile >> ns;
    efile >> ne;

    v = new vertex[nv];
    s = new side[ns];
    e = new element[ne];

    read_vertices(vfile);
    read_sides(sfile);
    read_elems(efile);

    vfile.close();
    sfile.close();
    efile.close();

    compute_geom_props();
    init_boundary_vertices();
    init_boundary_sides();

    ncolors = edge_coloring::do_edge_coloring(*this, false);
    nbcolors = edge_coloring::do_edge_coloring(*this, true);

    init_color_sides();
    init_b_color_sides();
}
예제 #3
0
파일: poly.cpp 프로젝트: mors741/Polynom
int main()
{
    struct item *head = NULL;
    read_elems(&head);
    print_list(head);
    format(head);
    print_list(head);
    znach(head);
    return 0;
}