| commit | author | age | ||
| 7f6076 | 1 | /* vim: set ts=4 sts=4 sw=4 noet : */ |
| d7639a | 2 | #include<stdio.h> |
| SP | 3 | #include<math.h> |
| 2b14da | 4 | #include<stdlib.h> |
| d7639a | 5 | #include "general.h" |
| SP | 6 | #include "vertex.h" |
| a10dd5 | 7 | #include "bond.h" |
| a2a676 | 8 | #include "triangle.h" |
| bb77ca | 9 | #include "cell.h" |
| 7958e9 | 10 | #include "vesicle.h" |
| a6b1b5 | 11 | #include "io.h" |
| 7958e9 | 12 | #include "initial_distribution.h" |
| dac2e5 | 13 | #include "frame.h" |
| aec47d | 14 | #include "timestep.h" |
| 8db569 | 15 | #include "poly.h" |
| dc77e8 | 16 | #include "sh.h" |
| 459ff9 | 17 | #include "shcomplex.h" |
| 8c1bb1 | 18 | #include "restore.h" |
| 6e42ef | 19 | |
| SP | 20 | #include <fcntl.h> |
| d7639a | 21 | /** Entrance function to the program |
| SP | 22 | * @param argv is a number of parameters used in program call (including the program name |
| 23 | * @param argc is a pointer to strings (character arrays) which holds the arguments | |
| 24 | * @returns returns 0 on success, any other number on fail. | |
| 25 | */ | |
| 26 | ||
| 27 | int main(int argv, char *argc[]){ | |
| 3c6e26 | 28 | ts_vesicle *vesicle=NULL; |
| SP | 29 | ts_tape *tape=NULL; |
| 8a6614 | 30 | ts_uint start_iteration=0; |
| 152052 | 31 | force_from_tape=0; |
| fab2ad | 32 | /* Area and volume for constant area and constant volume are initialized to be zero */ |
| SP | 33 | A0=0; |
| 34 | V0=0; | |
| 6e42ef | 35 | /* create lock file */ |
| SP | 36 | createPidFile("ts_trisurf",".lock",0); |
| 8a6614 | 37 | parse_args(argv,argc); // sets global variable command_line_args (defined in io.h) |
| 7f6076 | 38 | ts_fprintf(stdout,"TRISURF-NG v. %s, compiled on: %s %s.\n", TS_VERSION, __DATE__, __TIME__); |
| SP | 39 | ts_fprintf(stdout,"Programming done by: Samo Penic and Miha Fosnaric\n"); |
| 40 | ts_fprintf(stdout,"Released under terms of GPLv3\n"); | |
| 8a6614 | 41 | ts_fprintf(stdout,"Starting program...\n\n"); |
| ab798b | 42 | // vesicle = parseDump("timestep_000000.vtu"); |
| SP | 43 | // run_simulation(vesicle, vesicle->tape->mcsweeps, vesicle->tape->inititer, vesicle->tape->iterations, 1); |
| 44 | ||
| ee84bd | 45 | if(command_line_args.dump_from_vtk[0]!=0){ |
| SP | 46 | ts_fprintf(stdout,"************************************************\n"); |
| 57f830 | 47 | ts_fprintf(stdout,"**** Restoring vesicle from VTK points list ****\n"); |
| ee84bd | 48 | ts_fprintf(stdout,"************************************************\n\n"); |
| ab798b | 49 | vesicle = parseDump(command_line_args.dump_from_vtk); |
| 4f5ffc | 50 | write_vertex_xml_file(vesicle,9999, NULL); // here you can test if restoration and rewritting results in the same dump file. Only the date od creation of dump file must differ. |
| SP | 51 | printf("Dumped 9999 and exit\n"); |
| 52 | exit(12); | |
| ab798b | 53 | tape = vesicle->tape; |
| bb2074 | 54 | int arguments_no; |
| 3d0247 | 55 | FILE *fd=fopen(".status","r"); |
| SP | 56 | if(fd!=NULL){ |
| bb2074 | 57 | arguments_no=fscanf(fd,"%u", &start_iteration); |
| SP | 58 | if(arguments_no==0){ |
| a17e91 | 59 | ts_fprintf(stdout,"No information of start iteration in .status file\n"); |
| bb2074 | 60 | } |
| 3d0247 | 61 | fclose(fd); |
| a17e91 | 62 | start_iteration++; |
| 3d0247 | 63 | } |
| bb2074 | 64 | else |
| a17e91 | 65 | ts_fprintf(stdout,"No .status file. The iteration count will start from 0\n"); |
| ee84bd | 66 | } |
| SP | 67 | else if(command_line_args.force_from_tape){ |
| 8a6614 | 68 | ts_fprintf(stdout,"************************************************\n"); |
| SP | 69 | ts_fprintf(stdout,"**** Generating initial geometry from tape *****\n"); |
| 70 | ts_fprintf(stdout,"************************************************\n\n"); | |
| 267db5 | 71 | tape=parsetape(command_line_args.tape_fullfilename); |
| 8a6614 | 72 | vesicle=create_vesicle_from_tape(tape); |
| SP | 73 | } else { |
| 083e03 | 74 | |
| 8a6614 | 75 | ts_fprintf(stdout,"**********************************************************************\n"); |
| SP | 76 | ts_fprintf(stdout,"**** Recreating vesicle from dump file and continuing simulation *****\n"); |
| 77 | ts_fprintf(stdout,"**********************************************************************\n\n"); | |
| 3c6e26 | 78 | ts_fprintf(stderr, "Dump file does not exist or is not a regular file! Did you mean to invoke trisurf with --force-from-tape or --restore-from-vtk option?\n\n"); |
| SP | 79 | fatal("Recreating vesicle from binary dump file not supported anymore. Sorry.",254); |
| 8a6614 | 80 | } |
| SP | 81 | run_simulation(vesicle, tape->mcsweeps, tape->inititer, tape->iterations, start_iteration); |
| 82 | vesicle_free(vesicle); | |
| 83 | tape_free(tape); | |
| 84 | return 0; //program finished perfectly ok. We return 0. | |
| d7639a | 85 | } |