From 719c9febac2eaff9483fda487b57684afbb59bb2 Mon Sep 17 00:00:00 2001 From: Samo Penic <samo.penic@gmail.com> Date: Wed, 05 Mar 2014 16:47:50 +0000 Subject: [PATCH] dont know --- src/initial_distribution.c | 52 +++++++++++++++++++++++++++++++++------------------- 1 files changed, 33 insertions(+), 19 deletions(-) diff --git a/src/initial_distribution.c b/src/initial_distribution.c index 2444e15..dde08a4 100644 --- a/src/initial_distribution.c +++ b/src/initial_distribution.c @@ -20,7 +20,7 @@ ts_vesicle *vesicle=init_vesicle(no_vertices,ncmax1,ncmax2,ncmax3,stepsize); //TODO: debugging only. Please remove ASAP! - vesicle->bending_rigidity=25.0*25.0; + vesicle->bending_rigidity=25.0; vesicle->nshell=nshell; retval = vtx_set_global_values(vesicle); @@ -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); @@ -172,16 +173,16 @@ ts_double direct; // Something, dont know what, but could be normal of some kind for(i=1;i<=vlist->n;i++){ k++; // WHY i IS NOT GOOD?? - vtx_add_cneighbour(blist,tvtx[k], tvtx[vtx[i]->neigh[0]->idx+1]); //always add 1st + vtx_add_cneighbour(blist,tvtx[k], tvtx[vtx[i]->neigh->vtx[0]->idx+1]); //always add 1st jjj=1; jj=1; - for(l=2;l<=vtx[i]->neigh_no;l++){ - for(j=2;j<=vtx[i]->neigh_no;j++){ - dist2=vtx_distance_sq(vtx[i]->neigh[j-1],vtx[i]->neigh[jj-1]); - direct=vtx_direct(vtx[i],vtx[i]->neigh[j-1],vtx[i]->neigh[jj-1]); + for(l=2;l<=vtx[i]->neigh->n;l++){ + for(j=2;j<=vtx[i]->neigh->n;j++){ + dist2=vtx_distance_sq(vtx[i]->neigh->vtx[j-1],vtx[i]->neigh->vtx[jj-1]); + direct=vtx_direct(vtx[i],vtx[i]->neigh->vtx[j-1],vtx[i]->neigh->vtx[jj-1]); // TODO: check if fabs can be used with all floating point types!! if( (fabs(dist2-A0*A0)<=eps) && (direct>0.0) && (j!=jjj) ){ - vtx_add_cneighbour(blist,tvtx[k],tvtx[vtx[i]->neigh[j-1]->idx+1]); + vtx_add_cneighbour(blist,tvtx[k],tvtx[vtx[i]->neigh->vtx[j-1]->idx+1]); jjj=jj; jj=j; break; @@ -213,8 +214,8 @@ ts_uint i,j,k; for(i=1;i<=vlist->n;i++){ for(j=i+1;j<=vlist->n;j++){ - for(k=0;k<vtx[i]->neigh_no;k++){ // has changed 0 to < instead of 1 and <= - if(vtx[i]->neigh[k]==vtx[j]){ //if addresses matches it is the same + for(k=0;k<vtx[i]->neigh->n;k++){ // has changed 0 to < instead of 1 and <= + if(vtx[i]->neigh->vtx[k]==vtx[j]){ //if addresses matches it is the same bond_add(blist,vtx[i],vtx[j]); break; } @@ -239,15 +240,15 @@ ts_double eps=0.001; // can we use EPS from math.h? k=0; for(i=1;i<=vesicle->vlist->n;i++){ - for(j=1;j<=vtx[i]->neigh_no;j++){ - for(jj=1;jj<=vtx[i]->neigh_no;jj++){ + for(j=1;j<=vtx[i]->neigh->n;j++){ + for(jj=1;jj<=vtx[i]->neigh->n;jj++){ // ts_fprintf(stderr,"%u: (%u,%u) neigh_no=%u ",i,j,jj,vtx[i].neigh_no); // ts_fprintf(stderr,"%e, %e",vtx[i].neigh[j-1]->x,vtx[i].neigh[jj-1]->x); - dist=vtx_distance_sq(vtx[i]->neigh[j-1],vtx[i]->neigh[jj-1]); - direct=vtx_direct(vtx[i],vtx[i]->neigh[j-1],vtx[i]->neigh[jj-1]); + dist=vtx_distance_sq(vtx[i]->neigh->vtx[j-1],vtx[i]->neigh->vtx[jj-1]); + direct=vtx_direct(vtx[i],vtx[i]->neigh->vtx[j-1],vtx[i]->neigh->vtx[jj-1]); // TODO: same as above - if(fabs(dist-A0*A0)<=eps && direct < 0.0 && vtx[i]->neigh[j-1]->idx+1 > i && vtx[i]->neigh[jj-1]->idx+1 >i){ - triangle_add(tlist,vtx[i],vtx[i]->neigh[j-1],vtx[i]->neigh[jj-1]); + if(fabs(dist-A0*A0)<=eps && direct < 0.0 && vtx[i]->neigh->vtx[j-1]->idx+1 > i && vtx[i]->neigh->vtx[jj-1]->idx+1 >i){ + triangle_add(tlist,vtx[i],vtx[i]->neigh->vtx[j-1],vtx[i]->neigh->vtx[jj-1]); } } } @@ -342,11 +343,11 @@ ts_triangle **tria=tlist->tria -1; for(i=1;i<=vesicle->vlist->n;i++){ - for(j=1;j<=vtx[i]->neigh_no;j++){ - k1=vtx[i]->neigh[j-1]; + for(j=1;j<=vtx[i]->neigh->n;j++){ + k1=vtx[i]->neigh->vtx[j-1]; jp=j+1; - if(j == vtx[i]->neigh_no) jp=1; - k2=vtx[i]->neigh[jp-1]; + if(j == vtx[i]->neigh->n) jp=1; + k2=vtx[i]->neigh->vtx[jp-1]; for(k=1;k<=tlist->n;k++){ // VERY NON-OPTIMAL!!! too many loops (vlist.n * vtx.neigh * tlist.n )! k3=tria[k]->vertex[0]; k4=tria[k]->vertex[1]; @@ -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; +} -- Gitblit v1.9.3