Trisurf Monte Carlo simulator
Samo Penic
2013-12-07 d335d9af322ef4b32d22c0b25b6ff540a2febebf
Changes in ts_bond data structure, bond.c added assign_triangles functions that is called in initial_distribution for each bond.
5 files modified
41 ■■■■■ changed files
src/bond.c 22 ●●●●● patch | view | raw | blame | history
src/bond.h 2 ●●● patch | view | raw | blame | history
src/general.h 1 ●●●● patch | view | raw | blame | history
src/initial_distribution.c 14 ●●●●● patch | view | raw | blame | history
src/initial_distribution.h 2 ●●● patch | view | raw | blame | history
src/bond.c
@@ -30,10 +30,32 @@
    blist->bond[blist->n - 1]->vtx2=vtx2;
    blist->bond[blist->n - 1]->tainted=0;
    //Should we calculate bond length NOW?
    
    return blist->bond[blist->n-1];
}
/* Two triangles are assigned to the bond. Bond must already be initialized. */
ts_bool bond_assign_triangles(ts_bond *bond){
    ts_vertex *vtx1=bond->vtx1, *vtx2=bond->vtx2;
    ts_uint i,j,k;
    for(i=0,k=0;i<vtx1->tristar_no;i++){
        for(j=0;j<3;j++){
            if(vtx1->tristar[i]->vertex[j]==vtx2){
                //triangle found;
                bond->tria[k]=vtx1->tristar[i];
                k++;
            }
        }
    }
    if(k<2) return TS_FAIL;
    else return TS_SUCCESS;
}
ts_bool bond_list_free(ts_bond_list *blist){
    ts_uint i;
    for(i=0;i<blist->n;i++){
src/bond.h
@@ -19,7 +19,7 @@
 *  system.
 */
ts_bond *bond_add(ts_bond_list *blist, ts_vertex *vtx1, ts_vertex *vtx2);
ts_bool bond_assign_triangles(ts_bond *bond);
ts_bool bond_list_free(ts_bond_list *blist);
src/general.h
@@ -176,6 +176,7 @@
    ts_uint idx;
    ts_vertex *vtx1;
    ts_vertex *vtx2;
    struct ts_triangle *tria[2];
    ts_double bond_length;
    ts_double bond_length_dual;
    ts_bool tainted;
src/initial_distribution.c
@@ -32,6 +32,7 @@
    retval = init_triangle_neighbours(vesicle);
    retval = init_common_vertex_triangle_neighbours(vesicle);
    retval = init_normal_vectors(vesicle->tlist);
    retval = init_bond_triangles(vesicle->blist);
    retval = mean_curvature_and_energy(vesicle);
 ts_fprintf(stderr,"initial_distribution finished!\n");
    if(retval);
@@ -382,3 +383,16 @@
    }
    return TS_SUCCESS;
}
ts_bool init_bond_triangles(ts_bond_list *blist){
    ts_uint i;
    ts_bool retval;
    for(i=0;i<blist->n;i++){
        retval=bond_assign_triangles(blist->bond[i]);
        if(retval==TS_FAIL){
            fatal("Bond %u does not have 2 triangles. Possible error in structure.",156);
        }
    }
    return TS_SUCCESS;
}
src/initial_distribution.h
@@ -33,4 +33,4 @@
ts_bool init_triangle_neighbours(ts_vesicle *vesicle);
ts_bool init_common_vertex_triangle_neighbours(ts_vesicle *vesicle);
ts_bool init_normal_vectors(ts_triangle_list *tlist);
ts_bool init_bond_triangles(ts_bond_list *blist);