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