Trisurf Monte Carlo simulator
Samo Penic
2016-02-29 698ae18f535c3e388b6ebcdca1582005a29ff2f2
Tape is in the dump and successfully restored.
7 files modified
61 ■■■■ changed files
src/initial_distribution.c 12 ●●●● patch | view | raw | blame | history
src/initial_distribution.h 2 ●●● patch | view | raw | blame | history
src/io.c 16 ●●●●● patch | view | raw | blame | history
src/io.h 3 ●●●● patch | view | raw | blame | history
src/restore.c 21 ●●●● patch | view | raw | blame | history
src/restore.h 1 ●●●● patch | view | raw | blame | history
src/snapshot.c 6 ●●●● patch | view | raw | blame | history
src/initial_distribution.c
@@ -39,11 +39,17 @@
ts_vesicle *create_vesicle_from_tape(ts_tape *tape){
    ts_vesicle *vesicle;
    ts_vertex *vtx;
    vesicle=initial_distribution_dipyramid(tape->nshell,tape->ncxmax,tape->ncymax,tape->nczmax,tape->stepsize);
    vesicle->tape=tape;
        vesicle->tape=tape;
    set_vesicle_values_from_tape(vesicle);
    return vesicle;
}
ts_bool set_vesicle_values_from_tape(ts_vesicle *vesicle){
    // Nucleus:
    ts_vertex *vtx;
    ts_tape *tape=vesicle->tape;
    vesicle->R_nucleus=tape->R_nucleus*tape->R_nucleus;
    vesicle->clist->dmin_interspecies = tape->dmin_interspecies*tape->dmin_interspecies;
@@ -101,7 +107,7 @@
    else {
        vesicle->sphHarmonics=NULL;
    }
    return vesicle;
    return TS_SUCCESS;
}
src/initial_distribution.h
@@ -13,7 +13,7 @@
ts_vesicle *initial_distribution_dipyramid(ts_uint nshell, ts_uint ncmax1, ts_uint ncmax2, ts_uint ncmax3, ts_double stepsize);
ts_vesicle *create_vesicle_from_tape(ts_tape *tape);
ts_bool set_vesicle_values_from_tape(ts_vesicle *vesicle);
/** Sets the initial position of the vertexes to dipyramid
 *
 *      @param *vlist is a pointer to list of vertices
src/io.c
@@ -1000,6 +1000,20 @@
ts_tape *parsetape(char *filename){
    FILE *fd = fopen (filename, "r");
    long length;
    size_t size;
    fseek (fd, 0, SEEK_END);
      length = ftell (fd);
    fseek (fd, 0, SEEK_SET);
    size=fread (tapetxt, 1, length, fd);
    fclose(fd);
    if(size);
    ts_tape *tape=parsetapebuffer(tapetxt);
    return tape;
}
ts_tape *parsetapebuffer(char *buffer){
    ts_tape *tape=(ts_tape *)calloc(1,sizeof(ts_tape));
    tape->multiprocessing=calloc(255,sizeof(char));
@@ -1038,7 +1052,7 @@
    cfg_t *cfg;    
    ts_uint retval;
    cfg = cfg_init(opts, 0);
    retval=cfg_parse(cfg, filename);
    retval=cfg_parse_buf(cfg, buffer);
    if(retval==CFG_FILE_ERROR){
    fatal("No tape file.",100);
    }
src/io.h
@@ -7,7 +7,7 @@
static ts_bool restore=0;
static char tape[1024]; */
int force_from_tape;
char tapetxt[128000]; //stores text file of the tape
typedef struct{
    ts_int force_from_tape;
    ts_int reset_iteration_count;
@@ -76,6 +76,7 @@
ts_bool write_pov_file(ts_vesicle *vesicle, char *filename);
ts_tape *parsetape(char *filename);
ts_tape *parsetapebuffer(char *buffer);
ts_bool tape_free(ts_tape *tape);
ts_bool getcmdline_tape(cfg_t *cfg, char *opts);
ts_bool cmdline_to_tape(cfg_t *cfg, char *key, char *val);
src/restore.c
@@ -14,12 +14,12 @@
#include "energy.h"
#include "poly.h"
#include "initial_distribution.h"
#include "io.h"
ts_bool parseDump(char *dumpfname) {
    xmlDocPtr doc;
    xmlNodePtr cur, cur1,cur2;
    ts_vesicle *vesicle=NULL;
    doc = xmlParseFile(dumpfname);
    
    if (doc == NULL ) {
@@ -38,6 +38,11 @@
    
    cur = cur->xmlChildrenNode;
    while (cur != NULL) {
        if ((!xmlStrcmp(cur->name, (const xmlChar *)"tape"))){
            setGlobalTapeTXTfromTapeTag(doc, cur);
        }
        if ((!xmlStrcmp(cur->name, (const xmlChar *)"trisurf"))){
            vesicle=parseTrisurfTag(doc, cur);
        }
@@ -84,6 +89,12 @@
    return TS_SUCCESS;
}
ts_bool setGlobalTapeTXTfromTapeTag(xmlDocPtr doc, xmlNodePtr cur){
    xmlChar *tape = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
    strcpy(tapetxt,(char *)tape);
    xmlFree(tape);
    return TS_SUCCESS;
}
/* this is a parser of additional data in xml */
@@ -129,8 +140,10 @@
    nvtx = xmlGetProp(cur, (xmlChar *)"nvtx");
    npoly=xmlGetProp(cur, (xmlChar *)"npoly");
    nfono=xmlGetProp(cur, (xmlChar *)"nfono");
    fprintf(stderr,"nvtx=%u\n",atoi((char *)nvtx));
    ts_vesicle *vesicle=init_vesicle(atoi((char *)nvtx),10,10,10,0.1);
    ts_tape *tape=parsetapebuffer(tapetxt);
    //fprintf(stderr,"nvtx=%u\n",atoi((char *)nvtx));
    //TODO: check if nvtx is in agreement with nshell from tape
    ts_vesicle *vesicle=init_vesicle(atoi((char *)nvtx),tape->ncxmax,tape->ncymax,tape->nczmax,tape->stepsize);
    //vesicle->poly_list=init_poly_list(atoi((char *)npoly),atoi((char *)nmono), vesicle->vlist, vesicle);
    xmlFree(nvtx);
    xmlFree(npoly);
@@ -155,6 +168,8 @@
    }
    vesicle->tape=tape;
    set_vesicle_values_from_tape(vesicle);
    return vesicle;
}
src/restore.h
@@ -3,6 +3,7 @@
ts_bool parseDump(char *dumpfname);
ts_vesicle *parseTrisurfTag(xmlDocPtr doc, xmlNodePtr cur);
ts_bool setGlobalTapeTXTfromTapeTag(xmlDocPtr doc, xmlNodePtr cur);
ts_bool parseTrisurfVtxn(ts_vertex_list *vlist, xmlDocPtr doc, xmlNodePtr cur);
ts_bool parseTrisurfTria(ts_vesicle *vesicle, xmlDocPtr doc, xmlNodePtr cur);
ts_bool parseTrisurfTriaNeigh(ts_vesicle *vesicle, xmlDocPtr doc, xmlNodePtr cur);
src/snapshot.c
@@ -7,7 +7,7 @@
#include<inttypes.h>
#include<config.h>
#include <time.h>
#include "io.h"
/* a helper function that utilizes ts_string data structure and performs same as sprintf */
ts_uint ts_sprintf(ts_string *str, char *fmt, ...){
    va_list ap;
@@ -56,7 +56,7 @@
    fprintf(fh, "<dumpdate>%s</dumpdate>\n", c_time_string);
    fprintf(fh, "<tape>\n");
        fprintf(fh,"%s",tapetxt);
    fprintf(fh, "</tape>\n");
    if(vesicle->poly_list!=NULL){
        npoly=vesicle->poly_list->n;
@@ -69,7 +69,7 @@
        npoly=0;
        nfono=0;
    }
    fprintf(fh, "<trisurf nvtx=\"%u\" npoly=\"%u\" nfono=\"%u\">\n", vesicle->vlist->n, npoly, nfono);
    fprintf(fh, "<trisurf nvtx=\"%u\" npoly=\"%u\" nfono=\"%u\" compressed=\"false\">\n", vesicle->vlist->n, npoly, nfono);
    return TS_SUCCESS;
}