From c9d07c3cae70179c3045b92b7dc04f0d2ebcfb89 Mon Sep 17 00:00:00 2001 From: Samo Penic <samo.penic@fe.uni-lj.si> Date: Thu, 14 Jun 2012 08:28:19 +0000 Subject: [PATCH] Lastly before debugging. We calculated the area of each triangle, volume function has been changed and data structure adapted for area calculation --- src/vesicle.c | 15 ++++++++------- src/general.h | 1 + src/sh.c | 11 ++++++++++- src/triangle.c | 12 ++++++++++++ 4 files changed, 31 insertions(+), 8 deletions(-) diff --git a/src/general.h b/src/general.h index 1a90e97..87c6174 100644 --- a/src/general.h +++ b/src/general.h @@ -187,6 +187,7 @@ ts_double ynorm; ts_double znorm; ts_double area; // firstly needed for sh.c + ts_double volume; // firstly needed for sh.c }; typedef struct ts_triangle ts_triangle; diff --git a/src/sh.c b/src/sh.c index 84aafdc..cc4d148 100644 --- a/src/sh.c +++ b/src/sh.c @@ -143,7 +143,16 @@ } -/*Computes Y(l,m,theta,fi) (Miha's definition that is different from common definition for factor srqt(1/(2*pi)) */ +/** @brief: Computes Y(l,m,theta,fi) + * + * Function calculates Y^l_m for vertex with given (\theta, \fi) coordinates in + * spherical coordinate system. + * @param l is an ts_int argument. + * @param m is an ts_int argument. + * @param theta is ts_double argument. + * @param fi is a ts_double argument. + * + * (Miha's definition that is different from common definition for factor srqt(1/(2*pi)) */ ts_double shY(ts_int l,ts_int m,ts_double theta,ts_double fi){ ts_double fac1, fac2, K; int i; diff --git a/src/triangle.c b/src/triangle.c index bcd074b..e051316 100644 --- a/src/triangle.c +++ b/src/triangle.c @@ -219,6 +219,18 @@ tria->xnorm=tria->xnorm/xden; tria->ynorm=tria->ynorm/xden; tria->znorm=tria->znorm/xden; + +/* Here it is an excellent point to recalculate volume of the triangle and + * store it into datastructure. Volume is required at least by constant volume + * calculation of vertex move and bondflip and spherical harmonics. */ + tria->volume=(tria->vertex[0]->x+ tria->vertex[1]->x + tria->vertex[2]->x) * tria->xnorm + + (tria->vertex[0]->y+ tria->vertex[1]->y + tria->vertex[2]->y) * tria->ynorm + + (tria->vertex[0]->z+ tria->vertex[1]->z + tria->vertex[2]->z) * tria->znorm; + tria->volume=-xden*tria->volume/18.0; +/* Also, area can be calculated in each triangle */ + tria->area=xden/2; + + return TS_SUCCESS; } diff --git a/src/vesicle.c b/src/vesicle.c index e1cc21d..d2caf4b 100644 --- a/src/vesicle.c +++ b/src/vesicle.c @@ -37,20 +37,21 @@ return TS_SUCCESS; } +/* @brief Function makes a sum of partial volumes of each triangle. Volumes of + * + * Partial volumes are calculated when we calculate normals of triangles. It is + * relatively easy to calculate the volume of vesicle if we take into account + * that the volume of the whole vertex is simply sum of all partial volumes of + * all the triangles. + */ ts_bool vesicle_volume(ts_vesicle *vesicle){ ts_double volume; - ts_double vol; ts_uint i; ts_triangle **tria=vesicle->tlist->tria; volume=0; for(i=0; i<vesicle->tlist->n;i++){ - vol=(tria[i]->vertex[0]->x+ tria[i]->vertex[1]->x + tria[i]->vertex[2]->x) * tria[i]->xnorm + - (tria[i]->vertex[0]->y+ tria[i]->vertex[1]->y + tria[i]->vertex[2]->y) * tria[i]->ynorm + - (tria[i]->vertex[0]->z+ tria[i]->vertex[1]->z + tria[i]->vertex[2]->z) * -tria[i]->znorm; - volume=volume-vol/18.0; + volume=volume+tria[i]->volume; } - vesicle->volume=volume; return TS_SUCCESS; } -- Gitblit v1.9.3