Trisurf Monte Carlo simulator
Samo Penic
2022-05-04 06afc729f9061c1cfa14c78728d61d518324c2f0
Moved all global variables to separate file and defined extern keyword where appropriate
14 files modified
2 files added
62 ■■■■ changed files
src/Makefile.am 4 ●●●● patch | view | raw | blame | history
src/bondflip.c 1 ●●●● patch | view | raw | blame | history
src/general.c 2 ●●● patch | view | raw | blame | history
src/general.h 8 ●●●●● patch | view | raw | blame | history
src/globals.c 15 ●●●●● patch | view | raw | blame | history
src/globals.h 14 ●●●●● patch | view | raw | blame | history
src/io.c 1 ●●●● patch | view | raw | blame | history
src/io.h 4 ●●● patch | view | raw | blame | history
src/main.c 2 ●●● patch | view | raw | blame | history
src/restore.c 1 ●●●● patch | view | raw | blame | history
src/sh.c 2 ●●● patch | view | raw | blame | history
src/snapshot.c 2 ●●●●● patch | view | raw | blame | history
src/timestep.c 1 ●●●● patch | view | raw | blame | history
src/tsmeasure.c 2 ●●● patch | view | raw | blame | history
src/tspoststat.c 2 ●●● patch | view | raw | blame | history
src/vertexmove.c 1 ●●●● patch | view | raw | blame | history
src/Makefile.am
@@ -14,7 +14,7 @@
#------------- LIBS ----------
lib_LTLIBRARIES= libtrisurf.la
libtrisurf_la_SOURCES= general.c vertex.c bond.c triangle.c cell.c vesicle.c initial_distribution.c io.c dumpstate.c frame.c energy.c timestep.c vertexmove.c bondflip.c poly.c stats.c sh.c shcomplex.c constvol.c snapshot.c restore.c cluster.c
libtrisurf_la_SOURCES= general.c vertex.c bond.c triangle.c cell.c vesicle.c initial_distribution.c io.c dumpstate.c frame.c energy.c timestep.c vertexmove.c bondflip.c poly.c stats.c sh.c shcomplex.c constvol.c snapshot.c restore.c cluster.c globals.c
#libtrisurf_la_CPPFLAGS = ${libxml2_CFLAGS}
libtrisurf_la_LIBADD=${libxml2_LIBS}
pkginclude_HEADERS=general.h vertex.h bond.h triangle.h cell.h vesicle.h initial_distribution.h io.h dumpstate.h frame.h energy.h timestep.h vertexmove.h bondflip.h poly.h stats.h sh.h shcomplex.h constvol.h snapshot.h restore.h cluster.h
pkginclude_HEADERS=general.h vertex.h bond.h triangle.h cell.h vesicle.h initial_distribution.h io.h dumpstate.h frame.h energy.h timestep.h vertexmove.h bondflip.h poly.h stats.h sh.h shcomplex.h constvol.h snapshot.h restore.h cluster.h globals.h
src/bondflip.c
@@ -14,6 +14,7 @@
#include<stdio.h>
#include<string.h>
#include "constvol.h"
#include "globals.h"
ts_bool single_bondflip_timestep(ts_vesicle *vesicle, ts_bond *bond, ts_double *rn){
/*c  Vertex and triangle (lm and lp) indexing for bond flip:
src/general.c
@@ -12,7 +12,7 @@
#include <fcntl.h>
#include <errno.h>
#include <string.h>
#include "globals.h"
ts_uint ts_fprintf(FILE *fd, char *fmt, ...){
if(quiet) return TS_SUCCESS;
    va_list ap;
src/general.h
@@ -352,14 +352,6 @@
    ts_cluster **cluster;
} ts_cluster_list;
/* GLOBAL VARIABLES */
int quiet;
ts_double V0;
ts_double A0;
ts_double epsvol;
ts_double epsarea;
/* FUNCTIONS */
/** Non-fatal error function handler:
src/globals.c
New file
@@ -0,0 +1,15 @@
#include "general.h"
#include "io.h"
#include "globals.h"
/* GLOBAL VARIABLES */
int quiet;
ts_double V0;
ts_double A0;
ts_double epsvol;
ts_double epsarea;
ts_args command_line_args;
int force_from_tape;
char tapetxt[128000]; //stores text file of the tape
src/globals.h
New file
@@ -0,0 +1,14 @@
#ifndef __GLOBALS
#define __GLOBALS
/* GLOBAL VARIABLES */
#include "general.h"
#include "io.h"
extern int quiet;
extern ts_double V0;
extern ts_double A0;
extern ts_double epsvol;
extern ts_double epsarea;
extern ts_args command_line_args;
extern int force_from_tape;
extern char tapetxt[128000]; //stores text file of the tape
#endif
src/io.c
@@ -1,6 +1,7 @@
/* vim: set ts=4 sts=4 sw=4 noet : */
#include "general.h"
#include "globals.h"
#include<stdio.h>
#include "io.h"
#include "vertex.h"
src/io.h
@@ -7,8 +7,7 @@
static char prefixname[1024];
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;
@@ -21,7 +20,6 @@
    char dump_from_vtk[1024];
} ts_args;
ts_args command_line_args;
ts_bool parse_args(int argc, char **argv);
src/main.c
@@ -17,7 +17,7 @@
#include "shcomplex.h"
#include "dumpstate.h"
#include "restore.h"
#include "globals.h"
#include <fcntl.h>
/** Entrance function to the program
  * @param argv is a number of parameters used in program call (including the program name
src/restore.c
@@ -17,6 +17,7 @@
#include "initial_distribution.h"
#include "io.h"
#include <math.h>
#include "globals.h"
ts_vesicle *parseDump(char *dumpfname) {
    xmlDocPtr doc;
src/sh.c
@@ -5,7 +5,7 @@
#include "sh.h"
#include "io.h"
#include <string.h>
#include "globals.h"
ts_spharm *sph_init(ts_vertex_list *vlist, ts_uint l){
    ts_uint j,i;
src/snapshot.c
@@ -10,6 +10,8 @@
#include<config.h>
#include <time.h>
#include "io.h"
#include "globals.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;
src/timestep.c
@@ -4,6 +4,7 @@
#include<math.h>
//#include "io.h"
#include "general.h"
#include "globals.h"
#include "timestep.h"
#include "vertexmove.h"
#include "bondflip.h"
src/tsmeasure.c
@@ -26,7 +26,7 @@
#include <snapshot.h>
#include<gsl/gsl_complex.h>
#include<gsl/gsl_complex_math.h>
#include "globals.h"
ts_vesicle *restoreVesicle(char *filename){
    ts_vesicle *vesicle = parseDump(filename);
src/tspoststat.c
@@ -29,7 +29,7 @@
#include<gsl/gsl_complex.h>
#include<gsl/gsl_complex_math.h>
#include<stdio.h>
#include "globals.h"
ts_vesicle *restoreVesicle(char *filename){
    ts_vesicle *vesicle = parseDump(filename);
    return vesicle;
src/vertexmove.c
@@ -15,6 +15,7 @@
#include "vertexmove.h"
#include <string.h>
#include "constvol.h"
#include "globals.h"
ts_bool single_verticle_timestep(ts_vesicle *vesicle,ts_vertex *vtx,ts_double *rn){
    ts_uint i;