Trisurf Monte Carlo simulator
Samo Penic
2016-05-18 002b70ce9bba4475376eb4933f1e7c58cac89c57
commit | author | age
f4d6ca 1 /* vim: set ts=4 sts=4 sw=4 noet : */
SP 2 #include<stdio.h>
3 #include<math.h>
4 #include<stdlib.h>
5 #include "general.h"
6 //#include "vertex.h"
7 //#include "bond.h"
8 //#include "triangle.h"
9 //#include "cell.h"
10 #include "vesicle.h"
11 #include "io.h"
12 //#include "initial_distribution.h"
13 //#include "frame.h"
14 //#include "timestep.h"
15 //#include "poly.h"
16 #include "sh.h"
17 #include "shcomplex.h"
18 #include "dumpstate.h"
19 #include "restore.h"
20 #include <string.h>
21 #include <getopt.h>
22 #include <sys/stat.h>
23 #include <sys/types.h>
24 #include <dirent.h>
25 #include <errno.h>
26 #include <snapshot.h>
27 #include<gsl/gsl_complex.h>
28 #include<gsl/gsl_complex_math.h>
29
30
31 ts_vesicle *restoreVesicle(char *filename){
32     ts_vesicle *vesicle = parseDump(filename);
33     return vesicle;
34 }
35
36 void vesicle_calculate_ulm2(ts_vesicle *vesicle){
002b70 37     complex_sph_free(vesicle->sphHarmonics);
SP 38
f4d6ca 39     vesicle->sphHarmonics=complex_sph_init(vesicle->vlist,21);
SP 40     vesicle_volume(vesicle);
41     preparationSh(vesicle,getR0(vesicle));
42     calculateUlmComplex(vesicle);
43     ts_int i,j;
44     for(i=0;i<vesicle->sphHarmonics->l;i++){
aad500 45             for(j=i;j<2*i+1;j++){
f4d6ca 46             printf("%e ", gsl_complex_abs2(vesicle->sphHarmonics->ulmComplex[i][j]));
SP 47             }
48     }
49         printf("\n");
50
51 }
52
53 int main(){
54     ts_vesicle *vesicle;
55     ts_char *i,*j;
aad500 56     ts_uint tstep,n;
f4d6ca 57         ts_char *number;
aad500 58     struct dirent **list;
SP 59     int count;
f4d6ca 60     ts_fprintf(stdout,"TRISURF-NG v. %s, compiled on: %s %s.\n", TS_VERSION, __DATE__, __TIME__);
aad500 61     count=scandir(".",&list,0,alphasort);
SP 62     if(count<0){
63         fatal("Error, cannot open directory.",1);
64     }
65         tstep=0;
66     for(n=0;n<count;n++){
f4d6ca 67         struct dirent *ent;
aad500 68         ent=list[n];    
f4d6ca 69                 i=rindex(ent->d_name,'.');
002b70 70                 if(i==NULL) {
SP 71             free(ent);  
72             continue;
73         }
f4d6ca 74                 if(strcmp(i+1,"vtu")==0){
SP 75                     j=rindex(ent->d_name,'_');
76                     if(j==NULL) continue;
77                     number=strndup(j+1,j-i); 
78             quiet=1;
79                     ts_fprintf(stdout,"timestep: %u filename: %s\n",atoi(number),ent->d_name);
aad500 80             printf("%u ",atoi(number));
f4d6ca 81             vesicle=restoreVesicle(ent->d_name);
SP 82             vesicle_calculate_ulm2(vesicle);
83                         tstep++;
84             //vesicle_free(vesicle);
85                     free(number);
002b70 86             vesicle_free(vesicle);
aad500 87                 }
SP 88         free(ent);  
f4d6ca 89         }
aad500 90     free(list);
SP 91     return 0;
f4d6ca 92 }
SP 93