From 42190fb471120cd6aafc9227081c57f7a0aca68e Mon Sep 17 00:00:00 2001
From: Samo Penic <samo.penic@gmail.com>
Date: Thu, 04 Jul 2019 20:04:10 +0000
Subject: [PATCH] Fixed the max_occupancy double -> int

---
 src/tspoststat.c |   59 ++++++++++++++++++++++++++++++++++++++++++++++++++++++-----
 1 files changed, 54 insertions(+), 5 deletions(-)

diff --git a/src/tspoststat.c b/src/tspoststat.c
index 4a318e2..f518000 100644
--- a/src/tspoststat.c
+++ b/src/tspoststat.c
@@ -18,6 +18,7 @@
 #include "shcomplex.h"
 #include "dumpstate.h"
 #include "restore.h"
+#include "cluster.h"
 #include <string.h>
 #include <getopt.h>
 #include <sys/stat.h>
@@ -27,7 +28,7 @@
 #include <snapshot.h>
 #include<gsl/gsl_complex.h>
 #include<gsl/gsl_complex_math.h>
-
+#include<stdio.h>
 
 ts_vesicle *restoreVesicle(char *filename){
 	ts_vesicle *vesicle = parseDump(filename);
@@ -51,17 +52,64 @@
 
 }
 
+
+
+int count_bonds_with_energy(ts_bond_list *blist){
+
+	unsigned int i, cnt;
+	cnt=0;
+	for(i=0;i<blist->n;i++){
+		if(fabs(blist->bond[i]->energy)>1e-16) cnt++;
+	}
+	return cnt;
+}
+
+
+
+ts_bool write_histogram_data(ts_uint timestep_no, ts_vesicle *vesicle){
+	ts_cluster_list *cstlist=init_cluster_list();
+	clusterize_vesicle(vesicle,cstlist);
+	//printf("No clusters=%d\n",cstlist->n);
+	int k,i,cnt, test=0;
+	int max_nvtx=0;
+	char filename[255];
+	sprintf(filename,"histogram_%.6u.csv",timestep_no);
+	FILE *fd=fopen(filename,"w");
+	fprintf(fd,"Number_of_vertices_in cluster Number_of_clusters\n");
+	for(k=0;k<cstlist->n;k++)
+		if(cstlist->cluster[k]->nvtx>max_nvtx) max_nvtx=cstlist->cluster[k]->nvtx;
+	//printf("Max. number of vertices in cluster: %d\n",max_nvtx);
+	for(i=1;i<=max_nvtx;i++){
+		cnt=0;
+		for(k=0;k<cstlist->n;k++)
+			if(cstlist->cluster[k]->nvtx==i) cnt++;
+		fprintf(fd,"%d %d\n",i,cnt);
+		test+=cnt*i;
+	}
+	//for(k=0;k<cstlist->n;k++){
+//		printf("*Cluster %d has %d vertices\n",k,cstlist->cluster[k]->nvtx);
+//	}
+
+	fclose(fd);
+//	printf("*Sum of all vertices in clusters: %d\n", test);
+//	write_vertex_xml_file(vesicle,timestep_no,cstlist);
+	cluster_list_free(cstlist);
+	
+	return TS_SUCCESS;
+}
+
+
 int main(){
 	ts_vesicle *vesicle;
 	ts_char *i,*j;
 	ts_uint tstep,n;
     	ts_char *number;
 	struct dirent **list;
-	ts_double l1,l2,l3;
+	ts_double l1,l2,l3,hbar;
 	int count;
 	ts_fprintf(stderr,"TRISURF-NG v. %s, compiled on: %s %s.\n", TS_VERSION, __DATE__, __TIME__);
 
-	fprintf(stdout, "OuterLoop Volume Area lamdba1 lambda2 lambda3 Nb/Ncb\n");
+	fprintf(stdout, "OuterLoop Volume Area lamdba1 lambda2 lambda3 Nbw/Nb hbar\n");
 
 
 	count=scandir(".",&list,0,alphasort);
@@ -88,9 +136,10 @@
 			vesicle_volume(vesicle);
 			vesicle_area(vesicle);
 			gyration_eigen(vesicle,&l1,&l2,&l3);
-			fprintf(stdout,"%d %.17e %.17e %.17e %.17e %.17e\n",atoi(number),vesicle->volume, vesicle->area,l1,l2,l3),
+			hbar=vesicle_meancurvature(vesicle)/vesicle->area;			
+			fprintf(stdout,"%d %.17e %.17e %.17e %.17e %.17e %.17e %.17e\n",atoi(number),vesicle->volume, vesicle->area,l1,l2,l3, (ts_double)count_bonds_with_energy(vesicle->blist)/(ts_double)vesicle->blist->n,hbar);
                     	tstep++;
-
+			write_histogram_data(atoi(number), vesicle);
                     free(number);
 			tape_free(vesicle->tape);
 			vesicle_free(vesicle);

--
Gitblit v1.9.3