FrontISTR  5.7.0
Large-scale structural analysis program with finit element method
hecmw_vis_ucd_trans.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 
6 #include "hecmw_vis_ucd_trans.h"
7 
8 #include <stdio.h>
9 #include <string.h>
10 #include <math.h>
11 #include "hecmw_vis_mem_util.h"
12 #include "hecmw_vis_voxel_gen.h"
13 #include "hecmw_malloc.h"
14 
15 /* This program is used to transform GeoFEM UCD files into PVR data format */
16 
17 void transform_ucd_pvr(struct hecmwST_result_data *data, double *node1,
18  struct hecmwST_local_mesh *mesh, Parameter_vr *vr,
19  int my_rank, int pe_size, HECMW_Comm VIS_COMM,
20  double *voxel_dxyz, double *voxel_orig_xyz, int *level,
22  int voxel_on, int display_range_on, int init_flag,
23  int num_of_pvr)
24 
25 {
26  int i, j;
27  int c_base;
28  double range[6], c_range[2];
29  int name_len, find;
30  double x, y, z;
31  int nodeid;
32 
33  int tn_component;
34  double tmp;
35 
36  if ((init_flag == 1) || (num_of_pvr > 1)) {
37  if (my_rank == 0) {
38  fprintf(stderr, "start ucd-pvr transformation\n");
39  /* fprintf(stderr, "------in ucd_trans color_comp_name = %s\n",
40  * vr->color_comp_name);
41  */
42  }
43 
44  if (vr->color_comp == -1) {
45  find = 0;
46  if (strncmp(vr->color_comp_name, "NULL", 4) == 0) {
47  vr->color_comp = 0;
48  find = 1;
49  } else {
50  for (j = 0; j < data->nn_component; j++) {
51  name_len = strlen(data->node_label[j]);
52  if (strncmp(vr->color_comp_name, data->node_label[j], name_len) ==
53  0) {
54  vr->color_comp = j;
55  find = 1;
56  break;
57  }
58  }
59  }
60  if (find == 0) {
61  fprintf(stderr,
62  "ERROR: HEC-MW-VIS-E1053:the name for color component is not "
63  "correct:%s\n",
64  vr->color_comp_name);
65  HECMW_vis_print_exit("please check it again");
66  }
67  }
68  if (data->nn_dof[vr->color_comp] > 1) {
69  if (vr->color_subcomp == -1) {
70  find = 0;
71  if (strncmp(vr->color_subcomp_name, "norm", 4) == 0) {
72  vr->color_subcomp = 0;
73  find = 1;
74  } else if (strncmp(vr->color_subcomp_name, "x", 1) == 0) {
75  vr->color_subcomp = 1;
76  find = 1;
77  } else if (strncmp(vr->color_subcomp_name, "y", 1) == 0) {
78  vr->color_subcomp = 2;
79  find = 1;
80  } else if (strncmp(vr->color_subcomp_name, "z", 1) == 0) {
81  vr->color_subcomp = 3;
82  find = 1;
83  } else
84  vr->color_subcomp = 1;
85  }
86  }
87  }
88  /* fprintf(stderr, "*****ok here color_comp=%d color_subcomp=%d\n",
89  * vr->color_comp, vr->color_subcomp);
90  */
91  range[0] = range[2] = range[4] = 1.0E17;
92  range[1] = range[3] = range[5] = -1.0E17;
93  c_range[0] = 1.0E17;
94  c_range[1] = -1.0E17;
95  /* for(i=0;i<nstep;i++) {
96  tstep=step_start+step_increment*i;
97  sprintf(infile, "%s.%d.%d.inp", resultfile, tstep, my_rank);
98 if ((infp = fopen(infile, "r")) == NULL) {
99  fprintf(stderr, "There is no such an input data file %s:\n", infile);
100  exit (0);
101  }
102 
103 v = (struct visual_buf *)HECMW_malloc(sizeof(struct visual_buf));
104 color_comp=read_ucd(infp, v, range, c_range, str_color, color_subcomp);
105 fclose(infp);
106 fprintf(outfp, "%d\n", v->mesh->n_node);
107 fprintf(outfp, "%d\n", tstep);
108 fprintf(outfp, "%lf\n", 0.0);
109  */
110 
111  if (vr->color_comp >= data->nn_component)
113  "ERROR: HEC-MW-VIS-E1054: color_comp is wrong: >nn_component");
114  if (vr->color_subcomp > data->nn_dof[vr->color_comp])
116  "ERROR: HEC-MW-VIS-E1055: color_subcomp is wrong: >dof");
117  if (data->nn_dof[vr->color_comp] == 1) {
118  c_base = 0;
119  for (i = 0; i < vr->color_comp; i++) c_base += data->nn_dof[i];
120  vr->color_subcomp = 1;
121  } else if (data->nn_dof[vr->color_comp] > 1) {
122  c_base = 0;
123  for (i = 0; i < vr->color_comp; i++) c_base += data->nn_dof[i];
124  }
125  tn_component = 0;
126  for (i = 0; i < data->nn_component; i++) tn_component += data->nn_dof[i];
127 
128  if ((data->nn_dof[vr->color_comp] > 1) && (vr->color_subcomp == 0)) {
129  for (i = 0; i < mesh->n_node; i++) {
130  node1[i] = 0.0;
131  for (j = 0; j < data->nn_dof[vr->color_comp]; j++) {
132  tmp = data->node_val_item[c_base + i * tn_component + j];
133  node1[i] += tmp * tmp;
134  }
135  node1[i] = sqrt(node1[i]);
136  if (node1[i] < c_range[0]) c_range[0] = node1[i];
137  if (node1[i] > c_range[1]) c_range[1] = node1[i];
138  }
139  }
140 
141  else if (data->nn_dof[vr->color_comp] > 1) {
142  for (i = 0; i < mesh->n_node; i++) {
143  node1[i] = data->node_val_item[c_base + i * tn_component +
144  (vr->color_subcomp - 1)];
145  if (node1[i] < c_range[0]) c_range[0] = node1[i];
146  if (node1[i] > c_range[1]) c_range[1] = node1[i];
147  }
148  } else if (data->nn_dof[vr->color_comp] == 1) {
149  for (i = 0; i < mesh->n_node; i++) {
150  node1[i] = data->node_val_item[c_base + i * tn_component];
151  if (node1[i] < c_range[0]) c_range[0] = node1[i];
152  if (node1[i] > c_range[1]) c_range[1] = node1[i];
153  }
154  }
155  if (my_rank == 0)
156  fprintf(stderr, " colorminmax=%lf %lf\n", c_range[0], c_range[1]);
157  /* free_v_node(v);
158  */
159  HECMW_Barrier(VIS_COMM);
160  /*---------find minmax value of mesh ----------------*/
161  for (i = 0; i < mesh->n_elem; i++) {
162  if (mesh->elem_type[i] < 400) {
163  for (j = mesh->elem_node_index[i]; j < mesh->elem_node_index[i + 1];
164  j++) {
165  nodeid = mesh->elem_node_item[j];
166  x = mesh->node[(nodeid - 1) * 3];
167  y = mesh->node[(nodeid - 1) * 3 + 1];
168  z = mesh->node[2 + (nodeid - 1) * 3];
169  if (x > range[1]) range[1] = x;
170  if (x < range[0]) range[0] = x;
171  if (y > range[3]) range[3] = y;
172  if (y < range[2]) range[2] = y;
173  if (z > range[5]) range[5] = z;
174  if (z < range[4]) range[4] = z;
175  }
176  }
177  }
178 
179  voxel_gen(range, c_range, vr->nv_xyz, voxel_dxyz, voxel_orig_xyz, level,
180  voxel_n_neighbor_pe, voxel_neighbor_pe, VIS_COMM, voxel_on,
181  display_range_on, vr->display_range);
182 
183  return;
184 }
hecmw_malloc.h
hecmwST_result_data
Definition: hecmw_result.h:11
if
if(!(yy_init))
Definition: hecmw_ablex.c:1823
_vr_parameter_struct::color_comp_name
char color_comp_name[100]
Definition: hecmw_vis_ray_trace.h:112
hecmw_vis_mem_util.h
hecmwST_local_mesh::elem_node_item
int * elem_node_item
Definition: hecmw_struct.h:196
transform_ucd_pvr
void transform_ucd_pvr(struct hecmwST_result_data *data, double *node1, struct hecmwST_local_mesh *mesh, Parameter_vr *vr, int my_rank, int pe_size, HECMW_Comm VIS_COMM, double *voxel_dxyz, double *voxel_orig_xyz, int *level, int *voxel_n_neighbor_pe, int **voxel_neighbor_pe, int voxel_on, int display_range_on, int init_flag, int num_of_pvr)
Definition: hecmw_vis_ucd_trans.c:17
mesh
struct hecmwST_local_mesh * mesh
Definition: hecmw_repart.h:71
_vr_parameter_struct
Definition: hecmw_vis_ray_trace.h:56
hecmwST_local_mesh
Definition: hecmw_struct.h:139
voxel_n_neighbor_pe
int * voxel_n_neighbor_pe
Definition: hecmw_vis_pvr_main.c:26
hecmwST_local_mesh::elem_type
int * elem_type
Definition: hecmw_struct.h:191
HECMW_vis_print_exit
void HECMW_vis_print_exit(char *var)
Definition: hecmw_vis_mem_util.c:21
hecmwST_local_mesh::n_elem
int n_elem
Definition: hecmw_struct.h:184
voxel_dxyz
double * voxel_dxyz
Definition: hecmw_vis_pvr_main.c:25
level
int * level
Definition: hecmw_vis_pvr_main.c:26
hecmwST_local_mesh::n_node
int n_node
Definition: hecmw_struct.h:161
voxel_orig_xyz
double * voxel_orig_xyz
Definition: hecmw_vis_pvr_main.c:25
hecmwST_local_mesh::node
double * node
Definition: hecmw_struct.h:170
_vr_parameter_struct::display_range
double display_range[6]
Definition: hecmw_vis_ray_trace.h:117
hecmwST_local_mesh::elem_node_index
int * elem_node_index
Definition: hecmw_struct.h:195
hecmw_vis_ucd_trans.h
data
CNFData data
Definition: neu_reporter.cpp:18
_vr_parameter_struct::color_subcomp_name
char color_subcomp_name[5]
Definition: hecmw_vis_ray_trace.h:114
voxel_neighbor_pe
int ** voxel_neighbor_pe
Definition: hecmw_vis_pvr_main.c:26
HECMW_Comm
MPI_Comm HECMW_Comm
Definition: hecmw_config.h:30
_vr_parameter_struct::color_comp
int color_comp
Definition: hecmw_vis_ray_trace.h:113
hecmw_vis_voxel_gen.h
_vr_parameter_struct::nv_xyz
int nv_xyz[3]
Definition: hecmw_vis_ray_trace.h:116
HECMW_Barrier
int HECMW_Barrier(HECMW_Comm comm)
Definition: hecmw_comm.c:95
voxel_gen
void voxel_gen(double range[6], double c_range[2], int nv[3], double *voxel_dxyz, double *voxel_orig_xyz, int *level, int *voxel_n_neighbor_pe, int **voxel_neighbor_pe, HECMW_Comm VIS_COMM, int vox_on, int display_range_on, double display_range[6])
Definition: hecmw_vis_voxel_gen.c:15
_vr_parameter_struct::color_subcomp
int color_subcomp
Definition: hecmw_vis_ray_trace.h:115