FrontISTR 5.2.0
Large-scale structural analysis program with finit element method
Loading...
Searching...
No Matches
hecmw_vis_surface_main.c
Go to the documentation of this file.
1/*****************************************************************************
2 * Copyright (c) 2019 FrontISTR Commons
3 * This software is released under the MIT License, see LICENSE.txt
4 *****************************************************************************/
5
7
8#include <stdio.h>
9#include <stdlib.h>
10#include <string.h>
11#include <math.h>
12#include "hecmw_vis_mem_util.h"
15#include "hecmw_vis_rendering.h"
16#include "hecmw_vis_combine.h"
19#include "hecmw_malloc.h"
20
21static void conv_compname_integer(struct surface_module *sf,
23static void chk_sf_param(struct surface_module *sf,
24 struct hecmwST_result_data *data, int ii);
25static void copy_control_para(Surface *sff, struct surface_module *sf, int ii);
26static void read_surface_equation(Surface *sff, struct surface_module *sf,
27 int ii);
28static void shell2hexa(struct hecmwST_local_mesh *mesh,
29 struct hecmwST_result_data *data, HECMW_Comm VIS_COMM);
30
32
34 struct hecmwST_result_data *data, int *timestep,
35 struct surface_module *sf, Parameter_rendering *sr,
36 int stat_para[NUM_CONTROL_PSF], char *outfile1, char *body,
37 HECMW_Comm VIS_COMM) {
38 int pesize, mynode;
39 Surface *sff;
40
41 int *bdflag;
42 double *minvalue, *maxvalue, *mincolor, *maxcolor, mic, mac;
43 int sum_v, sum_t, tvertex, tpatch;
44 int ii, j, find;
45 int *color_list;
46 double t1, t2, t3;
47 Result *result;
48 int name_len;
49 static int first_boundary = 1;
50
51 HECMW_Comm_size(VIS_COMM, &pesize);
52 HECMW_Comm_rank(VIS_COMM, &mynode);
53
54 if (mynode == 0) {
55 t1 = HECMW_Wtime();
56 t2 = t1;
57 }
58 if (sf[1].output_type == 5) {
59 find = 0;
60 for (j = 0; j < data->nn_component; j++) {
61 name_len = strlen(data->node_label[j]);
62 if (strncmp("NodalSTRESS", data->node_label[j], name_len) == 0 ||
63 strncmp("NodalSTRESSplus", data->node_label[j], name_len) == 0 ||
64 strncmp("TEMPERATURE", data->node_label[j], name_len) == 0) {
65 find = 1;
66 break;
67 }
68 }
69 if (find == 0) {
70 if (mynode == 0) {
71 fprintf(stderr,
72 "The current library only support the FEMAP output for "
73 "structure/heat analysis result.\n");
74 }
75 return;
76 } else {
77 ii = 0;
78 while ((outfile1[ii] != ' ') && (ii < 100) && (outfile1[ii] != '\0')) {
79 if (outfile1[ii] == '.') outfile1[ii] = '_';
80 ii++;
81 }
82 HECMW_fstr_output_femap(mesh, data, outfile1, VIS_COMM);
83 return;
84 }
85 }
86 if ((sf[1].output_type == 6) || (sf[1].output_type == 7) ||
87 (sf[1].output_type == 8) || (sf[1].output_type == 9)) {
88 strcat(outfile1, ".inp");
89 if (sf[1].output_type == 6) {
90 HECMW_avs_output(mesh, data, outfile1, VIS_COMM);
91 } else if (sf[1].output_type == 8) {
92 HECMW_reorder_avs_output(mesh, data, outfile1, VIS_COMM);
93 } else if (sf[1].output_type == 7) {
94 HECMW_bin_avs_output(mesh, data, outfile1, VIS_COMM);
95 } else if (sf[1].output_type == 9) {
96 HECMW_microavs_output(mesh, data, outfile1, VIS_COMM);
97 }
98
99 return;
100 }
101 if (sf[1].output_type == 10) {
102 char buf[16];
103 sprintf(buf, "_%d.inp", mynode);
104 strcat(outfile1, buf);
106 return;
107 } else if(sf[1].output_type==15) {
108 HECMW_vtk_output(mesh, data, body, outfile1, VIS_COMM);
109 return;
110 } else if(sf[1].output_type==16) {
111 HECMW_bin_vtk_output(mesh, data, body, outfile1, VIS_COMM);
112 return;
113 }
114
115 if (mesh->elem_type[0] > 700) shell2hexa(mesh, data, VIS_COMM);
116 conv_compname_integer(sf, data);
117
118 bdflag = (int *)HECMW_calloc(mesh->n_elem, sizeof(int));
119 if (bdflag == NULL) HECMW_vis_memory_exit("bdflag");
120
121 tvertex = 0;
122 tpatch = 0;
123 color_list = (int *)HECMW_calloc(data->nn_component, sizeof(int));
124 if (color_list == NULL) HECMW_vis_memory_exit("color_list");
125 for (ii = 0; ii < data->nn_component; ii++) color_list[ii] = 0;
126 for (ii = 1; ii < sf[0].surface_style + 1; ii++) {
127 if (sf[ii].display_method != 4) {
128 if ((sf[ii].color_comp >= 0) && (sf[ii].color_comp < data->nn_component))
129 color_list[sf[ii].color_comp] = 1;
130 }
131 }
132 minvalue = (double *)HECMW_calloc(data->nn_component, sizeof(double));
133 mincolor = (double *)HECMW_calloc(data->nn_component, sizeof(double));
134 maxvalue = (double *)HECMW_calloc(data->nn_component, sizeof(double));
135 maxcolor = (double *)HECMW_calloc(data->nn_component, sizeof(double));
136 if ((minvalue == NULL) || (mincolor == NULL) || (maxvalue == NULL) ||
137 (maxcolor == NULL))
138 HECMW_vis_memory_exit("minmax_color");
139 for (ii = 0; ii < data->nn_component; ii++) {
140 minvalue[ii] = mincolor[ii] = 1.0E17;
141 maxvalue[ii] = maxcolor[ii] = -1.0E17;
142 }
143 mic = 1.0E17;
144 mac = -1.0E17;
145
146 sff = (Surface *)HECMW_malloc(sizeof(Surface));
147 result = (Result *)HECMW_calloc(sf[0].surface_style, sizeof(Result));
148 if ((sff == NULL) || (result == NULL))
149 HECMW_vis_memory_exit("sff and result");
150 for (ii = 0; ii < sf[0].surface_style; ii++) {
151 result[ii].n_patch = 0;
152 result[ii].n_vertex = 0;
153 result[ii].vertex = NULL;
154 result[ii].color = NULL;
155 result[ii].patch = NULL;
156 }
157
158 for (ii = 1; ii < sf[0].surface_style + 1; ii++) {
159 /* check parameters */
160
161 chk_sf_param(sf, data, ii);
162
163 copy_control_para(sff, sf, ii);
164 /* fprintf(stderr, " coef=%lf %lf %lf %lf surface_style %d display_way:
165%d color_comp=%d\n",sff->cont_equ[6], sff->cont_equ[7], sff->cont_equ[8],
166sff->cont_equ[9],
167sff->surface_style, sff->display_way, sff->color_comp);
168 */
169 if (mesh->elem_type[0] < 300) {
170 if (sff->display_way != 4) {
171 mic = mincolor[sff->color_comp];
172 mac = maxcolor[sff->color_comp];
173 HECMW_vis_surface_compute(sff, mesh, data, bdflag, &sum_v, &sum_t,
174 &tvertex, &tpatch, &mic, &mac, result, ii - 1,
175 mynode, VIS_COMM);
176
177 if (mic < minvalue[sff->color_comp]) minvalue[sff->color_comp] = mic;
178 if (mac > maxvalue[sff->color_comp]) maxvalue[sff->color_comp] = mac;
179 } else if (sff->display_way == 4)
180 HECMW_vis_surface_compute(sff, mesh, data, bdflag, &sum_v, &sum_t,
181 &tvertex, &tpatch, &mic, &mac, result, ii - 1,
182 mynode, VIS_COMM);
183 } else if (mesh->elem_type[0] > 300) {
184 if (sff->surface_style == 1) {
185 if (first_boundary == 1) {
187 if (global_connect == NULL) HECMW_vis_memory_exit("global_connect");
188 }
189 if (sff->display_way != 4) {
190 mic = mincolor[sff->color_comp];
191 mac = maxcolor[sff->color_comp];
192 /* find_fault_surface(sff, v, &tvertex, &tpatch, &mic,&mac, result,
193 * ii-1);
194 */
195 /* if(strncmp(sff->group_name, "boundary", 8)==0)
196 */
197 HECMW_vis_find_boundary_surface(sff, mesh, data, &tvertex, &tpatch,
198 &mic, &mac, result, ii - 1, VIS_COMM,
199 first_boundary, global_connect);
200 if (mic < minvalue[sff->color_comp]) minvalue[sff->color_comp] = mic;
201 if (mac > maxvalue[sff->color_comp]) maxvalue[sff->color_comp] = mac;
202 } else if (sff->display_way == 4) {
203 /* if(strncmp(sff->group_name, "boundary", 8)==0)
204 */
205 HECMW_vis_find_boundary_surface(sff, mesh, data, &tvertex, &tpatch,
206 &mic, &mac, result, ii - 1, VIS_COMM,
207 first_boundary, global_connect);
208 }
209 first_boundary = 0;
210 } else if (sff->surface_style == 2) {
211 if (mynode == 0)
212 fprintf(stderr, "iso surface parameters: %d %lf\n", sff->data_comp,
213 sff->iso_value);
214 HECMW_vis_chk_bounds(mesh, bdflag);
215 sum_v = 0;
216 sum_t = 0;
217 if (sff->display_way != 4) {
218 mic = mincolor[sff->color_comp];
219 mac = maxcolor[sff->color_comp];
220 HECMW_vis_surface_compute(sff, mesh, data, bdflag, &sum_v, &sum_t,
221 &tvertex, &tpatch, &mic, &mac, result,
222 ii - 1, mynode, VIS_COMM);
223
224 if (mic < minvalue[sff->color_comp]) minvalue[sff->color_comp] = mic;
225 if (mac > maxvalue[sff->color_comp]) maxvalue[sff->color_comp] = mac;
226 } else if (sff->display_way == 4)
227 HECMW_vis_surface_compute(sff, mesh, data, bdflag, &sum_v, &sum_t,
228 &tvertex, &tpatch, &mic, &mac, result,
229 ii - 1, mynode, VIS_COMM);
230
231 } else if (sff->surface_style == 3) {
232 /* get_onepoint_on_section(css, p);
233
234for(i=0;i<3;i++)
235pp[i]=p[i];
236
237loopflag=1;
238loopnum=0;
239loopadd=1; loopmin=0;
240while(loopflag==1) {
241loopnum++;*/
242 HECMW_vis_chk_bounds(mesh, bdflag);
243 sum_v = 0;
244 sum_t = 0;
245 if (sff->display_way != 4) {
246 mic = mincolor[sff->color_comp];
247 mac = maxcolor[sff->color_comp];
248
249 HECMW_vis_surface_compute(sff, mesh, data, bdflag, &sum_v, &sum_t,
250 &tvertex, &tpatch, &mic, &mac, result,
251 ii - 1, mynode, VIS_COMM);
252
253 if (mic < minvalue[sff->color_comp]) minvalue[sff->color_comp] = mic;
254 if (mac > maxvalue[sff->color_comp]) maxvalue[sff->color_comp] = mac;
255 } else if (sff->display_way == 4)
256 HECMW_vis_surface_compute(sff, mesh, data, bdflag, &sum_v, &sum_t,
257 &tvertex, &tpatch, &mic, &mac, result,
258 ii - 1, mynode, VIS_COMM);
259 }
260 }
261 }
262 /* fclose(vfile); fclose(pfile); fclose(cfile);
263 */
264 HECMW_free(bdflag);
265 HECMW_Barrier(VIS_COMM);
266 if (mynode == MASTER_PE) {
267 t3 = HECMW_Wtime();
268 fprintf(stderr, "Finish visual computing, the time is: %lf\n", t3 - t2);
269 t2 = t3;
270 }
271 if (sf[1].output_type == 4) {
272 ii = 0;
273 while ((outfile1[ii] != ' ') && (ii < 100) && (outfile1[ii] != '\0')) {
274 if (outfile1[ii] == '.') outfile1[ii] = '_';
275 ii++;
276 }
277 }
278 if ((sf[1].output_type == 1) || (sf[1].output_type == 2) ||
279 (sf[1].output_type == 4))
280 HECMW_vis_combine(sf, mesh, data, tvertex, tpatch, color_list, minvalue,
281 maxvalue, result, outfile1, VIS_COMM);
282 else if (sf[1].output_type == 3)
283 HECMW_vis_rendering_surface(sf, sr, mesh, data, tvertex, tpatch, color_list,
284 minvalue, maxvalue, result, outfile1, stat_para,
285 VIS_COMM, *timestep);
286
287 if (mynode == 0) {
288 fprintf(stderr, "surface module finish\n");
289 t3 = HECMW_Wtime();
290 fprintf(stderr, "the rendering and output file time is %lf\n", t3 - t2);
291 }
292 for (ii = 0; ii < sf[0].surface_style; ii++) {
293 if (result[ii].n_vertex > 0) {
294 HECMW_free(result[ii].vertex);
295 HECMW_free(result[ii].color);
296 }
297 if (result[ii].n_patch > 0) HECMW_free(result[ii].patch);
298 }
299 HECMW_free(result);
300 /*
301HECMW_free(sff);
302 */
303 HECMW_free(color_list);
304 HECMW_free(mincolor);
305 HECMW_free(maxcolor);
306 HECMW_free(minvalue);
307 HECMW_free(maxvalue);
308 HECMW_Barrier(VIS_COMM);
309 /*}
310if(mynode==0) {
311fprintf(stderr,"surface module finish\n");
312t3=HECMW_Wtime();
313fprintf(stderr, "the rendering and output file time is %lf\n", t3-t2);
314}
315
316HECMW_Finalize();
317 */
318
319 return;
320}
321
322static void conv_compname_integer(struct surface_module *sf,
323 struct hecmwST_result_data *data) {
324 int i, j, name_len, find;
325
326 for (i = 1; i < sf[0].surface_style + 1; i++) {
327 if (sf[i].surface_style == 2) {
328 if (sf[i].data_comp < 0) {
329 find = 0;
330 if (strncmp(sf[i].data_comp_name, "NULL", 4) != 0) {
331 for (j = 0; j < data->nn_component; j++) {
332 name_len = strlen(data->node_label[j]);
333 if (strncmp(sf[i].data_comp_name, data->node_label[j], name_len) ==
334 0) {
335 sf[i].data_comp = j;
336 find = 1;
337 break;
338 }
339 }
340 }
341 if (find == 0) {
342 fprintf(stderr,
343 "ERROR: HEC-MW-VIS-E1051:the name for data component is not "
344 "correct:%s\n",
345 sf[i].data_comp_name);
346 HECMW_vis_print_exit("Please check it again");
347 }
348 }
349
350 if (data->nn_dof[sf[i].data_comp] > 1) {
351 if (sf[i].data_subcomp < 0) {
352 find = 0;
353 if (strncmp(sf[i].data_subcomp_name, "norm", 4) == 0) {
354 sf[i].data_subcomp = 0;
355 find = 1;
356 } else if (strncmp(sf[i].data_subcomp_name, "x", 1) == 0) {
357 sf[i].data_subcomp = 1;
358 find = 1;
359 } else if (strncmp(sf[i].data_subcomp_name, "y", 1) == 0) {
360 sf[i].data_subcomp = 2;
361 find = 1;
362 } else if (strncmp(sf[i].data_subcomp_name, "z", 1) == 0) {
363 sf[i].data_subcomp = 3;
364 find = 1;
365 } else {
366 fprintf(stderr,
367 "ERROR: HEC-MW-VIS-E1052:The subcompnent name is not "
368 "correct, it must be norm, x, y, or z. \n");
369 HECMW_vis_print_exit("Please check it again");
370 }
371 }
372 }
373 }
374
375 if (sf[i].deform_display_on == 1) {
376 if (sf[i].disp_comp < 0) {
377 find = 0;
378 if (strncmp(sf[i].disp_comp_name, "NULL", 4) != 0) {
379 for (j = 0; j < data->nn_component; j++) {
380 name_len = strlen(data->node_label[j]);
381 if (strncmp(sf[i].disp_comp_name, data->node_label[j], name_len) ==
382 0) {
383 sf[i].disp_comp = j;
384 find = 1;
385 break;
386 }
387 }
388 }
389 if (find == 0) {
390 fprintf(stderr,
391 "ERROR: HEC-MW-VIS-E1051:the name for deformation component "
392 "is not correct:%s\n",
393 sf[i].disp_comp_name);
394 HECMW_vis_print_exit("Please check it again");
395 }
396 }
397 }
398
399 if (sf[i].color_comp < 0) {
400 find = 0;
401 if (strncmp(sf[i].color_comp_name, "NULL", 4) != 0) {
402 for (j = 0; j < data->nn_component; j++) {
403 name_len = strlen(data->node_label[j]);
404 if (strncmp(sf[i].color_comp_name, data->node_label[j], name_len) ==
405 0) {
406 sf[i].color_comp = j;
407 find = 1;
408 break;
409 }
410 }
411 }
412 if (find == 0) {
413 fprintf(stderr,
414 "ERROR: HEC-MW-VIS-E1053:the name for color component is not "
415 "correct:%s\n",
416 sf[i].color_comp_name);
417 HECMW_vis_print_exit("Please check it again");
418 }
419 }
420 if (data->nn_dof[sf[i].color_comp] > 1) {
421 if (sf[i].color_subcomp < 0) {
422 find = 0;
423 if (strncmp(sf[i].color_subcomp_name, "norm", 4) == 0) {
424 sf[i].color_subcomp = 0;
425 find = 1;
426 } else if (strncmp(sf[i].color_subcomp_name, "x", 1) == 0) {
427 sf[i].color_subcomp = 1;
428 find = 1;
429 } else if (strncmp(sf[i].color_subcomp_name, "y", 1) == 0) {
430 sf[i].color_subcomp = 2;
431 find = 1;
432 } else if (strncmp(sf[i].color_subcomp_name, "z", 1) == 0) {
433 sf[i].color_subcomp = 3;
434 find = 1;
435 } else {
436 fprintf(stderr,
437 "ERROR: HEC-MW-VIS-E1052:The subcompnent name is not "
438 "correct, it must be norm, x, y, or z. \n");
439 HECMW_vis_print_exit("Please check it again");
440 }
441 }
442 }
443 }
444 return;
445}
446
447static void chk_sf_param(struct surface_module *sf,
448 struct hecmwST_result_data *data, int ii) {
449 if (data->nn_component < sf[ii].color_comp) {
451 "ERROR: HEC-MW-VIS-E1054: color_comp is wrong: >nn_component");
452 }
453 if (data->nn_dof[sf[ii].color_comp] > 1) {
454 if (sf[ii].color_subcomp > data->nn_dof[sf[ii].color_comp]) {
456 "ERROR: HEC-MW-VIS-E1055: color_subcomp is wrong: >dof");
457 }
458 }
459 /* if(sf[ii].surface_style==1) {
460 if((sf[ii].defined_style<1) || (sf[ii].defined_style>2)){
461 HECMW_vis_print_exit("Error: the style of group defined: 1 or 2");
462 }
463 }
464 */
465 if (sf[ii].surface_style == 2) {
466 if (data->nn_component < sf[ii].data_comp)
468 "ERROR: HEC-MW-VIS-E1056: data component number is wrong: "
469 ">nn_component");
470 if (data->nn_dof[sf[ii].data_comp] > 1) {
471 if (sf[ii].data_subcomp > data->nn_dof[sf[ii].data_comp])
473 "ERROR: HEC-MW-VIS-E1057: data_subcomp is wrong: >dof");
474 }
475 }
476 if (sf[ii].surface_style == 3) {
477 if ((sf[ii].method < 1) || (sf[ii].method > 5)) {
479 "ERROR: HEC-MW-VIS-E1058: the number of method, it must be between "
480 "1 and 5");
481 }
482 if ((sf[ii].display_method < 1) || (sf[ii].display_method > 5)) {
484 "ERROR: HEC-MW-VIS-E1004: the number of display_method,it should be "
485 "between 1 and 5");
486 }
487 if (sf[ii].isoline_number < 0) {
489 "ERROR: HEC-MW-VIS-E1059: the number of isolines,it should be >=0");
490 }
491 }
492 return;
493}
494
495static void copy_control_para(Surface *sff, struct surface_module *sf, int ii) {
496 int j;
497
498 sff->surface_style = sf[ii].surface_style;
499 if (sff->surface_style == 1) {
500 /* sff->group_name=(char *)HECMW_calloc(100, sizeof(char));
501 if(sff->group_name==NULL)
502 HECMW_vis_memory_exit("group_name");
503 sff->group_name=sf[ii].group_name;
504 sff->defined_style=sf[ii].defined_style;
505 */
506 } else if (sff->surface_style == 2) {
507 sff->data_comp = sf[ii].data_comp;
508 sff->data_subcomp = sf[ii].data_subcomp;
509 sff->iso_value = sf[ii].iso_value;
510 } else if (sff->surface_style == 3) {
511 /* fscanf(fp1, "%d", &(css->color_comp));
512 */
513 /* fscanf(fp1, "%d", &(css->cross_type));
514 */ sff->cross_type = 2;
515 read_surface_equation(sff, sf, ii);
516 }
517 /* fscanf(fp1,"%d",&(css->display_way));
518 */ sff->display_way = sf[ii].display_method;
519 if (sff->display_way == 1) {
520 sff->color_comp = sf[ii].color_comp;
521 sff->color_subcomp = sf[ii].color_subcomp;
522 sff->rgbrange[0] = sff->rgbrange[1] = sff->rgbrange[2] = 1.0;
523 sff->isonumber = 0;
524 } else if (sff->display_way == 2) {
525 sff->color_comp = sf[ii].color_comp;
526 sff->color_subcomp = sf[ii].color_subcomp;
527 sff->rgbrange[0] = sff->rgbrange[1] = sff->rgbrange[2] = 0.0;
528 /* fscanf(fp1,"%d", &(css->isonumber));
529 */ sff->isonumber = sf[ii].isoline_number;
530 } else if (sff->display_way == 3) {
531 /* fscanf(fp1, "%lf %lf %lf", &(css->rgbrange[0]),&(css->rgbrange[1]),&(css->rgbrange[2]));
532 */ sff->color_comp = sf[ii].color_comp;
533 sff->color_subcomp = sf[ii].color_subcomp;
534
535 sff->rgbrange[0] = sff->rgbrange[1] = sff->rgbrange[2] = 1.0;
536 sff->isonumber = sf[ii].isoline_number;
537
538 /* fscanf(fp1,"%d", &(css->isonumber));
539 */ }
540 else if(sff->display_way==4) {
541 /* fscanf(fp1, "%lf %lf %lf", &(css->rgbrange[0]),&(css->rgbrange[1]),&(css->rgbrange[2]));
542 */ sff->specified_color = sf[ii].specified_color;
543 sff->rgbrange[0] = sff->rgbrange[1] = sff->rgbrange[2] =
544 1.0;
545
546 /* fscanf(fp1,"%d", &(css->isonumber));
547 */ }
548 else if(sff->display_way==5) {
549 /* fscanf(fp1, "%lf %lf %lf", &(css->rgbrange[0]),&(css->rgbrange[1]),&(css->rgbrange[2]));
550 */ sff->color_comp = sf[ii].color_comp;
551 sff->color_subcomp = sf[ii].color_subcomp;
552
553 sff->rgbrange[0] = sff->rgbrange[1] = sff->rgbrange[2] =
554 1.0;
555 sff->isonumber = sf[ii].isoline_number;
556
557 /* fscanf(fp1,"%d", &(css->isonumber));
558 */ }
560 sff->output_type = sf[ii].output_type;
561 if (sff->deform_display_on == 1) {
562 sff->disp_scale = sf[ii].disp_scale;
563 sff->initial_style = sf[ii].initial_style;
564 sff->deform_style = sf[ii].deform_style;
565 sff->disp_comp = sf[ii].disp_comp;
566 for (j = 0; j < 3; j++) {
567 sff->initial_line_color[j] = sf[ii].initial_line_color[j];
568 sff->deform_line_color[j] = sf[ii].deform_line_color[j];
569 }
570 }
571}
572
573static void read_surface_equation(Surface *sff, struct surface_module *sf,
574 int ii) {
575 int input_way;
576 int i;
577 double point[3], coff[10];
578 double laxis[3], radius;
579 for (i = 0; i < 10; i++) coff[i] = 0.0;
580
581 input_way = sf[ii].method;
582 switch (input_way) {
583 case 1: /*the surface is a sphere*/
584 for (i = 0; i < 3; i++) point[i] = sf[ii].point[i];
585 radius = sf[ii].radius;
586 coff[0] = coff[1] = coff[2] = 1;
587 coff[6] = -2 * point[0];
588 coff[7] = -2 * point[1];
589 coff[8] = -2 * point[2];
590 coff[9] = point[0] * point[0] + point[1] * point[1] +
591 point[2] * point[2] - radius * radius;
592 break;
593
594 case 2: /*the surface is an ellipsoidal surface*/
595 for (i = 0; i < 3; i++) {
596 point[i] = sf[ii].point[i];
597 laxis[i] = sf[ii].length[i];
598 }
599 for (i = 0; i < 3; i++) coff[i] = 1 / (laxis[i] * laxis[i]);
600 for (i = 0; i < 3; i++)
601 coff[i + 6] = -2.0 * point[i] / (laxis[i] * laxis[i]);
602 coff[9] = point[0] * point[0] / (laxis[0] * laxis[0]) +
603 (point[1] * point[1]) / (laxis[1] * laxis[1]) +
604 (point[2] * point[2]) / (laxis[2] * laxis[2]) - 1;
605
606 break;
607
608 case 3: /*the surface is a hyperboloid surface*/
609 for (i = 0; i < 3; i++) {
610 point[i] = sf[ii].point[i];
611 laxis[i] = sf[ii].length[i];
612 }
613
614 for (i = 0; i < 3; i++) coff[i] = 1 / (laxis[i] * laxis[i]);
615 coff[2] = -coff[2];
616 for (i = 0; i < 3; i++)
617 coff[i + 6] = -2.0 * point[i] / (laxis[i] * laxis[i]);
618 coff[8] = -coff[8];
619 coff[9] = point[0] * point[0] / (laxis[0] * laxis[0]) +
620 (point[1] * point[1]) / (laxis[1] * laxis[1]) -
621 (point[2] * point[2]) / (laxis[2] * laxis[2]) - 1;
622 break;
623
624 case 4: /*the surface is parabolic*/
625 for (i = 0; i < 3; i++) {
626 point[i] = sf[ii].point[i];
627 laxis[i] = sf[ii].length[i];
628 }
629 for (i = 0; i < 2; i++) coff[i] = 1 / (laxis[i] * laxis[i]);
630 coff[1] = -coff[1];
631 coff[2] = 0;
632 coff[6] = -2.0 * point[0] / (laxis[0] * laxis[0]);
633 coff[7] = 2.0 * point[1] / (laxis[1] * laxis[1]);
634 coff[8] = -1;
635 coff[9] = point[0] * point[0] / (laxis[0] * laxis[0]) -
636 (point[1] * point[1]) / (laxis[1] * laxis[1]) + point[2];
637 break;
638
639 case 5:
640 for (i = 0; i < 10; i++) coff[i] = sf[ii].coef[i];
641 break;
642 }
643
644 for (i = 0; i < 10; i++) sff->cont_equ[i] = coff[i];
645 return;
646}
647
648#if 0
649double cal_matrix(double a[3][3])
650{
651 double value;
652 value=a[0][0]*a[1][1]*a[2][2]+a[0][1]*a[1][2]*a[2][0]+a[0][2]*a[1][0]*a[2][1]
653 -a[0][0]*a[1][2]*a[2][1]-a[0][1]*a[1][0]*a[2][2]-a[0][2]*a[1][1]*a[2][0];
654 return(value);
655}
656#endif
657
658#ifdef old
659int chk_gid(struct visual_buf *vol, int *bdflag, int *gid, int *over_elem_id) {
660 int i;
661 int count;
662
663 count = 0;
664 for (i = 0; i < vol->mesh->n_elem; i++) {
665 gid[i] = vol->mesh->global_elem_id[i];
666 if ((bdflag[i] % 1024) != HEX_FACE_INDEX) {
667 over_elem_id[count] = i;
668 count++;
669 }
670 }
671
672 return count;
673}
674#endif
675
676#if 0
677int judge_box(double box[HEX_N_NODE*3], double cont_equ[10])
678{
679 int loopflag1,i,sum;
680 double x,y,z,f[HEX_N_NODE];
681 for(i=0;i<HEX_N_NODE;i++) {
682 x=box[i*3];
683 y=box[i*3+1];
684 z=box[i*3+2];
685 f[i]=x*cont_equ[0]+y*cont_equ[1]+z*cont_equ[2]+cont_equ[3];
686 }
687 sum=0;
688 for(i=0;i<HEX_N_NODE;i++) {
689 if(f[i]>0) sum++;
690 if(f[i]<0) sum--;
691 }
692 if((sum==-8) || (sum==8))
693 loopflag1=0;
694 else loopflag1=1;
695 return(loopflag1);
696}
697#endif
698
699#ifdef old_version
700void shell2hexa(struct hecmwST_local_mesh *mesh,
701 struct hecmwST_result_data *data) {
702 int i, j, k;
703 double *coord;
704 int *connect;
705 double thickness;
706 double *value;
707 int tn_component;
708 fprintf(stderr, "Start transforming...\n");
709 /* thickness=1.0;
710 */
711 thickness = mesh->section->sect_R_item[0];
712 coord = (double *)HECMW_calloc(2 * mesh->n_node * 3, sizeof(double));
713 if (coord == NULL) HECMW_vis_memory_exit("coord");
714
715 for (i = 0; i < mesh->n_node; i++) {
716 for (j = 0; j < 3; j++) coord[i * 2 * 3 + j] = mesh->node[i * 3 + j];
717 for (j = 0; j < 2; j++) coord[(i * 2 + 1) * 3 + j] = mesh->node[i * 3 + j];
718 coord[(i * 2 + 1) * 3 + 2] = mesh->node[i * 3 + 2] + thickness;
719 }
721
722 mesh->node = coord;
723 if ((mesh->elem_type[0] == 731) || (mesh->elem_type[0] == 732)) {
724 connect = (int *)HECMW_calloc(mesh->n_elem * 6, sizeof(int));
725 if (connect == NULL) HECMW_vis_memory_exit("connect");
726 for (i = 0; i < mesh->n_elem; i++) {
727 for (j = 0; j < 3; j++)
728 connect[i * 6 + j] =
729 (mesh->elem_node_item[mesh->elem_node_index[i] + j] - 1) * 2 + 1;
730 for (j = 0; j < 3; j++)
731 connect[i * 6 + 3 + j] =
732 (mesh->elem_node_item[mesh->elem_node_index[i] + j] - 1) * 2 + 1 +
733 1;
734 }
735 for (i = 0; i < mesh->n_elem; i++) mesh->elem_type[i] = 351;
736 for (i = 0; i < mesh->n_elem + 1; i++) mesh->elem_node_index[i] = 6 * i;
738 mesh->elem_node_item = connect;
739 } else if ((mesh->elem_type[0] == 741) || (mesh->elem_type[0] == 742) ||
740 (mesh->elem_type[0] == 743)) {
741 connect = (int *)HECMW_calloc(mesh->n_elem * 8, sizeof(int));
742 if (connect == NULL) HECMW_vis_memory_exit("connect");
743 for (i = 0; i < mesh->n_elem; i++) {
744 for (j = 0; j < 4; j++)
745 connect[i * 8 + j] =
746 (mesh->elem_node_item[mesh->elem_node_index[i] + j] - 1) * 2 + 1;
747 for (j = 0; j < 4; j++)
748 connect[i * 8 + 4 + j] =
749 (mesh->elem_node_item[mesh->elem_node_index[i] + j] - 1) * 2 + 1 +
750 1;
751 /* fprintf(stderr, "%d ", i);
752 for(j=0;j<8;j++)
753 fprintf(stderr, "%d ", connect[i*8+j]);
754 fprintf(stderr, "\n");
755 */
756 }
757 for (i = 0; i < mesh->n_elem; i++) mesh->elem_type[i] = 361;
758 for (i = 0; i < mesh->n_elem + 1; i++) mesh->elem_node_index[i] = 8 * i;
760 mesh->elem_node_item = connect;
761 }
762 tn_component = 0;
763 for (i = 0; i < data->nn_component; i++) tn_component += data->nn_dof[i];
764 value =
765 (double *)HECMW_calloc(tn_component * mesh->n_node * 2, sizeof(double));
766 if (value == NULL) HECMW_vis_memory_exit("value");
767 for (i = 0; i < mesh->n_node; i++) {
768 for (j = 0; j < tn_component; j++)
769 value[i * 2 * tn_component + j] =
770 data->node_val_item[i * tn_component + j];
771 for (j = 0; j < tn_component; j++)
772 value[(i * 2 + 1) * tn_component + j] =
773 data->node_val_item[i * tn_component + j];
774 }
775 HECMW_free(data->node_val_item);
776 data->node_val_item = value;
777
778 fprintf(stderr, "It is ok to transform shell to solid\n");
779 mesh->n_node *= 2;
780 mesh->nn_internal *= 2;
781
782 return;
783}
784
785#endif
786
787static void shell2hexa(struct hecmwST_local_mesh *mesh,
788 struct hecmwST_result_data *data, HECMW_Comm VIS_COMM) {
789 int i, j;
790 double *coord;
791 int *connect;
792 double thickness;
793 double *value;
794 int tn_component, pesize;
795 double range[6], trange[6];
796 fprintf(stderr, "Start transforming...\n");
797 /* thickness=1.0;
798 */
799
800 HECMW_Comm_size(VIS_COMM, &pesize);
801 range[0] = range[2] = range[4] = 1.0E17;
802 range[1] = range[3] = range[5] = -1.0E17;
803
804 for (i = 0; i < mesh->n_node; i++) {
805 for (j = 0; j < 3; j++) {
806 if (mesh->node[i * 3 + j] < range[j * 2])
807 range[j * 2] = mesh->node[i * 3 + j];
808 if (mesh->node[i * 3 + j] > range[j * 2 + 1])
809 range[j * 2 + 1] = mesh->node[i * 3 + j];
810 }
811 }
812 if (pesize > 1) {
813 HECMW_Allreduce(&range[0], &trange[0], 1, HECMW_DOUBLE, HECMW_MIN,
814 VIS_COMM);
815 HECMW_Allreduce(&range[1], &trange[1], 1, HECMW_DOUBLE, HECMW_MAX,
816 VIS_COMM);
817 HECMW_Allreduce(&range[2], &trange[2], 1, HECMW_DOUBLE, HECMW_MIN,
818 VIS_COMM);
819 HECMW_Allreduce(&range[3], &trange[3], 1, HECMW_DOUBLE, HECMW_MAX,
820 VIS_COMM);
821 HECMW_Allreduce(&range[4], &trange[4], 1, HECMW_DOUBLE, HECMW_MIN,
822 VIS_COMM);
823 HECMW_Allreduce(&range[5], &trange[5], 1, HECMW_DOUBLE, HECMW_MAX,
824 VIS_COMM);
825 } else {
826 for (i = 0; i < 6; i++) trange[i] = range[i];
827 }
828 thickness = 0.01 * sqrt((trange[1] - trange[0]) * (trange[1] - trange[0]) +
829 (trange[3] - trange[2]) * (trange[3] - trange[2]) +
830 (trange[5] - trange[4]) * (trange[5] - trange[4]));
831 coord = (double *)HECMW_calloc(2 * mesh->n_node * 3, sizeof(double));
832 if (coord == NULL) HECMW_vis_memory_exit("coord");
833
834 for (i = 0; i < mesh->n_node; i++) {
835 for (j = 0; j < 3; j++) coord[i * 2 * 3 + j] = mesh->node[i * 3 + j];
836 for (j = 0; j < 2; j++) coord[(i * 2 + 1) * 3 + j] = mesh->node[i * 3 + j];
837 coord[(i * 2 + 1) * 3 + 2] = mesh->node[i * 3 + 2] + thickness;
838 }
840
841 mesh->node = coord;
842 if ((mesh->elem_type[0] == 731) || (mesh->elem_type[0] == 732)) {
843 connect = (int *)HECMW_calloc(mesh->n_elem * 6, sizeof(int));
844 if (connect == NULL) HECMW_vis_memory_exit("connect");
845 for (i = 0; i < mesh->n_elem; i++) {
846 for (j = 0; j < 3; j++)
847 connect[i * 6 + j] =
848 (mesh->elem_node_item[mesh->elem_node_index[i] + j] - 1) * 2 + 1;
849 for (j = 0; j < 3; j++)
850 connect[i * 6 + 3 + j] =
851 (mesh->elem_node_item[mesh->elem_node_index[i] + j] - 1) * 2 + 1 +
852 1;
853 }
854 for (i = 0; i < mesh->n_elem; i++) mesh->elem_type[i] = 351;
855 for (i = 0; i < mesh->n_elem + 1; i++) mesh->elem_node_index[i] = 6 * i;
857 mesh->elem_node_item = connect;
858 } else if ((mesh->elem_type[0] == 741) || (mesh->elem_type[0] == 742) ||
859 (mesh->elem_type[0] == 743)) {
860 connect = (int *)HECMW_calloc(mesh->n_elem * 8, sizeof(int));
861 if (connect == NULL) HECMW_vis_memory_exit("connect");
862 for (i = 0; i < mesh->n_elem; i++) {
863 for (j = 0; j < 4; j++)
864 connect[i * 8 + j] =
865 (mesh->elem_node_item[mesh->elem_node_index[i] + j] - 1) * 2 + 1;
866 for (j = 0; j < 4; j++)
867 connect[i * 8 + 4 + j] =
868 (mesh->elem_node_item[mesh->elem_node_index[i] + j] - 1) * 2 + 1 +
869 1;
870 /* fprintf(stderr, "%d ", i);
871 for(j=0;j<8;j++)
872 fprintf(stderr, "%d ", connect[i*8+j]);
873 fprintf(stderr, "\n");
874 */
875 }
876 for (i = 0; i < mesh->n_elem; i++) mesh->elem_type[i] = 361;
877 for (i = 0; i < mesh->n_elem + 1; i++) mesh->elem_node_index[i] = 8 * i;
879 mesh->elem_node_item = connect;
880 }
881 tn_component = 0;
882 for (i = 0; i < data->nn_component; i++) tn_component += data->nn_dof[i];
883 value =
884 (double *)HECMW_calloc(tn_component * mesh->n_node * 2, sizeof(double));
885 if (value == NULL) HECMW_vis_memory_exit("value");
886 for (i = 0; i < mesh->n_node; i++) {
887 for (j = 0; j < tn_component; j++)
888 value[i * 2 * tn_component + j] =
889 data->node_val_item[i * tn_component + j];
890 for (j = 0; j < tn_component; j++)
891 value[(i * 2 + 1) * tn_component + j] =
892 data->node_val_item[i * tn_component + j];
893 }
894 HECMW_free(data->node_val_item);
895 data->node_val_item = value;
896
897 fprintf(stderr, "It is ok to transform shell to solid\n");
898 mesh->n_node *= 2;
899 mesh->nn_internal *= 2;
900
901 return;
902}
int HECMW_Comm_rank(HECMW_Comm comm, int *rank)
Definition: hecmw_comm.c:18
int HECMW_Comm_size(HECMW_Comm comm, int *size)
Definition: hecmw_comm.c:37
int HECMW_Allreduce(void *sendbuf, void *recvbuf, int count, HECMW_Datatype datatype, HECMW_Op op, HECMW_Comm comm)
Definition: hecmw_comm.c:364
int HECMW_Barrier(HECMW_Comm comm)
Definition: hecmw_comm.c:95
#define HECMW_MAX
Definition: hecmw_config.h:56
#define HECMW_DOUBLE
Definition: hecmw_config.h:50
MPI_Comm HECMW_Comm
Definition: hecmw_config.h:30
#define HECMW_MIN
Definition: hecmw_config.h:54
struct hecmwST_local_mesh * mesh
Definition: hecmw_repart.h:71
void HECMW_fstr_output_femap(struct hecmwST_local_mesh *mesh, struct hecmwST_result_data *data, char *outfile, HECMW_Comm VIS_COMM)
void HECMW_separate_avs_output(struct hecmwST_local_mesh *mesh, struct hecmwST_result_data *data, char *outfile)
void HECMW_microavs_output(struct hecmwST_local_mesh *mesh, struct hecmwST_result_data *data, char *outfile, HECMW_Comm VIS_COMM)
void HECMW_bin_avs_output(struct hecmwST_local_mesh *mesh, struct hecmwST_result_data *data, char *outfile, HECMW_Comm VIS_COMM)
void HECMW_avs_output(struct hecmwST_local_mesh *mesh, struct hecmwST_result_data *data, char *outfile, HECMW_Comm VIS_COMM)
void HECMW_reorder_avs_output(struct hecmwST_local_mesh *mesh, struct hecmwST_result_data *data, char *outfile, HECMW_Comm VIS_COMM)
void HECMW_vtk_output(struct hecmwST_local_mesh *mesh, struct hecmwST_result_data *data, char *outfile, char *outfile1, HECMW_Comm VIS_COMM)
void HECMW_bin_vtk_output(struct hecmwST_local_mesh *mesh, struct hecmwST_result_data *data, char *outfile, char *outfile1, HECMW_Comm VIS_COMM)
#define NULL
#define HECMW_calloc(nmemb, size)
Definition: hecmw_malloc.h:21
#define HECMW_free(ptr)
Definition: hecmw_malloc.h:24
#define HECMW_malloc(size)
Definition: hecmw_malloc.h:20
#define HEX_FACE_INDEX
Definition: hecmw_repart.h:23
#define MASTER_PE
Definition: hecmw_repart.h:17
#define HEX_N_NODE
Definition: hecmw_repart.h:20
double HECMW_Wtime(void)
Definition: hecmw_time.c:8
#define NUM_CONTROL_PSF
void HECMW_vis_combine(struct surface_module *sf, struct hecmwST_local_mesh *mesh, struct hecmwST_result_data *data, int tvertex, int tpatch, int *color_list, double *minvalue, double *maxvalue, Result *result, char *outfile, HECMW_Comm VIS_COMM)
void HECMW_vis_find_boundary_surface(Surface *sff, struct hecmwST_local_mesh *mesh, struct hecmwST_result_data *data, int *tvertex, int *tpatch, double *minc, double *maxc, Result *result, int sf_i, HECMW_Comm VIS_COMM, int init_flag, Connect_inf *global_connect)
void HECMW_vis_print_exit(char *var)
void HECMW_vis_memory_exit(char *var)
void HECMW_vis_rendering_surface(struct surface_module *sf, Parameter_rendering *sr, struct hecmwST_local_mesh *mesh, struct hecmwST_result_data *data, int tvertex, int tpatch, int *color_list, double *minvalue, double *maxvalue, Result *result, char *outfile, int stat_para[NUM_CONTROL_PSF], HECMW_Comm VIS_COMM, int timestep)
int HECMW_vis_surface_compute(Surface *sff, struct hecmwST_local_mesh *mesh, struct hecmwST_result_data *data, int *bdflag, int *sum_v, int *sum_t, int *tvertex, int *tpatch, double *minc, double *maxc, Result *result, int sf_i, int mynode, HECMW_Comm VIS_COMM)
int HECMW_vis_chk_bounds(struct hecmwST_local_mesh *mesh, int *bdflag)
Connect_inf * global_connect
void HECMW_vis_psf_rendering(struct hecmwST_local_mesh *mesh, struct hecmwST_result_data *data, int *timestep, struct surface_module *sf, Parameter_rendering *sr, int stat_para[NUM_CONTROL_PSF], char *outfile1, char *body, HECMW_Comm VIS_COMM)
CNFData data
struct hecmwST_section * section
Definition: hecmw_struct.h:244
double * sect_R_item
Definition: hecmw_struct.h:32
double deform_line_color[3]
double initial_line_color[3]