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