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