From d335d9af322ef4b32d22c0b25b6ff540a2febebf Mon Sep 17 00:00:00 2001 From: Samo Penic <samo.penic@gmail.com> Date: Sat, 07 Dec 2013 21:29:57 +0000 Subject: [PATCH] Changes in ts_bond data structure, bond.c added assign_triangles functions that is called in initial_distribution for each bond. --- src/bond.h | 2 +- src/initial_distribution.h | 2 +- src/bond.c | 22 ++++++++++++++++++++++ src/initial_distribution.c | 14 ++++++++++++++ src/general.h | 1 + 5 files changed, 39 insertions(+), 2 deletions(-) diff --git a/src/bond.c b/src/bond.c index af39532..85daf92 100644 --- a/src/bond.c +++ b/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++){ diff --git a/src/bond.h b/src/bond.h index e2be586..3b6e24d 100644 --- a/src/bond.h +++ b/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); diff --git a/src/general.h b/src/general.h index 03dcc1d..6497c14 100644 --- a/src/general.h +++ b/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; diff --git a/src/initial_distribution.c b/src/initial_distribution.c index f507d50..dde08a4 100644 --- a/src/initial_distribution.c +++ b/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; +} diff --git a/src/initial_distribution.h b/src/initial_distribution.h index 7b3e2ba..c119cfb 100644 --- a/src/initial_distribution.h +++ b/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); -- Gitblit v1.9.3