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