commit | author | age
|
f74313
|
1 |
#include "general.h" |
d7639a
|
2 |
#include<stdio.h> |
SP |
3 |
#include "io.h" |
f74313
|
4 |
#include <confuse.h> |
SP |
5 |
#include "vertex.h" |
|
6 |
#include "bond.h" |
d7639a
|
7 |
#include<string.h> |
a6b1b5
|
8 |
#include<stdlib.h> |
d7639a
|
9 |
#include <sys/types.h> |
SP |
10 |
#include <dirent.h> |
b14a8d
|
11 |
#include "initial_distribution.h" |
a2db52
|
12 |
#include "poly.h" |
d7639a
|
13 |
|
SP |
14 |
ts_bool print_vertex_list(ts_vertex_list *vlist){ |
|
15 |
ts_uint i; |
|
16 |
printf("Number of vertices: %u\n",vlist->n); |
|
17 |
for(i=0;i<vlist->n;i++){ |
a6b1b5
|
18 |
printf("%u: %f %f %f\n", |
8f6a69
|
19 |
vlist->vtx[i]->idx,vlist->vtx[i]->x, vlist->vtx[i]->y, vlist->vtx[i]->z); |
d7639a
|
20 |
} |
SP |
21 |
return TS_SUCCESS; |
|
22 |
} |
|
23 |
|
|
24 |
ts_bool print_vertex_neighbours(ts_vertex_list *vlist){ |
|
25 |
ts_uint i,j; |
a6b1b5
|
26 |
ts_vertex **vtx=vlist->vtx; |
d7639a
|
27 |
printf("Vertex id(neigh no): (neighvertex coord) (neighvertex coord) ...\n"); |
SP |
28 |
for(i=0;i<vlist->n;i++){ |
8f6a69
|
29 |
printf("%u(%u): ",vtx[i]->idx,vtx[i]->neigh_no); |
SP |
30 |
for(j=0;j<vtx[i]->neigh_no;j++){ |
|
31 |
printf("(%f,%f,%f)",vtx[i]->neigh[j]->x, |
|
32 |
vtx[i]->neigh[j]->y,vtx[i]->neigh[j]->z); |
d7639a
|
33 |
} |
SP |
34 |
printf("\n"); |
|
35 |
} |
|
36 |
|
|
37 |
return TS_SUCCESS; |
|
38 |
} |
|
39 |
|
|
40 |
ts_bool write_vertex_fcompat_file(ts_vertex_list *vlist,ts_char *filename){ |
a6b1b5
|
41 |
ts_vertex **vtx=vlist->vtx; |
d7639a
|
42 |
ts_uint i; |
SP |
43 |
FILE *fh; |
|
44 |
|
|
45 |
fh=fopen(filename, "w"); |
|
46 |
if(fh==NULL){ |
|
47 |
err("Cannot open file %s for writing"); |
|
48 |
return TS_FAIL; |
|
49 |
} |
|
50 |
for(i=0;i<vlist->n;i++) |
8f6a69
|
51 |
fprintf(fh," %E\t%E\t%E\n",vtx[i]->x,vtx[i]->y, vtx[i]->z); |
d7639a
|
52 |
|
SP |
53 |
fclose(fh); |
|
54 |
return TS_SUCCESS; |
|
55 |
} |
|
56 |
|
|
57 |
|
|
58 |
ts_bool fprint_vertex_list(FILE *fh,ts_vertex_list *vlist){ |
|
59 |
ts_uint i,j; |
|
60 |
for(i=0;i<vlist->n;i++){ |
8f6a69
|
61 |
fprintf(fh," %.17E\t%.17E\t%.17E\t%u\n",vlist->vtx[i]->x, |
SP |
62 |
vlist->vtx[i]->y, vlist->vtx[i]->z, |
|
63 |
vlist->vtx[i]->neigh_no); |
|
64 |
for(j=0;j<vlist->vtx[i]->neigh_no;j++){ |
|
65 |
fprintf(fh,"\t%u",(ts_uint)(vlist->vtx[i]->neigh[j]->idx)); |
a6b1b5
|
66 |
//-vlist->vtx+1)); |
d7639a
|
67 |
} |
SP |
68 |
fprintf(fh,"\n"); |
|
69 |
} |
|
70 |
return TS_SUCCESS; |
|
71 |
} |
|
72 |
|
|
73 |
ts_bool fprint_tristar(FILE *fh, ts_vesicle *vesicle){ |
|
74 |
ts_uint i,j; |
a6b1b5
|
75 |
for(i=0;i<vesicle->vlist->n;i++){ |
8f6a69
|
76 |
fprintf(fh,"\t%u",vesicle->vlist->vtx[i]->tristar_no); |
SP |
77 |
for(j=0;j<vesicle->vlist->vtx[i]->tristar_no;j++){ |
|
78 |
fprintf(fh,"\t%u",(ts_uint)(vesicle->vlist->vtx[i]->tristar[j]->idx));//-vesicle->tlist->tria+1)); |
d7639a
|
79 |
} |
SP |
80 |
fprintf(fh,"\n"); |
|
81 |
} |
|
82 |
return TS_SUCCESS; |
|
83 |
} |
|
84 |
|
|
85 |
ts_bool fprint_triangle_list(FILE *fh, ts_vesicle *vesicle){ |
a6b1b5
|
86 |
ts_triangle_list *tlist=vesicle->tlist; |
d7639a
|
87 |
ts_uint i,j; |
SP |
88 |
for(i=0;i<tlist->n;i++){ |
41a035
|
89 |
fprintf(fh,"\t%u",tlist->tria[i]->neigh_no); |
SP |
90 |
for(j=0;j<tlist->tria[i]->neigh_no;j++){ |
|
91 |
fprintf(fh,"\t%u",(ts_uint)(tlist->tria[i]->neigh[j]->idx));//-tlist->tria+1)); |
d7639a
|
92 |
} |
SP |
93 |
fprintf(fh,"\n"); |
|
94 |
for(j=0;j<3;j++){ |
41a035
|
95 |
fprintf(fh,"\t%u",(ts_uint)(tlist->tria[i]->vertex[j]->idx));//-vesicle->vlist->vtx+1)); |
d7639a
|
96 |
} |
SP |
97 |
fprintf(fh,"\n"); |
41a035
|
98 |
fprintf(fh,"%.17E\t%.17E\t%.17E\n",tlist->tria[i]->xnorm, |
SP |
99 |
tlist->tria[i]->ynorm,tlist->tria[i]->znorm); |
d7639a
|
100 |
fprintf(fh,"0.00000000000000000\n0.00000000000000000\n"); |
SP |
101 |
} |
|
102 |
return TS_SUCCESS; |
|
103 |
} |
|
104 |
|
|
105 |
ts_bool fprint_vertex_data(FILE *fh,ts_vertex_list *vlist){ |
|
106 |
ts_uint i,j; |
|
107 |
for(i=0;i<vlist->n;i++){ |
|
108 |
fprintf(fh," %.17E\t%.17E\t%.17E\t%.17E\t%.17E\t%u\n", |
8f6a69
|
109 |
vlist->vtx[i]->xk,vlist->vtx[i]->c,vlist->vtx[i]->energy, |
SP |
110 |
vlist->vtx[i]->energy_h, vlist->vtx[i]->curvature, 0); |
|
111 |
for(j=0;j<vlist->vtx[i]->neigh_no;j++){ |
|
112 |
fprintf(fh," %.17E", vlist->vtx[i]->bond[j]->bond_length_dual); |
d7639a
|
113 |
} |
SP |
114 |
fprintf(fh,"\n"); |
8f6a69
|
115 |
for(j=0;j<vlist->vtx[i]->neigh_no;j++){ |
SP |
116 |
fprintf(fh," %.17E", vlist->vtx[i]->bond[j]->bond_length); |
d7639a
|
117 |
} |
SP |
118 |
fprintf(fh,"\n"); |
|
119 |
} |
|
120 |
return TS_SUCCESS; |
|
121 |
} |
|
122 |
|
|
123 |
ts_bool fprint_bonds(FILE *fh,ts_vesicle *vesicle){ |
|
124 |
ts_uint i; |
a6b1b5
|
125 |
for(i=0;i<vesicle->blist->n;i++){ |
e016c4
|
126 |
fprintf(fh,"\t%u\t%u\n",(ts_uint)(vesicle->blist->bond[i]->vtx1->idx), |
a6b1b5
|
127 |
//-vesicle->vlist->vtx+1), |
e016c4
|
128 |
(ts_uint)(vesicle->blist->bond[i]->vtx2->idx)); |
a6b1b5
|
129 |
//-vesicle->vlist.vtx+1)); |
d7639a
|
130 |
} |
SP |
131 |
return TS_SUCCESS; |
|
132 |
} |
|
133 |
|
|
134 |
|
|
135 |
ts_bool write_dout_fcompat_file(ts_vesicle *vesicle, ts_char *filename){ |
|
136 |
FILE *fh; |
|
137 |
fh=fopen(filename, "w"); |
|
138 |
if(fh==NULL){ |
|
139 |
err("Cannot open file %s for writing"); |
|
140 |
return TS_FAIL; |
|
141 |
} |
|
142 |
fprintf(fh,"%.17E\n%.17E\n",vesicle->stepsize,vesicle->dmax); |
a6b1b5
|
143 |
fprint_vertex_list(fh,vesicle->vlist); |
d7639a
|
144 |
fprint_tristar(fh,vesicle); |
SP |
145 |
fprint_triangle_list(fh,vesicle); |
a6b1b5
|
146 |
fprint_vertex_data(fh,vesicle->vlist); |
d7639a
|
147 |
fprint_bonds(fh,vesicle); |
SP |
148 |
fclose(fh); |
|
149 |
return TS_SUCCESS; |
|
150 |
} |
|
151 |
|
|
152 |
ts_bool read_tape_fcompat_file(ts_vesicle *vesicle, ts_char *filename){ |
|
153 |
FILE *fh; |
|
154 |
char line[255]; |
|
155 |
fh=fopen(filename, "r"); |
|
156 |
if(fh==NULL){ |
|
157 |
err("Cannot open file for reading... Nonexistant file?"); |
|
158 |
return TS_FAIL; |
|
159 |
} |
a6b1b5
|
160 |
ts_uint retval=1; |
d7639a
|
161 |
while(retval!=EOF){ |
SP |
162 |
retval=fscanf(fh,"%s",line); |
|
163 |
|
|
164 |
fprintf(stderr,"%s",line); |
|
165 |
} |
|
166 |
fclose(fh); |
|
167 |
return TS_SUCCESS; |
|
168 |
} |
|
169 |
|
|
170 |
ts_bool write_master_xml_file(ts_char *filename){ |
|
171 |
FILE *fh; |
|
172 |
ts_char *i,*j; |
|
173 |
ts_uint tstep; |
|
174 |
ts_char *number; |
|
175 |
fh=fopen(filename, "w"); |
|
176 |
if(fh==NULL){ |
|
177 |
err("Cannot open file %s for writing"); |
|
178 |
return TS_FAIL; |
|
179 |
} |
|
180 |
|
|
181 |
fprintf(fh,"<?xml version=\"1.0\"?>\n<VTKFile type=\"Collection\" version=\"0.1\" byte_order=\"LittleEndian\" compressor=\"vtkZLibDataCompressor\">\n<Collection>"); |
|
182 |
DIR *dir = opendir("."); |
|
183 |
if(dir){ |
|
184 |
struct dirent *ent; |
|
185 |
tstep=0; |
|
186 |
while((ent = readdir(dir)) != NULL) |
|
187 |
{ |
|
188 |
i=rindex(ent->d_name,'.'); |
|
189 |
if(i==NULL) continue; |
|
190 |
if(strcmp(i+1,"vtu")==0){ |
|
191 |
j=rindex(ent->d_name,'_'); |
|
192 |
if(j==NULL) continue; |
|
193 |
number=strndup(j+1,j-i); |
a6b1b5
|
194 |
fprintf(fh,"<DataSet timestep=\"%u\" group=\"\" part=\"0\" file=\"%s\"/>\n",atoi(number),ent->d_name); |
d7639a
|
195 |
tstep++; |
SP |
196 |
free(number); |
|
197 |
} |
|
198 |
} |
|
199 |
} |
f74313
|
200 |
free(dir); |
d7639a
|
201 |
fprintf(fh,"</Collection>\n</VTKFile>\n"); |
SP |
202 |
fclose(fh); |
|
203 |
return TS_SUCCESS; |
|
204 |
} |
|
205 |
|
|
206 |
ts_bool write_vertex_xml_file(ts_vesicle *vesicle, ts_uint timestepno){ |
a6b1b5
|
207 |
ts_vertex_list *vlist=vesicle->vlist; |
SP |
208 |
ts_bond_list *blist=vesicle->blist; |
|
209 |
ts_vertex **vtx=vlist->vtx; |
40aa5b
|
210 |
ts_uint i,j; |
d7639a
|
211 |
char filename[255]; |
SP |
212 |
FILE *fh; |
|
213 |
|
|
214 |
sprintf(filename,"timestep_%.6u.vtu",timestepno); |
|
215 |
fh=fopen(filename, "w"); |
|
216 |
if(fh==NULL){ |
|
217 |
err("Cannot open file %s for writing"); |
|
218 |
return TS_FAIL; |
|
219 |
} |
|
220 |
/* Here comes header of the file */ |
40aa5b
|
221 |
|
SP |
222 |
//find number of extra vtxs and bonds of polymeres |
|
223 |
ts_uint monono=0, polyno=0; |
|
224 |
ts_bool poly=0; |
|
225 |
if(vesicle->poly_list!=NULL){ |
|
226 |
if(vesicle->poly_list->poly[0]!=NULL){ |
|
227 |
polyno=vesicle->poly_list->n; |
|
228 |
monono=vesicle->poly_list->poly[0]->vlist->n; |
|
229 |
poly=1; |
|
230 |
} |
|
231 |
} |
d7639a
|
232 |
fprintf(fh, "<?xml version=\"1.0\"?>\n<VTKFile type=\"UnstructuredGrid\" version=\"0.1\" byte_order=\"LittleEndian\" compressor=\"vtkZLibDataCompressor\">\n <UnstructuredGrid>\n"); |
40aa5b
|
233 |
fprintf(fh, "<Piece NumberOfPoints=\"%u\" NumberOfCells=\"%u\">\n",vlist->n+monono*polyno, blist->n+monono*polyno); |
d7639a
|
234 |
fprintf(fh,"<PointData Scalars=\"scalars\">\n<DataArray type=\"Int64\" Name=\"scalars\" format=\"ascii\">"); |
SP |
235 |
for(i=0;i<vlist->n;i++){ |
a6b1b5
|
236 |
fprintf(fh,"%u ",vtx[i]->idx); |
d7639a
|
237 |
} |
40aa5b
|
238 |
//polymeres |
SP |
239 |
if(poly){ |
|
240 |
for(i=0;i<vesicle->poly_list->n;i++){ |
|
241 |
for(j=0;j<vesicle->poly_list->poly[i]->vlist->n;j++){ |
|
242 |
fprintf(fh,"%u ", vesicle->poly_list->poly[i]->vlist->vtx[j]->idx); |
|
243 |
} |
|
244 |
} |
|
245 |
} |
d7639a
|
246 |
|
SP |
247 |
fprintf(fh,"</DataArray>\n</PointData>\n<CellData>\n</CellData>\n<Points>\n<DataArray type=\"Float64\" Name=\"Koordinate tock\" NumberOfComponents=\"3\" format=\"ascii\">\n"); |
|
248 |
for(i=0;i<vlist->n;i++){ |
8f6a69
|
249 |
fprintf(fh,"%e %e %e\n",vtx[i]->x,vtx[i]->y, vtx[i]->z); |
40aa5b
|
250 |
} |
SP |
251 |
//polymeres |
|
252 |
if(poly){ |
|
253 |
for(i=0;i<vesicle->poly_list->n;i++){ |
|
254 |
for(j=0;j<vesicle->poly_list->poly[i]->vlist->n;j++){ |
|
255 |
fprintf(fh,"%e %e %e\n", vesicle->poly_list->poly[i]->vlist->vtx[j]->x,vesicle->poly_list->poly[i]->vlist->vtx[j]->y, vesicle->poly_list->poly[i]->vlist->vtx[j]->z ); |
|
256 |
} |
|
257 |
} |
d7639a
|
258 |
} |
SP |
259 |
|
|
260 |
fprintf(fh,"</DataArray>\n</Points>\n<Cells>\n<DataArray type=\"Int64\" Name=\"connectivity\" format=\"ascii\">"); |
|
261 |
for(i=0;i<blist->n;i++){ |
e016c4
|
262 |
fprintf(fh,"%u %u\n",blist->bond[i]->vtx1->idx,blist->bond[i]->vtx2->idx); |
d7639a
|
263 |
} |
40aa5b
|
264 |
//polymeres |
SP |
265 |
if(poly){ |
|
266 |
for(i=0;i<vesicle->poly_list->n;i++){ |
|
267 |
for(j=0;j<vesicle->poly_list->poly[i]->blist->n;j++){ |
|
268 |
fprintf(fh,"%u %u\n", vesicle->poly_list->poly[i]->blist->bond[j]->vtx1->idx,vesicle->poly_list->poly[i]->blist->bond[j]->vtx2->idx); |
|
269 |
} |
|
270 |
//grafted bonds |
|
271 |
fprintf(fh,"%u %u\n", vesicle->poly_list->poly[i]->grafted_vtx->idx, vesicle->poly_list->poly[i]->vlist->vtx[0]->idx); |
|
272 |
} |
|
273 |
|
|
274 |
} |
|
275 |
|
|
276 |
|
d7639a
|
277 |
fprintf(fh,"</DataArray>\n<DataArray type=\"Int64\" Name=\"offsets\" format=\"ascii\">"); |
40aa5b
|
278 |
for (i=2;i<(blist->n+monono*polyno)*2+1;i+=2){ |
d7639a
|
279 |
fprintf(fh,"%u ",i); |
SP |
280 |
} |
|
281 |
fprintf(fh,"\n"); |
|
282 |
fprintf(fh,"</DataArray>\n<DataArray type=\"UInt8\" Name=\"types\" format=\"ascii\">\n"); |
40aa5b
|
283 |
for (i=0;i<blist->n+monono*polyno;i++){ |
d7639a
|
284 |
fprintf(fh,"3 "); |
SP |
285 |
} |
|
286 |
|
|
287 |
fprintf(fh,"</DataArray>\n</Cells>\n</Piece>\n</UnstructuredGrid>\n</VTKFile>\n"); |
|
288 |
fclose(fh); |
|
289 |
return TS_SUCCESS; |
|
290 |
|
|
291 |
} |
|
292 |
|
|
293 |
ts_bool write_vertex_vtk_file(ts_vesicle *vesicle,ts_char *filename, ts_char *text){ |
a6b1b5
|
294 |
ts_vertex_list *vlist=vesicle->vlist; |
SP |
295 |
ts_bond_list *blist=vesicle->blist; |
|
296 |
ts_vertex **vtx=vlist->vtx; |
|
297 |
ts_uint i; |
d7639a
|
298 |
FILE *fh; |
SP |
299 |
|
|
300 |
fh=fopen(filename, "w"); |
|
301 |
if(fh==NULL){ |
|
302 |
err("Cannot open file %s for writing"); |
|
303 |
return TS_FAIL; |
|
304 |
} |
|
305 |
/* Here comes header of the file */ |
|
306 |
// fprintf(stderr,"NSHELL=%u\n",nshell); |
|
307 |
fprintf(fh, "# vtk DataFile Version 2.0\n"); |
|
308 |
/* TODO: Do a sanity check on text. Max 255 char, must not me \n terminated */ |
|
309 |
fprintf(fh, "%s\n", text); |
|
310 |
fprintf(fh,"ASCII\n"); |
|
311 |
fprintf(fh,"DATASET UNSTRUCTURED_GRID\n"); |
|
312 |
fprintf(fh,"POINTS %u double\n", vlist->n); |
|
313 |
for(i=0;i<vlist->n;i++){ |
8f6a69
|
314 |
fprintf(fh,"%e %e %e\n",vtx[i]->x,vtx[i]->y, vtx[i]->z); |
d7639a
|
315 |
} |
SP |
316 |
|
|
317 |
fprintf(fh,"CELLS %u %u\n",blist->n,3*blist->n); |
|
318 |
for(i=0;i<blist->n;i++){ |
e016c4
|
319 |
fprintf(fh,"2 %u %u\n",blist->bond[i]->vtx1->idx,blist->bond[i]->vtx2->idx); |
d7639a
|
320 |
} |
SP |
321 |
fprintf(fh,"CELL_TYPES %u\n",blist->n); |
|
322 |
for(i=0;i<blist->n;i++) |
|
323 |
fprintf(fh,"3\n"); |
|
324 |
|
|
325 |
fprintf(fh,"POINT_DATA %u\n", vlist->n); |
|
326 |
fprintf(fh,"SCALARS scalars long 1\n"); |
|
327 |
fprintf(fh,"LOOKUP_TABLE default\n"); |
|
328 |
|
|
329 |
for(i=0;i<vlist->n;i++) |
8f6a69
|
330 |
fprintf(fh,"%u\n",vtx[i]->idx); |
d7639a
|
331 |
|
SP |
332 |
fclose(fh); |
|
333 |
return TS_SUCCESS; |
|
334 |
} |
|
335 |
|
|
336 |
|
|
337 |
|
d7a113
|
338 |
ts_vesicle *parsetape(ts_uint *mcsweeps, ts_uint *inititer, ts_uint *iterations){ |
a2db52
|
339 |
long int nshell=17,ncxmax=60, ncymax=60, nczmax=60, npoly=10, nmono=20; // THIS IS DUE TO CONFUSE BUG! |
b14a8d
|
340 |
char *buf=malloc(255*sizeof(char)); |
SP |
341 |
long int brezveze0=1; |
|
342 |
long int brezveze1=1; |
|
343 |
long int brezveze2=1; |
48bb92
|
344 |
ts_double xk0=25.0, dmax=1.67,stepsize=0.15,kspring=800.0; |
d7a113
|
345 |
long int iter=1000, init=1000, mcsw=1000; |
40aa5b
|
346 |
|
SP |
347 |
|
d7639a
|
348 |
cfg_opt_t opts[] = { |
SP |
349 |
CFG_SIMPLE_INT("nshell", &nshell), |
a2db52
|
350 |
CFG_SIMPLE_INT("npoly", &npoly), |
SP |
351 |
CFG_SIMPLE_INT("nmono", &nmono), |
d7639a
|
352 |
CFG_SIMPLE_FLOAT("dmax", &dmax), |
SP |
353 |
CFG_SIMPLE_FLOAT("xk0",&xk0), |
48bb92
|
354 |
CFG_SIMPLE_FLOAT("k_spring",&kspring), |
d7639a
|
355 |
CFG_SIMPLE_FLOAT("stepsize",&stepsize), |
SP |
356 |
CFG_SIMPLE_INT("nxmax", &ncxmax), |
|
357 |
CFG_SIMPLE_INT("nymax", &ncymax), |
|
358 |
CFG_SIMPLE_INT("nzmax", &nczmax), |
d7a113
|
359 |
CFG_SIMPLE_INT("iterations",&iter), |
SP |
360 |
CFG_SIMPLE_INT("mcsweeps",&mcsw), |
|
361 |
CFG_SIMPLE_INT("inititer", &init), |
d7639a
|
362 |
CFG_SIMPLE_BOOL("quiet",&quiet), |
314f2d
|
363 |
CFG_SIMPLE_STR("multiprocessing",buf), |
b14a8d
|
364 |
CFG_SIMPLE_INT("smp_cores",&brezveze0), |
SP |
365 |
CFG_SIMPLE_INT("cluster_nodes",&brezveze1), |
|
366 |
CFG_SIMPLE_INT("distributed_processes",&brezveze2), |
d7639a
|
367 |
CFG_END() |
SP |
368 |
}; |
|
369 |
cfg_t *cfg; |
|
370 |
ts_uint retval; |
|
371 |
cfg = cfg_init(opts, 0); |
a6b1b5
|
372 |
retval=cfg_parse(cfg, "tape"); |
d7639a
|
373 |
if(retval==CFG_FILE_ERROR){ |
a6b1b5
|
374 |
fatal("No tape file.",100); |
d7639a
|
375 |
} |
SP |
376 |
else if(retval==CFG_PARSE_ERROR){ |
|
377 |
fatal("Invalid tape!",100); |
|
378 |
} |
b14a8d
|
379 |
ts_vesicle *vesicle; |
d7a113
|
380 |
*iterations=iter; |
SP |
381 |
*inititer=init; |
|
382 |
*mcsweeps=mcsw; |
b14a8d
|
383 |
vesicle=initial_distribution_dipyramid(nshell,ncxmax,ncymax,nczmax,stepsize); |
a2db52
|
384 |
vesicle->poly_list=init_poly_list(npoly,nmono, vesicle->vlist); |
48bb92
|
385 |
vesicle->spring_constant=kspring; |
M |
386 |
poly_assign_spring_const(vesicle); |
|
387 |
|
a2db52
|
388 |
|
d7639a
|
389 |
vesicle->nshell=nshell; |
SP |
390 |
vesicle->dmax=dmax*dmax; |
|
391 |
vesicle->bending_rigidity=xk0; |
|
392 |
vesicle->stepsize=stepsize; |
a6b1b5
|
393 |
vesicle->clist->ncmax[0]=ncxmax; |
SP |
394 |
vesicle->clist->ncmax[1]=ncymax; |
|
395 |
vesicle->clist->ncmax[2]=nczmax; |
|
396 |
vesicle->clist->max_occupancy=8; |
b14a8d
|
397 |
|
d7639a
|
398 |
cfg_free(cfg); |
b14a8d
|
399 |
free(buf); |
SP |
400 |
// fprintf(stderr,"NSHELL=%u\n",vesicle->nshell); |
40aa5b
|
401 |
|
SP |
402 |
|
|
403 |
|
b14a8d
|
404 |
return vesicle; |
d7639a
|
405 |
|
SP |
406 |
} |
f74313
|
407 |
|
SP |
408 |
|
|
409 |
ts_bool read_geometry_file(char *fname, ts_vesicle *vesicle){ |
|
410 |
FILE *fh; |
|
411 |
ts_uint i, nvtx,nedges,ntria; |
|
412 |
ts_uint vtxi1,vtxi2; |
|
413 |
float x,y,z; |
|
414 |
ts_vertex_list *vlist; |
|
415 |
fh=fopen(fname, "r"); |
|
416 |
if(fh==NULL){ |
|
417 |
err("Cannot open file for reading... Nonexistant file?"); |
|
418 |
return TS_FAIL; |
|
419 |
} |
|
420 |
ts_uint retval; |
|
421 |
retval=fscanf(fh,"%u %u %u",&nvtx, &nedges, &ntria); |
|
422 |
vesicle->vlist=init_vertex_list(nvtx); |
|
423 |
vlist=vesicle->vlist; |
|
424 |
for(i=0;i<nvtx;i++){ |
8f6a69
|
425 |
// fscanf(fh,"%F %F %F",&vlist->vtx[i]->x,&vlist->vtx[i]->y,&vlist->vtx[i]->z); |
f74313
|
426 |
retval=fscanf(fh,"%F %F %F",&x,&y,&z); |
8f6a69
|
427 |
vlist->vtx[i]->x=x; |
SP |
428 |
vlist->vtx[i]->y=y; |
|
429 |
vlist->vtx[i]->z=z; |
f74313
|
430 |
} |
SP |
431 |
for(i=0;i<nedges;i++){ |
|
432 |
retval=fscanf(fh,"%u %u",&vtxi1,&vtxi2); |
|
433 |
bond_add(vesicle->blist,vesicle->vlist->vtx[vtxi1-1],vesicle->vlist->vtx[vtxi2-1]); |
|
434 |
} |
|
435 |
//TODO: neighbours from bonds, |
|
436 |
//TODO: triangles from neigbours |
|
437 |
|
|
438 |
// Don't need to read triangles. Already have enough data |
|
439 |
/* |
|
440 |
for(i=0;i<ntria;i++){ |
|
441 |
retval=fscanf(fh,"%u %u %u", &bi1, &bi2, &bi3); |
8f6a69
|
442 |
vtxi1=vesicle->blist->vertex1->idx; |
SP |
443 |
vtxi2=vesicle->blist->vertex1->idx; |
f74313
|
444 |
|
SP |
445 |
} |
|
446 |
*/ |
41a035
|
447 |
if(retval); |
f74313
|
448 |
fclose(fh); |
SP |
449 |
|
|
450 |
|
|
451 |
|
|
452 |
return TS_SUCCESS; |
|
453 |
} |