Trisurf Monte Carlo simulator
Samo Penic
2014-09-10 a549778bfece819cf0b599168c571e400e6eb67d
src/io.c
@@ -10,7 +10,7 @@
#include <dirent.h>
#include "initial_distribution.h"
#include "poly.h"
#include "cell.h"
#include <getopt.h>
#include <sys/stat.h>
#include <sys/types.h>
@@ -169,8 +169,9 @@
        poly_list->poly->bond
*/
   fwrite(vesicle->clist, sizeof(ts_cell_list),1,  fh);
//   fwrite(vesicle->clist, sizeof(ts_cell_list),1,  fh);
/* write tape information on vesicle */
//    fwrite(vesicle->tape,sizeof(ts_tape),1,fh);
   fwrite(&iteration, sizeof(ts_uint),1,fh);
    fclose(fh);
    return TS_SUCCESS;
@@ -418,16 +419,12 @@
                vesicle->filament_list->poly[i]->blist->bond[j]->vtx2=vesicle->filament_list->poly[i]->vlist->vtx[idx];
        }
    }
    vesicle->tape=parsetape("tape");
// recreating space for cells // 
   vesicle->clist=(ts_cell_list *)malloc(sizeof(ts_cell_list));
   retval=fread(vesicle->clist, sizeof(ts_cell_list), 1,fh);
   vesicle->clist->cell=(ts_cell **)malloc(sizeof(ts_cell *)*vesicle->clist->ncmax[0]*vesicle->clist->ncmax[1]*vesicle->clist->ncmax[2]);
   for(i=0;i<vesicle->clist->ncmax[0]*vesicle->clist->ncmax[1]*vesicle->clist->ncmax[2];i++){
           vesicle->clist->cell[i]=(ts_cell *)calloc(1,sizeof(ts_cell));
           vesicle->clist->cell[i]->idx=i+1; // We enumerate cells! Probably never required!
       }
    vesicle->clist=init_cell_list(vesicle->tape->ncxmax, vesicle->tape->ncymax, vesicle->tape->nczmax, vesicle->tape->stepsize);
   vesicle->clist->max_occupancy=8;
//    vesicle->tape=(ts_tape *)malloc(sizeof(ts_tape));
//    retval=fread(vesicle->tape, sizeof(ts_tape),1,fh);
   retval=fread(iteration,sizeof(ts_uint),1,fh);
    if(retval); 
    fclose(fh);
@@ -918,6 +915,39 @@
ts_bool write_pov_file(ts_vesicle *vesicle, char *filename){
   FILE *fh;
   ts_uint i;
   fh=fopen(filename, "w");
   if(fh==NULL){
      err("Cannot open file %s for writing");
      return TS_FAIL;
   }
   for(i=0;i<vesicle->tlist->n;i++){
   fprintf(fh,"\ttriangle {");
   fprintf(fh,"\t<%e,%e,%e> <%e,%e,%e> <%e,%e,%e> }\n",
   vesicle->tlist->tria[i]->vertex[0]->x,
   vesicle->tlist->tria[i]->vertex[0]->y,
   vesicle->tlist->tria[i]->vertex[0]->z,
   vesicle->tlist->tria[i]->vertex[1]->x,
   vesicle->tlist->tria[i]->vertex[1]->y,
   vesicle->tlist->tria[i]->vertex[1]->z,
   vesicle->tlist->tria[i]->vertex[2]->x,
   vesicle->tlist->tria[i]->vertex[2]->y,
   vesicle->tlist->tria[i]->vertex[2]->z
   );
   }
   fclose(fh);
   return TS_SUCCESS;
}
ts_tape *parsetape(char *filename){
  //  long int nshell=17,ncxmax=60, ncymax=60, nczmax=60, npoly=10, nmono=20, pswitch=0;  // THIS IS DUE TO CONFUSE BUG!
    ts_tape *tape=(ts_tape *)calloc(1,sizeof(ts_tape));
@@ -937,8 +967,11 @@
   CFG_SIMPLE_INT("nfono",&tape->nfono),
   CFG_SIMPLE_INT("R_nucleus",&tape->R_nucleus),
   CFG_SIMPLE_FLOAT("dmax", &tape->dmax),
   CFG_SIMPLE_FLOAT("dmin_interspecies", &tape->dmin_interspecies),
        CFG_SIMPLE_FLOAT("xk0",&tape->xk0),
   CFG_SIMPLE_INT("pswitch",&tape->pswitch),
   CFG_SIMPLE_INT("constvolswitch",&tape->constvolswitch),
   CFG_SIMPLE_FLOAT("constvolprecision",&tape->constvolprecision),
   CFG_SIMPLE_FLOAT("pressure",&tape->pressure),
   CFG_SIMPLE_FLOAT("k_spring",&tape->kspring),
   CFG_SIMPLE_FLOAT("xi",&tape->xi),
@@ -954,6 +987,7 @@
        CFG_SIMPLE_INT("smp_cores",&tape->brezveze0),
        CFG_SIMPLE_INT("cluster_nodes",&tape->brezveze1),
        CFG_SIMPLE_INT("distributed_processes",&tape->brezveze2),
   CFG_SIMPLE_INT("spherical_harmonics_coefficients",&tape->shc),
        CFG_END()
    };
    cfg_t *cfg;