Trisurf Monte Carlo simulator
Samo Penic
2014-04-29 fbcbdf4093644e43688d9a44d6553d7153d8a2eb
commit | author | age
d7639a 1 #include<general.h>
SP 2 #include "vesicle.h"
bb77ca 3 #include "vertex.h"
SP 4 #include "triangle.h"
5 #include "bond.h"
6 #include "cell.h"
7958e9 7 #include "stdlib.h"
a2db52 8 #include "poly.h"
632960 9 #include "sh.h"
459ff9 10 #include "shcomplex.h"
8db569 11
bb77ca 12 ts_vesicle *init_vesicle(ts_uint N, ts_uint ncmax1, ts_uint ncmax2, ts_uint
SP 13 ncmax3, ts_double stepsize){
8db569 14     ts_vesicle *vesicle=(ts_vesicle *)calloc(1,sizeof(ts_vesicle));
bb77ca 15     vesicle->vlist=init_vertex_list(N);
SP 16     vesicle->blist=init_bond_list();
17     vesicle->tlist=init_triangle_list();
18     vesicle->clist=init_cell_list(ncmax1, ncmax2, ncmax3, stepsize);
7958e9 19     return vesicle;
bb77ca 20 }
SP 21
d7639a 22 ts_bool vesicle_translate(ts_vesicle *vesicle,ts_double x, ts_double y, ts_double z){
SP 23     ts_uint i;
7958e9 24     ts_vertex **vtx=vesicle->vlist->vtx;
bb77ca 25     ts_uint nn=vesicle->vlist->n;
d7639a 26     for(i=0;i<nn;i++){
8f6a69 27         vtx[i]->x+=x;
SP 28         vtx[i]->y+=y;
29         vtx[i]->z+=z;
d7639a 30     }
SP 31     return TS_SUCCESS;
32 }
33
34 ts_bool vesicle_free(ts_vesicle *vesicle){
7958e9 35     vtx_list_free(vesicle->vlist);
bb77ca 36     bond_list_free(vesicle->blist);
SP 37     triangle_list_free(vesicle->tlist);
38     cell_list_free(vesicle->clist);
a2db52 39     poly_list_free(vesicle->poly_list);
459ff9 40     complex_sph_free(vesicle->sphHarmonics);
7958e9 41     free(vesicle);
d7639a 42     return TS_SUCCESS;
SP 43 }
523bf1 44
c9d07c 45 /* @brief Function makes a sum of partial volumes of each triangle. Volumes of
SP 46  *
47  * Partial volumes are calculated when we calculate normals of triangles. It is
48  * relatively easy to calculate the volume of vesicle if we take into account
49  * that the volume of the whole vertex is simply sum of all partial volumes of
50  * all the triangles.
51  */
523bf1 52 ts_bool vesicle_volume(ts_vesicle *vesicle){
SP 53     ts_double volume;
54     ts_uint i;
55     ts_triangle **tria=vesicle->tlist->tria;
56     volume=0;
57     for(i=0; i<vesicle->tlist->n;i++){
c9d07c 58     volume=volume+tria[i]->volume;
523bf1 59     }
SP 60     vesicle->volume=volume;
61     return TS_SUCCESS;
62 }