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