src/energy.c | ●●●●● patch | view | raw | blame | history | |
src/frame.c | ●●●●● patch | view | raw | blame | history | |
src/general.h | ●●●●● patch | view | raw | blame | history | |
src/initial_distribution.c | ●●●●● patch | view | raw | blame | history | |
src/io.c | ●●●●● patch | view | raw | blame | history | |
src/main.c | ●●●●● patch | view | raw | blame | history | |
src/timestep.c | ●●●●● patch | view | raw | blame | history | |
src/triangle.c | ●●●●● patch | view | raw | blame | history | |
src/triangle.h | ●●●●● patch | view | raw | blame | history |
src/energy.c
@@ -89,9 +89,9 @@ xh+=tot*(j->data->x - data->x); yh+=tot*(j->data->y - data->y); zh+=tot*(j->data->z - data->z); txn+=jt->data->xnorm; tyn+=jt->data->ynorm; tzn+=jt->data->znorm; txn+=jt->xnorm; tyn+=jt->ynorm; tzn+=jt->znorm; } h=xh*xh+yh*yh+zh*zh; src/frame.c
@@ -52,5 +52,7 @@ } */ if(dcell); if(shift); return TS_SUCCESS; } src/general.h
@@ -170,22 +170,14 @@ }; typedef struct ts_bond_list ts_bond_list; /** ts_triangle_data is a structure that describes a triangle */ struct ts_triangle_data { ts_uint idx; struct ts_triangle { ts_uint idx; ts_vertex *vertex[3]; ts_uint neigh_no; struct ts_triangle **neigh; ts_double xnorm; ts_double ynorm; ts_double znorm; }; typedef struct ts_triangle_data ts_triangle_data; struct ts_triangle { ts_uint idx; ts_triangle_data *data; }; typedef struct ts_triangle ts_triangle; src/initial_distribution.c
@@ -28,6 +28,7 @@ retval = init_normal_vectors(vesicle->tlist); retval = mean_curvature_and_energy(vesicle); ts_fprintf(stderr,"initial_distribution finished!\n"); if(retval); return vesicle; } @@ -249,7 +250,7 @@ for(i=0;i<tlist->n;i++){ k=0; for(j=0;j<3;j++){ if(tlist->tria[i]->data->vertex[j]!=NULL) if(tlist->tria[i]->vertex[j]!=NULL) k++; } if(k!=3){ @@ -273,14 +274,14 @@ ts_triangle **tria=tlist->tria -1; nobo=0; for(i=1;i<=tlist->n;i++){ i1=tria[i]->data->vertex[0]; i2=tria[i]->data->vertex[1]; i3=tria[i]->data->vertex[2]; i1=tria[i]->vertex[0]; i2=tria[i]->vertex[1]; i3=tria[i]->vertex[2]; for(j=1;j<=tlist->n;j++){ if(j==i) continue; j1=tria[j]->data->vertex[0]; j2=tria[j]->data->vertex[1]; j3=tria[j]->data->vertex[2]; j1=tria[j]->vertex[0]; j2=tria[j]->vertex[1]; j3=tria[j]->vertex[2]; if((i1==j1 && i3==j2) || (i1==j2 && i3==j3) || (i1==j3 && i3==j1)){ triangle_add_neighbour(tria[i],tria[j]); nobo++; @@ -288,14 +289,14 @@ } } for(i=1;i<=tlist->n;i++){ i1=tria[i]->data->vertex[0]; i2=tria[i]->data->vertex[1]; i3=tria[i]->data->vertex[2]; i1=tria[i]->vertex[0]; i2=tria[i]->vertex[1]; i3=tria[i]->vertex[2]; for(j=1;j<=tlist->n;j++){ if(j==i) continue; j1=tria[j]->data->vertex[0]; j2=tria[j]->data->vertex[1]; j3=tria[j]->data->vertex[2]; j1=tria[j]->vertex[0]; j2=tria[j]->vertex[1]; j3=tria[j]->vertex[2]; if((i1==j1 && i2==j3) || (i1==j3 && i2==j2) || (i1==j2 && i2==j1)){ triangle_add_neighbour(tria[i],tria[j]); nobo++; @@ -303,14 +304,14 @@ } } for(i=1;i<=tlist->n;i++){ i1=tria[i]->data->vertex[0]; i2=tria[i]->data->vertex[1]; i3=tria[i]->data->vertex[2]; i1=tria[i]->vertex[0]; i2=tria[i]->vertex[1]; i3=tria[i]->vertex[2]; for(j=1;j<=tlist->n;j++){ if(j==i) continue; j1=tria[j]->data->vertex[0]; j2=tria[j]->data->vertex[1]; j3=tria[j]->data->vertex[2]; j1=tria[j]->vertex[0]; j2=tria[j]->vertex[1]; j3=tria[j]->vertex[2]; if((i2==j1 && i3==j3) || (i2==j3 && i3==j2) || (i2==j2 && i3==j1)){ triangle_add_neighbour(tria[i],tria[j]); nobo++; @@ -339,9 +340,9 @@ if(j == vtx[i]->data->neigh_no) jp=1; k2=vtx[i]->data->neigh[jp-1]; for(k=1;k<=tlist->n;k++){ // VERY NON-OPTIMAL!!! too many loops (vlist.n * vtx.neigh * tlist.n )! k3=tria[k]->data->vertex[0]; k4=tria[k]->data->vertex[1]; k5=tria[k]->data->vertex[2]; k3=tria[k]->vertex[0]; k4=tria[k]->vertex[1]; k5=tria[k]->vertex[2]; // ts_fprintf(stderr,"%u %u: k=(%u %u %u)\n",k1,k2,k3,k4,k5); if((vtx[i]==k3 && k1==k4 && k2==k5) || (vtx[i]==k4 && k1==k5 && k2==k3) || src/io.c
@@ -85,17 +85,17 @@ ts_triangle_list *tlist=vesicle->tlist; ts_uint i,j; for(i=0;i<tlist->n;i++){ fprintf(fh,"\t%u",tlist->tria[i]->data->neigh_no); for(j=0;j<tlist->tria[i]->data->neigh_no;j++){ fprintf(fh,"\t%u",(ts_uint)(tlist->tria[i]->data->neigh[j]->idx));//-tlist->tria+1)); fprintf(fh,"\t%u",tlist->tria[i]->neigh_no); for(j=0;j<tlist->tria[i]->neigh_no;j++){ fprintf(fh,"\t%u",(ts_uint)(tlist->tria[i]->neigh[j]->idx));//-tlist->tria+1)); } fprintf(fh,"\n"); for(j=0;j<3;j++){ fprintf(fh,"\t%u",(ts_uint)(tlist->tria[i]->data->vertex[j]->idx));//-vesicle->vlist->vtx+1)); fprintf(fh,"\t%u",(ts_uint)(tlist->tria[i]->vertex[j]->idx));//-vesicle->vlist->vtx+1)); } fprintf(fh,"\n"); fprintf(fh,"%.17E\t%.17E\t%.17E\n",tlist->tria[i]->data->xnorm, tlist->tria[i]->data->ynorm,tlist->tria[i]->data->znorm); fprintf(fh,"%.17E\t%.17E\t%.17E\n",tlist->tria[i]->xnorm, tlist->tria[i]->ynorm,tlist->tria[i]->znorm); fprintf(fh,"0.00000000000000000\n0.00000000000000000\n"); } return TS_SUCCESS; @@ -373,6 +373,7 @@ } */ if(retval); fclose(fh); src/main.c
@@ -65,12 +65,10 @@ centermass(vesicle); cell_occupation(vesicle); for(i=0;i<100;i++) for(i=0;i<100;i++){ single_timestep(vesicle); write_vertex_xml_file(vesicle,0); write_vertex_xml_file(vesicle,i); } write_master_xml_file("test.pvd"); write_dout_fcompat_file(vesicle,"dout"); vesicle_free(vesicle); src/timestep.c
@@ -26,7 +26,7 @@ // retval=single_bondflip_timestep(vesicle,&vesicle->blist.bond[i],rnvec); } if(retval); return TS_SUCCESS; } src/triangle.c
@@ -57,13 +57,13 @@ tlist->tria[tlist->n-1]=(ts_triangle *)calloc(1,sizeof(ts_triangle)); if(tlist->tria[tlist->n-1]==NULL) fatal("Cannot reallocate memory for additional ts_triangle.",5); tlist->tria[tlist->n-1]->data=(ts_triangle_data *)calloc(1,sizeof(ts_triangle_data)); // tlist->tria[tlist->n-1]->data=(ts_triangle_data *)calloc(1,sizeof(ts_triangle_data)); //NOW insert vertices! tlist->tria[tlist->n - 1]->idx=tlist->n-1; tlist->tria[tlist->n - 1]->data->vertex[0]=vtx1; tlist->tria[tlist->n - 1]->data->vertex[1]=vtx2; tlist->tria[tlist->n - 1]->data->vertex[2]=vtx3; tlist->tria[tlist->n - 1]->vertex[0]=vtx1; tlist->tria[tlist->n - 1]->vertex[1]=vtx2; tlist->tria[tlist->n - 1]->vertex[2]=vtx3; return tlist->tria[tlist->n-1]; } @@ -94,11 +94,11 @@ if(tria==NULL || ntria==NULL) return TS_FAIL; /*TODO: check if the neighbour already exists! Now there is no such check * because of the performance issue. */ tria->data->neigh_no++; tria->data->neigh=realloc(tria->data->neigh,tria->data->neigh_no*sizeof(ts_triangle *)); if(tria->data->neigh == NULL) tria->neigh_no++; tria->neigh=realloc(tria->neigh,tria->neigh_no*sizeof(ts_triangle *)); if(tria->neigh == NULL) fatal("Reallocation of memory failed during insertion of triangle neighbour in triangle_add_neighbour",3); tria->data->neigh[tria->data->neigh_no-1]=ntria; tria->neigh[tria->neigh_no-1]=ntria; /* we repeat the procedure for the neighbour */ @@ -136,9 +136,9 @@ ts_uint i,j=0; if(tria==NULL || ntria==NULL) return TS_FAIL; for(i=0;i<tria->data->neigh_no;i++){ if(tria->data->neigh[i]!=ntria){ tria->data->neigh[j]=tria->data->neigh[i]; for(i=0;i<tria->neigh_no;i++){ if(tria->neigh[i]!=ntria){ tria->neigh[j]=tria->neigh[i]; j++; } } @@ -146,15 +146,15 @@ return TS_FAIL; //fatal("In triangle_remove_neighbour: Specified neighbour does not exist for given triangle",3); } tria->data->neigh_no--; tria->data->neigh=(ts_triangle **)realloc(tria->data->neigh,tria->data->neigh_no*sizeof(ts_triangle *)); if(tria->data->neigh == NULL){ tria->neigh_no--; tria->neigh=(ts_triangle **)realloc(tria->neigh,tria->neigh_no*sizeof(ts_triangle *)); if(tria->neigh == NULL){ fatal("Reallocation of memory failed during removal of vertex neighbour in triangle_remove_neighbour",100); } /* we repeat the procedure for neighbour */ for(i=0;i<ntria->data->neigh_no;i++){ if(ntria->data->neigh[i]!=tria){ ntria->data->neigh[j]=ntria->data->neigh[i]; for(i=0;i<ntria->neigh_no;i++){ if(ntria->neigh[i]!=tria){ ntria->neigh[j]=ntria->neigh[i]; j++; } } @@ -162,9 +162,9 @@ return TS_FAIL; //fatal("In triangle_remove_neighbour: Specified neighbour does not exist for given triangle",3); } ntria->data->neigh_no--; ntria->data->neigh=(ts_triangle **)realloc(ntria->data->neigh,ntria->data->neigh_no*sizeof(ts_triangle *)); if(ntria->data->neigh == NULL){ ntria->neigh_no--; ntria->neigh=(ts_triangle **)realloc(ntria->neigh,ntria->neigh_no*sizeof(ts_triangle *)); if(ntria->neigh == NULL){ fatal("Reallocation of memory failed during removal of vertex neighbour in triangle_remove_neighbour",100); } return TS_SUCCESS; @@ -194,19 +194,19 @@ */ ts_bool triangle_normal_vector(ts_triangle *tria){ ts_double x21,x31,y21,y31,z21,z31,xden; x21=tria->data->vertex[1]->data->x - tria->data->vertex[0]->data->x; x31=tria->data->vertex[2]->data->x - tria->data->vertex[0]->data->x; y21=tria->data->vertex[1]->data->y - tria->data->vertex[0]->data->y; y31=tria->data->vertex[2]->data->y - tria->data->vertex[0]->data->y; z21=tria->data->vertex[1]->data->z - tria->data->vertex[0]->data->z; z31=tria->data->vertex[2]->data->z - tria->data->vertex[0]->data->z; x21=tria->vertex[1]->data->x - tria->vertex[0]->data->x; x31=tria->vertex[2]->data->x - tria->vertex[0]->data->x; y21=tria->vertex[1]->data->y - tria->vertex[0]->data->y; y31=tria->vertex[2]->data->y - tria->vertex[0]->data->y; z21=tria->vertex[1]->data->z - tria->vertex[0]->data->z; z31=tria->vertex[2]->data->z - tria->vertex[0]->data->z; tria->data->xnorm=y21*z31 - z21*y31; tria->data->ynorm=z21*x31 - x21*z31; tria->data->znorm=x21*y31 - y21*x31; xden=tria->data->xnorm*tria->data->xnorm + tria->data->ynorm*tria->data->ynorm + tria->data->znorm*tria->data->znorm; tria->xnorm=y21*z31 - z21*y31; tria->ynorm=z21*x31 - x21*z31; tria->znorm=x21*y31 - y21*x31; xden=tria->xnorm*tria->xnorm + tria->ynorm*tria->ynorm + tria->znorm*tria->znorm; #ifdef TS_DOUBLE_DOUBLE xden=sqrt(xden); #endif @@ -216,9 +216,9 @@ #ifdef TS_DOUBLE_LONGDOUBLE xden=sqrtl(xden); #endif tria->data->xnorm=tria->data->xnorm/xden; tria->data->ynorm=tria->data->ynorm/xden; tria->data->znorm=tria->data->znorm/xden; tria->xnorm=tria->xnorm/xden; tria->ynorm=tria->ynorm/xden; tria->znorm=tria->znorm/xden; return TS_SUCCESS; } @@ -226,29 +226,6 @@ /** @brief Frees the memory allocated for data structure of triangle data * (ts_triangle_data) * * Function frees the memory of ts_triangle_data previously allocated. It * accepts one argument, the address of data structure. It destroys all * pointers the structure might have (currently only neigh -- the pointer to * list of neighbouring triangles) and data structure itself. The return value * is always TS_SUCCESS. * * WARNING: The function doesn't check whether the pointer is NULL or invalid. It is the * job of programmer to make sure the pointer is valid. * * Example of usage: * triangle_data_free(tlist->tria[3]->data); * * Clears the data structure with all pointers. * */ ts_bool triangle_data_free(ts_triangle_data *data){ if(data->neigh!=NULL) free(data->neigh); free(data); return TS_SUCCESS; } /** @brief Frees the memory allocated for data structure of triangle list * (ts_triangle_list) @@ -277,7 +254,7 @@ ts_bool triangle_list_free(ts_triangle_list *tlist){ ts_uint i; for(i=0;i<tlist->n;i++){ triangle_data_free(tlist->tria[i]->data); if(tlist->tria[i]->neigh!=NULL) free(tlist->tria[i]->neigh); free(tlist->tria[i]); } free(tlist->tria); src/triangle.h
@@ -5,7 +5,6 @@ ts_triangle *triangle_add(ts_triangle_list *tlist, ts_vertex *vtx1, ts_vertex *vtx2, ts_vertex *vtx3); ts_bool triangle_add_neighbour(ts_triangle *tria, ts_triangle *ntria); ts_bool triangle_normal_vector(ts_triangle *tria); ts_bool triangle_data_free(ts_triangle_data *triang); ts_bool triangle_list_free(ts_triangle_list *tlist); #endif