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/bondflip.c |   73 +++++++++++++-----------------------
 1 files changed, 26 insertions(+), 47 deletions(-)

diff --git a/src/bondflip.c b/src/bondflip.c
index cc29021..4ceaf2b 100644
--- a/src/bondflip.c
+++ b/src/bondflip.c
@@ -15,10 +15,10 @@
 ts_bool single_bondflip_timestep(ts_vesicle *vesicle, ts_bond *bond, ts_double *rn){
 /*c  Vertex and triangle (lm and lp) indexing for bond flip:
 c      +----- k-------+              +----- k ------+
-c      |lm1 / | \ lp1 |              |lm1 /   \ lp1 |
+c      |lm1 / ^ \ lp1 |              |lm1 /   \ lp1 |
 c      |  /   |   \   |              |  /       \   |
 c      |/     |     \ |     FLIP     |/    lm     \ |
-c     km  lm  | lp   kp    --->      km ---------- kp  
+c     km  lm  | lp   kp    --->      km ---------> kp  
 c      |\     |     / |              |\    lp     / |  
 c      |  \   |   /   |              |  \       /   |
 c      |lm2 \ | / lp2 |              |lm2 \   / lp2 |
@@ -113,7 +113,7 @@
 #endif
         {
             //not accepted, reverting changes
-       //     fprintf(stderr,"Failed to move, due to MC\n");
+            fprintf(stderr,"Failed to move, due to MC\n");
 
 //            ts_flip_bond(km,kp,it,k, bond);
             ts_flip_bond(bond);
@@ -142,7 +142,7 @@
             return TS_FAIL;
         }
     }
-        //    fprintf(stderr,"Success\n");
+            fprintf(stderr,"Success\n");
 
 
 /* IF BONDFLIP ACCEPTED, THEN RETURN SUCCESS! */
@@ -153,49 +153,8 @@
 ts_bool ts_flip_bond(ts_bond *bond){
 fprintf(stderr,"Called!\n");
     ts_triangle *lm=NULL,*lp=NULL, *lp1=NULL, *lm2=NULL;
-    ts_uint i; //lmidx, lpidx;
-/*This is no longer necessary! if(k==NULL || it==NULL || km==NULL || kp==NULL){
-    fatal("ts_flip_bond: You called me with invalid pointers to vertices",999);
-}*/
-// 1. step. We find lm and lp from k->tristar !
-/*    for(i=0;i<it->tristar_no;i++){
-        for(j=0;j<k->tristar_no;j++){
-            if((it->tristar[i] == k->tristar[j])){ //ce gre za skupen trikotnik
-                if((it->tristar[i]->vertex[0] == km || it->tristar[i]->vertex[1]
-== km || it->tristar[i]->vertex[2]== km )){
-                lm=it->tristar[i];
-         //       lmidx=i;
-                }
-                else
-                {
-                lp=it->tristar[i];
-         //       lpidx=i;
-                }
+    ts_uint i,j; //lmidx, lpidx;
 
-            }
-        }
-    }
-if(lm==NULL || lp==NULL) fatal("ts_flip_bond: Cannot find triangles lm and lp!",999);
-
-//we look for important triangles lp1 and lm2.
-
- for(i=0;i<k->tristar_no;i++){
-        for(j=0;j<kp->tristar_no;j++){
-                if((k->tristar[i] == kp->tristar[j]) && k->tristar[i]!=lp){ //ce gre za skupen trikotnik
-                    lp1=k->tristar[i];
-            }
-        }
-}
-
- for(i=0;i<it->tristar_no;i++){
-        for(j=0;j<km->tristar_no;j++){
-            if((it->tristar[i] == km->tristar[j]) && it->tristar[i]!=lm){ //ce gre za skupen trikotnik
-                    lm2=it->tristar[i];
-            } 
-        }
-    }
-*/
-//Upper block no longer neccessary.
 ts_vertex *it=bond->vtx1;
 ts_vertex *k=bond->vtx2;
 ts_vertex *km=bond->adjvtx[0];
@@ -219,6 +178,22 @@
 */
 //find bonds between k and kp (adj[1] vtx)
 //find bonds between it and km (adj[0] vtx)
+
+for(i=0;i<3;i++){
+if(lm->neigh[i]==lp) break;
+	for(j=0;j<3;j++){
+		if(lm->neigh[i]->vertex[j]==it) lm2=lm->neigh[i];
+	}
+}
+
+for(i=0;i<3;i++){
+if(lp->neigh[i]==lm) break;
+	for(j=0;j<3;j++){
+		if(lp->neigh[i]->vertex[j]==k) lp1=lp->neigh[i];
+	}
+}
+
+/*
 for(i=0;i<it->tristar_no;i++){
 	if((it->tristar[i]->vertex[0]==km || it->tristar[i]->vertex[1]==km || it->tristar[i]->vertex[2]==km) && (it->tristar[i]->vertex[0]==it || it->tristar[i]->vertex[1]==it || it->tristar[i]->vertex[2]==it)){
 		lm2=it->tristar[i];
@@ -227,7 +202,11 @@
 		lp1=it->tristar[i];
 	}
 }
+*/
+if(lm2==NULL ) fatal("ts_flip_bond: Cannot find triangles lm2!",999);
+if(lp1==NULL ) fatal("ts_flip_bond: Cannot find triangles lp1!",999);
 if(lm2==NULL || lp1==NULL) fatal("ts_flip_bond: Cannot find triangles lm2 and lp1!",999);
+
 /*
 //DEBUG TESTING
 fprintf(stderr,"1. step: lm, lm2, lp1 and lp found!\n");
@@ -347,9 +326,9 @@
   energy_vertex(it);
 
 //Extra steps for new bond data structure
+
 bond->adjvtx[0]=k;
 bond->adjvtx[1]=it;
-
 // END modifications to data structure!
 
 

--
Gitblit v1.9.3