From dac2e5020dc34c236b741ff5c4591244e73f56f2 Mon Sep 17 00:00:00 2001
From: Samo Penic <samo@andromeda>
Date: Tue, 28 Dec 2010 23:48:08 +0000
Subject: [PATCH] Rewrite of frame is complete.

---
 src/cell.c                 |    2 +-
 src/main.c                 |    7 ++++++-
 src/vertex.c               |   13 ++++++++++++-
 src/energy.c               |    4 +++-
 src/initial_distribution.c |    3 ++-
 src/frame.c                |    8 ++++----
 src/triangle.c             |    3 ++-
 src/vertex.h               |    1 +
 8 files changed, 31 insertions(+), 10 deletions(-)

diff --git a/src/cell.c b/src/cell.c
index 26ce2d6..1d66bc6 100644
--- a/src/cell.c
+++ b/src/cell.c
@@ -76,7 +76,7 @@
 ts_bool cell_add_vertex(ts_cell *cell, ts_vertex *vtx){
     cell->data->nvertex++;
 	cell->data->vertex=(ts_vertex **)realloc(cell->data->vertex,cell->data->nvertex*sizeof(ts_vertex *));
-		if(vtx->data->neigh == NULL){
+		if(cell->data->vertex == NULL){
 			fatal("Reallocation of memory failed during insertion of vertex in cell_add_vertex",3);
         }
     cell->data->vertex[cell->data->nvertex-1]=vtx;
diff --git a/src/energy.c b/src/energy.c
index e30295b..4f37474 100644
--- a/src/energy.c
+++ b/src/energy.c
@@ -118,7 +118,9 @@
         data->curvature=-sqrtl(h);
     }
 #endif
-//TODO: MAJOR!!!! What is vtx->data->c?????????????? Here it is 0!
+// What is vtx->data->c?????????????? Here it is 0!
+// c is forced curvature energy for each vertex. Should be set to zero for
+// norman circumstances.
     data->energy=0.5*s*(data->curvature/s-data->c)*(data->curvature/s-data->c);
 
     return TS_SUCCESS;
diff --git a/src/frame.c b/src/frame.c
index a578188..aa3c6e5 100644
--- a/src/frame.c
+++ b/src/frame.c
@@ -13,9 +13,9 @@
         vesicle->cm[1]+=vtx[i]->data->y;
         vesicle->cm[2]+=vtx[i]->data->z; 
     } 
-    vesicle->cm[0]/=(float)n;
-    vesicle->cm[1]/=(float)n;
-    vesicle->cm[2]/=(float)n;
+    vesicle->cm[0]/=(ts_float)n;
+    vesicle->cm[1]/=(ts_float)n;
+    vesicle->cm[2]/=(ts_float)n;
     return TS_SUCCESS;
 }
 
@@ -28,7 +28,6 @@
 
     cell_list_cell_occupation_clear(vesicle->clist);
     for(i=0;i<n;i++){
-  
     cellidx=vertex_self_avoidance(vesicle, vesicle->vlist->vtx[i]);
     vesicle->vlist->vtx[i]->data->cell=vesicle->clist->cell[cellidx];
 
@@ -38,6 +37,7 @@
   //  if(ncy > vesicle->clist.ncmax[1]) vesicle->clist.ncmax[1]=ncy;
   //  if(ncz > vesicle->clist.ncmax[2]) vesicle->clist.ncmax[2]=ncz;
     }
+    //fprintf(stderr, "Bil sem tu\n"); 
 
 
 /* This was already done in previous for loop.... Have I gained some time? 
diff --git a/src/initial_distribution.c b/src/initial_distribution.c
index 00d9138..a88014b 100644
--- a/src/initial_distribution.c
+++ b/src/initial_distribution.c
@@ -25,6 +25,7 @@
     retval = init_triangles(vesicle);
     retval = init_triangle_neighbours(vesicle);
     retval = init_common_vertex_triangle_neighbours(vesicle);
+    retval = init_normal_vectors(vesicle->tlist);
     retval = mean_curvature_and_energy(vesicle);
  ts_fprintf(stderr,"initial_distribution finished!\n");
 	return vesicle;
@@ -348,7 +349,7 @@
 
 //TODO: probably something wrong with neighbour distribution.
 //                if(vtx[i]==k3 || vtx[i]==k4 || vtx[i]==k5){
-//                    if(i==6) ts_fprintf(stdout, "Vtx[%u] > Added to tristar!\n",i);
+    //                    if(i==6) ts_fprintf(stdout, "Vtx[%u] > Added to tristar!\n",i);
                     vertex_add_tristar(vtx[i],tria[k]);
                 }
             }
diff --git a/src/main.c b/src/main.c
index d4cc0c8..96473ba 100644
--- a/src/main.c
+++ b/src/main.c
@@ -8,6 +8,7 @@
 #include "vesicle.h"
 #include "io.h"
 #include "initial_distribution.h"
+#include "frame.h"
 
 /** Entrance function to the program
   * @param argv is a number of parameters used in program call (including the program name
@@ -57,7 +58,11 @@
 
 vtx_list_free(vlist1);
 printf("Tests complete.\n");
-vesicle=initial_distribution_dipyramid(17,10,10,10,0.15);
+vesicle=initial_distribution_dipyramid(17,60,60,60,0.15);
+
+centermass(vesicle);
+cell_occupation(vesicle);
+
 write_vertex_xml_file(vesicle,0);
 write_master_xml_file("test.pvd");
 write_dout_fcompat_file(vesicle,"dout");
diff --git a/src/triangle.c b/src/triangle.c
index 53143af..a41f3b5 100644
--- a/src/triangle.c
+++ b/src/triangle.c
@@ -72,7 +72,8 @@
   * Add the neigbour to the list of neighbouring triangles. The
   * neighbouring triangles are those, who share two vertices. Function resizes
   * the list and adds the pointer to neighbour. It receives two arguments of
-  * ts_triangle type. It then adds eachother to eachother's list. Upon
+  * ts_triangle type. It then adds second triangle to the list of first
+  * triangle, but not the opposite. Upon
   * success it returns TS_SUCCESS, upon detecting NULL pointers 
   * returns TS_FAIL and it FATALY ends when the data structure
   * cannot be resized.
diff --git a/src/vertex.c b/src/vertex.c
index ccd661e..b5f8519 100644
--- a/src/vertex.c
+++ b/src/vertex.c
@@ -144,7 +144,8 @@
     if(data->neigh!=NULL)   free(data->neigh);
     if(data->tristar!=NULL) free(data->tristar);
     if(data->bond!=NULL)    free(data->bond);
-    if(data->cell!=NULL)    free(data->cell);
+//Cells are freed separately.
+ //   if(data->cell!=NULL)    free(data->cell);
     free(data);
     return TS_SUCCESS;
 }
@@ -235,11 +236,21 @@
     cvtx->data->cell=NULL;
     return TS_SUCCESS;
 }
+
+ts_bool vtx_duplicate(ts_vertex *cvtx, ts_vertex *ovtx){
+    memcpy((void *)cvtx,(void *)ovtx,sizeof(ts_vertex));
+    cvtx->data=(ts_vertex_data *)malloc(sizeof(ts_vertex_data));
+    memcpy((void *)cvtx->data,(void *)ovtx->data,sizeof(ts_vertex_data));
+    return TS_SUCCESS;
+}
+
 //TODO: needs to be done
 ts_vertex **vtx_neigh_copy(ts_vertex_list *vlist,ts_vertex *ovtx){
         return NULL;
 }
 
+
+
 ts_vertex_list *vertex_list_copy(ts_vertex_list *ovlist){
     ts_uint i;
     ts_vertex_list *vlist=(ts_vertex_list *)malloc(sizeof(ts_vertex_list));
diff --git a/src/vertex.h b/src/vertex.h
index 0c61c85..0d0c27c 100644
--- a/src/vertex.h
+++ b/src/vertex.h
@@ -28,6 +28,7 @@
 inline ts_bool vertex_add_tristar(ts_vertex *vtx, ts_triangle *tristarmem);
 
 ts_bool vtx_copy(ts_vertex *cvtx,ts_vertex *ovtx);
+ts_bool vtx_duplicate(ts_vertex *cvtx, ts_vertex *ovtx);
 ts_vertex **vtx_neigh_copy(ts_vertex_list *vlist,ts_vertex *ovtx);
 ts_vertex_list *vertex_list_copy(ts_vertex_list *ovlist);
 

--
Gitblit v1.9.3