FrontISTR  5.7.0
Large-scale structural analysis program with finit element method
hecmw_vis_case_table.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_case_table.h"
7 
8 #include <math.h>
10 
11 int p2h(int i) {
12  if (i == 0)
13  return 0;
14  else if (i == 1)
15  return 1;
16  else if (i == 2)
17  return 2;
18  else if (i == 3)
19  return 2;
20  else if (i == 4)
21  return 3;
22  else if (i == 5)
23  return 4;
24  else if (i == 6)
25  return 5;
26  else if (i == 7)
27  return 5;
28  return 0;
29 }
30 
31 int get_data(Surface *sff, struct hecmwST_local_mesh *mesh,
32  struct hecmwST_result_data *data, int elemID, Cell *cell,
33  int tn_component) {
34  int i, j;
35  int nodeID;
36  int c_base, s_base;
37  double c[13], s[13];
38  int tmp_int;
39  double tmp_d;
40 
41  c_base = 0;
42 
43  if (sff->display_way != 4) {
44  for (i = 0; i < sff->color_comp; i++) {
45  c_base += data->nn_dof[i];
46  }
47  }
48  if (sff->surface_style == 2) {
49  s_base = 0;
50  for (i = 0; i < sff->data_comp; i++) s_base += data->nn_dof[i];
51  }
52 
53  /* set field data of voxel in cube */
54  if ((mesh->elem_type[elemID] == 361) || (mesh->elem_type[elemID] == 362)) {
55  for (i = 0; i < HEX_N_NODE; i++) {
56  nodeID = mesh->elem_node_item[mesh->elem_node_index[elemID] + i];
57  if (sff->display_way != 4) {
58  if ((data->nn_dof[sff->color_comp] > 1) && (sff->color_subcomp == 0)) {
59  tmp_d = 0.0;
60  for (j = 0; j < data->nn_dof[sff->color_comp]; j++) {
61  c[j] =
62  data->node_val_item[(nodeID - 1) * tn_component + c_base + j];
63  tmp_d += c[j] * c[j];
64  }
65  cell->c_data[i] = sqrt(tmp_d);
66  } else if ((data->nn_dof[sff->color_comp] > 1) &&
67  (sff->color_subcomp != 0))
68  cell->c_data[i] =
69  data->node_val_item[(nodeID - 1) * tn_component + c_base +
70  (sff->color_subcomp - 1)];
71  else if (data->nn_dof[sff->color_comp] == 1)
72  cell->c_data[i] =
73  data->node_val_item[(nodeID - 1) * tn_component + c_base];
74 
75  } else if (sff->display_way == 4)
76  cell->c_data[i] = sff->specified_color;
77 
78  cell->axis[i * 3] = mesh->node[(nodeID - 1) * 3];
79  cell->axis[i * 3 + 1] = mesh->node[(nodeID - 1) * 3 + 1];
80  cell->axis[i * 3 + 2] = mesh->node[(nodeID - 1) * 3 + 2];
81 
82  if (sff->surface_style == 2) {
83  if ((data->nn_dof[sff->data_comp] > 1) && (sff->data_subcomp == 0)) {
84  tmp_d = 0.0;
85  for (j = 0; j < data->nn_dof[sff->data_comp]; j++) {
86  s[j] =
87  data->node_val_item[(nodeID - 1) * tn_component + s_base + j];
88  tmp_d += s[j] * s[j];
89  }
90  cell->s_data[i] = sqrt(tmp_d);
91  } else if ((data->nn_dof[sff->data_comp] > 1) &&
92  (sff->data_subcomp != 0))
93  cell->s_data[i] =
94  data->node_val_item[(nodeID - 1) * tn_component + s_base +
95  (sff->data_subcomp - 1)];
96  else if (data->nn_dof[sff->data_comp] == 1)
97  cell->s_data[i] =
98  data->node_val_item[(nodeID - 1) * tn_component + s_base];
99  } else if (sff->surface_style == 3)
100 
101  cell->s_data[i] =
102  get_value_equ(sff->cont_equ, sff->cross_type, cell->axis[i * 3],
103  cell->axis[i * 3 + 1], cell->axis[i * 3 + 2]);
104  }
105  } else if ((mesh->elem_type[elemID] == 351) ||
106  (mesh->elem_type[elemID] == 352)) {
107  for (i = 0; i < 8; i++) {
108  tmp_int = p2h(i);
109  nodeID = mesh->elem_node_item[mesh->elem_node_index[elemID] + tmp_int];
110  if (sff->display_way != 4) {
111  if ((data->nn_dof[sff->color_comp] > 1) && (sff->color_subcomp == 0)) {
112  tmp_d = 0.0;
113  for (j = 0; j < data->nn_dof[sff->color_comp]; j++) {
114  c[j] =
115  data->node_val_item[(nodeID - 1) * tn_component + c_base + j];
116  tmp_d += c[j] * c[j];
117  }
118  cell->c_data[i] = sqrt(tmp_d);
119  } else if ((data->nn_dof[sff->color_comp] > 1) &&
120  (sff->color_subcomp != 0))
121  cell->c_data[i] =
122  data->node_val_item[(nodeID - 1) * tn_component + c_base +
123  (sff->color_subcomp - 1)];
124  else if (data->nn_dof[sff->color_comp] == 1)
125  cell->c_data[i] =
126  data->node_val_item[(nodeID - 1) * tn_component + c_base];
127 
128  } else if (sff->display_way == 4)
129  cell->c_data[i] = sff->specified_color;
130 
131  cell->axis[i * 3] = mesh->node[(nodeID - 1) * 3];
132  cell->axis[i * 3 + 1] = mesh->node[(nodeID - 1) * 3 + 1];
133  cell->axis[i * 3 + 2] = mesh->node[(nodeID - 1) * 3 + 2];
134 
135  if (sff->surface_style == 2) {
136  if ((data->nn_dof[sff->data_comp] > 1) && (sff->data_subcomp == 0)) {
137  tmp_d = 0.0;
138  for (j = 0; j < data->nn_dof[sff->data_comp]; j++) {
139  s[j] =
140  data->node_val_item[(nodeID - 1) * tn_component + s_base + j];
141  tmp_d += s[j] * s[j];
142  }
143  cell->s_data[i] = sqrt(tmp_d);
144  } else if ((data->nn_dof[sff->data_comp] > 1) &&
145  (sff->data_subcomp != 0))
146  cell->s_data[i] =
147  data->node_val_item[(nodeID - 1) * tn_component + s_base +
148  (sff->data_subcomp - 1)];
149  else if (data->nn_dof[sff->data_comp] == 1)
150  cell->s_data[i] =
151  data->node_val_item[(nodeID - 1) * tn_component + s_base];
152  } else if (sff->surface_style == 3)
153 
154  cell->s_data[i] =
155  get_value_equ(sff->cont_equ, sff->cross_type, cell->axis[i * 3],
156  cell->axis[i * 3 + 1], cell->axis[i * 3 + 2]);
157  }
158  }
159 
160  cell->elem_id[0] = mesh->elem_ID[elemID * 2];
161  cell->elem_id[1] = mesh->elem_ID[elemID * 2 + 1];
162 
163  return 1;
164 }
165 
166 double get_value_equ(double cont_equ[10], int cross_type, double x, double y,
167  double z)
168 
169 {
170  double value;
171  if (cross_type == 1)
172  value = cont_equ[0] * x + cont_equ[1] * y + cont_equ[2] * z + cont_equ[3];
173  else if (cross_type == 2)
174  value = cont_equ[0] * x * x + cont_equ[1] * y * y + cont_equ[2] * z * z +
175  cont_equ[3] * x * y + cont_equ[4] * y * z + cont_equ[5] * x * z +
176  cont_equ[6] * x + cont_equ[7] * y + cont_equ[8] * z + cont_equ[9];
177  else {
178  fprintf(stderr, "The value of cross type is wrong\n");
179  return (-1);
180  }
181  return (value);
182 }
183 
184 /* make the boundary patches of interval volumes in each cube */
185 int make_tile(struct hecmwST_local_mesh *mesh, Cell *cell, double fvalue,
186  int CS_type, Cube_polygons *cube_polys, int disamb_flag) {
187  int index, config;
188 
189  /* decide the configuration of volume in cube */
190  index = 0;
191  if (!CS_type) {
192  /* when alpha volume */
193  index |= (cell->s_data[0] >= fvalue) ? (int)1 : (int)0;
194  index |= (cell->s_data[1] >= fvalue) ? (int)2 : (int)0;
195  index |= (cell->s_data[2] >= fvalue) ? (int)4 : (int)0;
196  index |= (cell->s_data[3] >= fvalue) ? (int)8 : (int)0;
197  index |= (cell->s_data[4] >= fvalue) ? (int)16 : (int)0;
198  index |= (cell->s_data[5] >= fvalue) ? (int)32 : (int)0;
199  index |= (cell->s_data[6] >= fvalue) ? (int)64 : (int)0;
200  index |= (cell->s_data[7] >= fvalue) ? (int)128 : (int)0;
201  } else {
202  /* when beta volume */
203  index |= (cell->s_data[0] < fvalue) ? (int)1 : (int)0;
204  index |= (cell->s_data[1] < fvalue) ? (int)2 : (int)0;
205  index |= (cell->s_data[2] < fvalue) ? (int)4 : (int)0;
206  index |= (cell->s_data[3] < fvalue) ? (int)8 : (int)0;
207  index |= (cell->s_data[4] < fvalue) ? (int)16 : (int)0;
208  index |= (cell->s_data[5] < fvalue) ? (int)32 : (int)0;
209  index |= (cell->s_data[6] < fvalue) ? (int)64 : (int)0;
210  index |= (cell->s_data[7] < fvalue) ? (int)128 : (int)0;
211  }
212 
213  /* make tile data of cube */
214  if (!index) return 0;
215  if ((config = get_config_info(index)) > 0) {
216  switch (config) {
217  case 1:
218  case1_tiler_hex(index, cube_polys);
219  break;
220  case 2:
221  case2_tiler_hex(index, cube_polys);
222  break;
223  case 3:
224  case3_tiler_hex(mesh, cell, fvalue, CS_type, index, cube_polys,
225  disamb_flag);
226  break;
227  case 4:
228  case4_tiler_hex(index, cube_polys);
229  break;
230  case 5:
231  case5_tiler_hex(index, cube_polys);
232  break;
233  case 6:
234  case6_tiler_hex(mesh, cell, fvalue, CS_type, index, cube_polys,
235  disamb_flag);
236  break;
237  case 7:
238  case7_tiler_hex(mesh, cell, fvalue, CS_type, index, cube_polys,
239  disamb_flag);
240  break;
241  case 8:
242  case8_tiler_hex(index, cube_polys);
243  break;
244  case 9:
245  case9_tiler_hex(index, cube_polys);
246  break;
247  case 10:
248  case10_tiler_hex(mesh, cell, fvalue, CS_type, index, cube_polys,
249  disamb_flag);
250  break;
251  case 11:
252  case11_tiler_hex(index, cube_polys);
253  break;
254  case 12:
255  case12_tiler_hex(mesh, cell, fvalue, CS_type, index, cube_polys,
256  disamb_flag);
257  break;
258  case 13:
259  case13_tiler_hex(mesh, cell, fvalue, CS_type, index, cube_polys,
260  disamb_flag);
261  break;
262  case 14:
263  case14_tiler_hex(index, cube_polys);
264  break;
265  }
266  } else {
267  switch (config) {
268  case 0:
269  case0opp_tiler_hex(cube_polys);
270  break;
271  case -1:
272  case1opp_tiler_hex(index, cube_polys);
273  break;
274  case -2:
275  case2opp_tiler_hex(index, cube_polys);
276  break;
277  case -3:
278  case3opp_tiler_hex(mesh, cell, fvalue, CS_type, index, cube_polys,
279  disamb_flag);
280  break;
281  case -4:
282  case4opp_tiler_hex(index, cube_polys);
283  break;
284  case -5:
285  case5opp_tiler_hex(index, cube_polys);
286  break;
287  case -6:
288  case6opp_tiler_hex(mesh, cell, fvalue, CS_type, index, cube_polys,
289  disamb_flag);
290  break;
291  case -7:
292  case7opp_tiler_hex(mesh, cell, fvalue, CS_type, index, cube_polys,
293  disamb_flag);
294  break;
295  case -8:
296  case8opp_tiler_hex(index, cube_polys);
297  break;
298  case -9:
299  case9opp_tiler_hex(index, cube_polys);
300  break;
301  case -10:
302  case10opp_tiler_hex(mesh, cell, fvalue, CS_type, index, cube_polys,
303  disamb_flag);
304  break;
305  case -11:
306  case11opp_tiler_hex(index, cube_polys);
307  break;
308  case -12:
309  case12opp_tiler_hex(mesh, cell, fvalue, CS_type, index, cube_polys,
310  disamb_flag);
311  break;
312  case -13:
313  case13opp_tiler_hex(mesh, cell, fvalue, CS_type, index, cube_polys,
314  disamb_flag);
315  break;
316  case -14:
317  case14opp_tiler_hex(index, cube_polys);
318  break;
319  }
320  }
321 
322  return index;
323 }
324 
325 /* decide the cube configuration */
326 int get_config_info(int index) {
327  static int config_list[256] = {
328  0, 1, 1, 2, 1, 3, 2, 5, 1, 2, 3, 5, 2, 5, 5,
329  8, 1, 2, 3, 5, 4, 6, 6, -14, 3, 5, 7, -9, 6, 11,
330  12, -5, 1, 3, 2, 5, 3, 7, 5, -9, 4, 6, 6, 11, 6,
331  12, -14, -5, 2, 5, 5, 8, 6, 12, 11, -5, 6, -14, 12, -5,
332  10, -6, -6, -2, 1, 4, 3, 6, 2, 6, 5, 11, 3, 6, 7,
333  12, 5, -14, -9, -5, 3, 6, 7, 12, 6, 10, 12, -6, 7, 12,
334  -13, -7, 12, -6, -7, -3, 2, 6, 5, -14, 5, 12, 8, -5, 6,
335  10, 12, -6, 11, -6, -5, -2, 5, 11, -9, -5, -14, -6, -5, -2,
336  12, -6, -7, -3, -6, -4, -3, -1, 1, 3, 4, 6, 3, 7, 6,
337  -12, 2, 5, 6, 14, 5, 9, -11, -5, 2, 5, 6, -11, 6, -12,
338  -10, -6, 5, -8, -12, -5, 14, -5, -6, -2, 3, 7, 6, -12, 7,
339  13, -12, -7, 6, -12, -10, -6, -12, -7, -6, -3, 5, 9, 14, -5,
340  -12, -7, -6, -3, -11, -5, -6, -2, -6, -3, -4, -1, 2, 6, 6,
341  -10, 5, -12, 14, -6, 5, -11, -12, -6, -8, -5, -5, -2, 5, 14,
342  -12, -6, -11, -6, -6, -4, 9, -5, -7, -3, -5, -2, -3, -1, 5,
343  -12, -11, -6, 9, -7, -5, -3, 14, -6, -6, -4, -5, -3, -2, -1,
344  -8, -5, -5, -2, -5, -3, -2, -1, -5, -2, -3, -1, -2, -1, -1,
345  0};
346 
347  return config_list[index];
348 }
hecmwST_result_data
Definition: hecmw_result.h:11
get_data
int get_data(Surface *sff, struct hecmwST_local_mesh *mesh, struct hecmwST_result_data *data, int elemID, Cell *cell, int tn_component)
Definition: hecmw_vis_case_table.c:31
case4_tiler_hex
void case4_tiler_hex(int index, Cube_polygons *cube_polys)
Definition: hecmw_vis_intersection_find.c:723
case7_tiler_hex
void case7_tiler_hex(struct hecmwST_local_mesh *mesh, Cell *cell, double fvalue, int CS_type, int index, Cube_polygons *cube_polys, int disamb_flag)
Definition: hecmw_vis_intersection_find.c:1493
case2_tiler_hex
void case2_tiler_hex(int index, Cube_polygons *cube_polys)
Definition: hecmw_vis_intersection_find.c:317
case5opp_tiler_hex
void case5opp_tiler_hex(int index, Cube_polygons *cube_polys)
Definition: hecmw_vis_intersection_find.c:894
_surface_module_struct::color_subcomp
int color_subcomp
Definition: hecmw_vis_SF_geom.h:141
hecmwST_local_mesh::elem_node_item
int * elem_node_item
Definition: hecmw_struct.h:196
p2h
int p2h(int i)
Definition: hecmw_vis_case_table.c:11
case11_tiler_hex
void case11_tiler_hex(int index, Cube_polygons *cube_polys)
Definition: hecmw_vis_intersection_find.c:2384
_surface_module_struct::cross_type
int cross_type
Definition: hecmw_vis_SF_geom.h:142
case4opp_tiler_hex
void case4opp_tiler_hex(int index, Cube_polygons *cube_polys)
Definition: hecmw_vis_intersection_find.c:758
mesh
struct hecmwST_local_mesh * mesh
Definition: hecmw_repart.h:71
_surface_module_struct::display_way
int display_way
Definition: hecmw_vis_SF_geom.h:144
case12_tiler_hex
void case12_tiler_hex(struct hecmwST_local_mesh *mesh, Cell *cell, double fvalue, int CS_type, int index, Cube_polygons *cube_polys, int disamb_flag)
Definition: hecmw_vis_intersection_find.c:2456
_cell_struct::elem_id
int elem_id[2]
Definition: hecmw_vis_SF_geom.h:258
_cell_struct::s_data
double s_data[8]
Definition: hecmw_vis_SF_geom.h:254
hecmwST_local_mesh
Definition: hecmw_struct.h:139
case8opp_tiler_hex
void case8opp_tiler_hex(int index, Cube_polygons *cube_polys)
Definition: hecmw_vis_intersection_find.c:2111
get_config_info
int get_config_info(int index)
Definition: hecmw_vis_case_table.c:326
hecmwST_local_mesh::elem_ID
int * elem_ID
Definition: hecmw_struct.h:189
case13opp_tiler_hex
void case13opp_tiler_hex(struct hecmwST_local_mesh *mesh, Cell *cell, double fvalue, int CS_type, int index, Cube_polygons *cube_polys, int disamb_flag)
Definition: hecmw_vis_intersection_find.c:3006
_surface_module_struct::surface_style
int surface_style
Definition: hecmw_vis_SF_geom.h:134
case9_tiler_hex
void case9_tiler_hex(int index, Cube_polygons *cube_polys)
Definition: hecmw_vis_intersection_find.c:2138
hecmwST_local_mesh::elem_type
int * elem_type
Definition: hecmw_struct.h:191
case5_tiler_hex
void case5_tiler_hex(int index, Cube_polygons *cube_polys)
Definition: hecmw_vis_intersection_find.c:793
_surface_module_struct::specified_color
double specified_color
Definition: hecmw_vis_SF_geom.h:147
case12opp_tiler_hex
void case12opp_tiler_hex(struct hecmwST_local_mesh *mesh, Cell *cell, double fvalue, int CS_type, int index, Cube_polygons *cube_polys, int disamb_flag)
Definition: hecmw_vis_intersection_find.c:2637
_surface_module_struct::data_comp
int data_comp
Definition: hecmw_vis_SF_geom.h:137
_surface_module_struct::data_subcomp
int data_subcomp
Definition: hecmw_vis_SF_geom.h:138
case14opp_tiler_hex
void case14opp_tiler_hex(int index, Cube_polygons *cube_polys)
Definition: hecmw_vis_intersection_find.c:3231
hecmwST_local_mesh::node
double * node
Definition: hecmw_struct.h:170
case3_tiler_hex
void case3_tiler_hex(struct hecmwST_local_mesh *mesh, Cell *cell, double fvalue, int CS_type, int index, Cube_polygons *cube_polys, int disamb_flag)
Definition: hecmw_vis_intersection_find.c:437
_cell_struct::axis
double axis[3 *8]
Definition: hecmw_vis_SF_geom.h:253
hecmw_vis_case_table.h
_cell_struct::c_data
double c_data[8]
Definition: hecmw_vis_SF_geom.h:255
case10opp_tiler_hex
void case10opp_tiler_hex(struct hecmwST_local_mesh *mesh, Cell *cell, double fvalue, int CS_type, int index, Cube_polygons *cube_polys, int disamb_flag)
Definition: hecmw_vis_intersection_find.c:2291
make_tile
int make_tile(struct hecmwST_local_mesh *mesh, Cell *cell, double fvalue, int CS_type, Cube_polygons *cube_polys, int disamb_flag)
Definition: hecmw_vis_case_table.c:185
_cell_struct
Definition: hecmw_vis_SF_geom.h:252
case8_tiler_hex
void case8_tiler_hex(int index, Cube_polygons *cube_polys)
Definition: hecmw_vis_intersection_find.c:2084
_surface_module_struct
Definition: hecmw_vis_SF_geom.h:133
hecmwST_local_mesh::elem_node_index
int * elem_node_index
Definition: hecmw_struct.h:195
case10_tiler_hex
void case10_tiler_hex(struct hecmwST_local_mesh *mesh, Cell *cell, double fvalue, int CS_type, int index, Cube_polygons *cube_polys, int disamb_flag)
Definition: hecmw_vis_intersection_find.c:2198
data
CNFData data
Definition: neu_reporter.cpp:18
case2opp_tiler_hex
void case2opp_tiler_hex(int index, Cube_polygons *cube_polys)
Definition: hecmw_vis_intersection_find.c:377
_surface_module_struct::cont_equ
double cont_equ[10]
Definition: hecmw_vis_SF_geom.h:143
hecmw_vis_intersection_find.h
case1opp_tiler_hex
void case1opp_tiler_hex(int index, Cube_polygons *cube_polys)
Definition: hecmw_vis_intersection_find.c:269
case3opp_tiler_hex
void case3opp_tiler_hex(struct hecmwST_local_mesh *mesh, Cell *cell, double fvalue, int CS_type, int index, Cube_polygons *cube_polys, int disamb_flag)
Definition: hecmw_vis_intersection_find.c:580
case0opp_tiler_hex
void case0opp_tiler_hex(Cube_polygons *cube_polys)
Definition: hecmw_vis_intersection_find.c:202
case6opp_tiler_hex
void case6opp_tiler_hex(struct hecmwST_local_mesh *mesh, Cell *cell, double fvalue, int CS_type, int index, Cube_polygons *cube_polys, int disamb_flag)
Definition: hecmw_vis_intersection_find.c:1243
_surface_module_struct::color_comp
int color_comp
Definition: hecmw_vis_SF_geom.h:140
HEX_N_NODE
#define HEX_N_NODE
Definition: hecmw_repart.h:20
get_value_equ
double get_value_equ(double cont_equ[10], int cross_type, double x, double y, double z)
Definition: hecmw_vis_case_table.c:166
case13_tiler_hex
void case13_tiler_hex(struct hecmwST_local_mesh *mesh, Cell *cell, double fvalue, int CS_type, int index, Cube_polygons *cube_polys, int disamb_flag)
Definition: hecmw_vis_intersection_find.c:2818
_cube_polygons_struct
Definition: hecmw_vis_SF_geom.h:239
case7opp_tiler_hex
void case7opp_tiler_hex(struct hecmwST_local_mesh *mesh, Cell *cell, double fvalue, int CS_type, int index, Cube_polygons *cube_polys, int disamb_flag)
Definition: hecmw_vis_intersection_find.c:1788
case6_tiler_hex
void case6_tiler_hex(struct hecmwST_local_mesh *mesh, Cell *cell, double fvalue, int CS_type, int index, Cube_polygons *cube_polys, int disamb_flag)
Definition: hecmw_vis_intersection_find.c:993
case11opp_tiler_hex
void case11opp_tiler_hex(int index, Cube_polygons *cube_polys)
Definition: hecmw_vis_intersection_find.c:2420
case9opp_tiler_hex
void case9opp_tiler_hex(int index, Cube_polygons *cube_polys)
Definition: hecmw_vis_intersection_find.c:2168
case14_tiler_hex
void case14_tiler_hex(int index, Cube_polygons *cube_polys)
Definition: hecmw_vis_intersection_find.c:3195
case1_tiler_hex
void case1_tiler_hex(int index, Cube_polygons *cube_polys)
Definition: hecmw_vis_intersection_find.c:221