FrontISTR  5.7.0
Large-scale structural analysis program with finit element method
hecmw2fstr_connect_conv.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  *****************************************************************************/
9 #include <string.h>
10 #include <stdlib.h>
11 #include <assert.h>
12 
13 #define Table232_Size 6
14 #define Table342_Size 10
15 #define Table352_Size 15
16 
17 /* for HECMW to FSTR */
18 int Table232[] = {1, 2, 3, 6, 4, 5};
19 int Table342[] = {1, 2, 3, 4, 7, 5, 6, 8, 9, 10};
20 int Table352[] = {1, 2, 3, 4, 5, 6, 9, 7, 8, 12, 10, 11, 13, 14, 15};
21 /*int Table232[] = { 1,2,3, 4,5,6 };
22 int Table342[] = { 1,2,3,4, 5,6,7, 8,9,10 };
23 int Table352[] = { 1,2,3,4,5,6, 7,8,9, 10,11,12, 13,14,15 };*/
24 
25 #define MaxItemNumber 15
26 
27 /*======================================================================*/
28 /* */
29 /* HECMW to FSTR Mesh Data Converter */
30 /* Converting Connectivity of Element Type 232, 342 and 352 */
31 /* */
32 /*======================================================================*/
33 
34 void c_hecmw2fstr_connect_conv(int n_elem, int elem_type[],
35  int elem_node_index[], int elem_node_item[]) {
36  int i, j;
37  int start_no;
38  int type;
39  int table_n;
40  int *table;
41  int *item;
42  int buff[MaxItemNumber];
43 
44  for (i = 0; i < n_elem; i++) {
45  type = elem_type[i];
46 
47  if (type != 232 && type != 2322 && type != 342 && type != 3422 &&
48  type != 352)
49  continue;
50 
51  switch (type) {
52  case 232:
53  case 2322:
54  table_n = Table232_Size;
55  table = Table232;
56  break;
57 
58  case 342:
59  case 3422:
60  table_n = Table342_Size;
61  table = Table342;
62  break;
63 
64  case 352:
65  table_n = Table352_Size;
66  table = Table352;
67  break;
68  }
69 
70  start_no = elem_node_index[i];
71  item = &elem_node_item[start_no];
72  memcpy(buff, item, sizeof(int) * table_n);
73 
74  for (j = 0; j < table_n; j++) {
75  item[j] = buff[table[j] - 1];
76  }
77  }
78 }
79 
80 /*======================================================================*/
81 /* */
82 /* FSTR to HECMW Mesh Data Converter */
83 /* Converting Connectivity of Element Type 232, 342 and 352 */
84 /* */
85 /*======================================================================*/
86 
87 void c_fstr2hecmw_connect_conv(int n_elem, int elem_type[],
88  int elem_node_index[], int elem_node_item[]) {
89  int i, j;
90  int start_no;
91  int type;
92  int table_n;
93  int *table;
94  int *item;
95  int buff[MaxItemNumber];
96 
97  for (i = 0; i < n_elem; i++) {
98  type = elem_type[i];
99 
100  if (type != 232 && type != 2322 && type != 342 && type != 3422 &&
101  type != 352)
102  continue;
103 
104  switch (type) {
105  case 232:
106  case 2322:
107  table_n = Table232_Size;
108  table = Table232;
109  break;
110 
111  case 342:
112  case 3422:
113  table_n = Table342_Size;
114  table = Table342;
115  break;
116 
117  case 352:
118  table_n = Table352_Size;
119  table = Table352;
120  break;
121  }
122 
123  start_no = elem_node_index[i];
124  item = &elem_node_item[start_no];
125  memcpy(buff, item, sizeof(int) * table_n);
126 
127  for (j = 0; j < table_n; j++) {
128  item[table[j] - 1] = buff[j];
129  }
130  }
131 }
132 
133 void c_fstr2hecmw_elem_conv(int type, int node[]) {
134  int j;
135  int table_n;
136  int *table;
137  int buff[MaxItemNumber];
138 
139  if (type != 232 && type != 2322 && type != 342 && type != 3422 && type != 352)
140  return;
141 
142  switch (type) {
143  case 232:
144  case 2322:
145  table_n = Table232_Size;
146  table = Table232;
147  break;
148 
149  case 342:
150  case 3422:
151  table_n = Table342_Size;
152  table = Table342;
153  break;
154 
155  case 352:
156  table_n = Table352_Size;
157  table = Table352;
158  break;
159  }
160 
161  memcpy(buff, node, sizeof(int) * table_n);
162 
163  for (j = 0; j < table_n; j++) {
164  node[table[j] - 1] = buff[j];
165  }
166 }
167 
168 /********************************************************************************************************/
169 /* Fortran Interface */
170 
171 void hecmw2fstr_connect_conv(int *n_elem, int elem_type[],
172  int elem_node_index[], int elem_node_item[]) {
173  c_hecmw2fstr_connect_conv(*n_elem, elem_type, elem_node_index,
174  elem_node_item);
175 }
176 
177 void hecmw2fstr_connect_conv_(int *n_elem, int elem_type[],
178  int elem_node_index[], int elem_node_item[]) {
179  c_hecmw2fstr_connect_conv(*n_elem, elem_type, elem_node_index,
180  elem_node_item);
181 }
182 
183 void hecmw2fstr_connect_conv__(int *n_elem, int elem_type[],
184  int elem_node_index[], int elem_node_item[]) {
185  c_hecmw2fstr_connect_conv(*n_elem, elem_type, elem_node_index,
186  elem_node_item);
187 }
188 
189 void HECMW2FSTR_CONNECT_CONV(int *n_elem, int elem_type[],
190  int elem_node_index[], int elem_node_item[]) {
191  c_hecmw2fstr_connect_conv(*n_elem, elem_type, elem_node_index,
192  elem_node_item);
193 }
194 
195 void HECMW2FSTR_CONNECT_CONV_(int *n_elem, int elem_type[],
196  int elem_node_index[], int elem_node_item[]) {
197  c_hecmw2fstr_connect_conv(*n_elem, elem_type, elem_node_index,
198  elem_node_item);
199 }
200 
201 void HECMW2FSTR_CONNECT_CONV__(int *n_elem, int elem_type[],
202  int elem_node_index[], int elem_node_item[]) {
203  c_hecmw2fstr_connect_conv(*n_elem, elem_type, elem_node_index,
204  elem_node_item);
205 }
206 
207 /*---------------------------------------------------------------------------------------------------------*/
208 
209 void fstr2hecmw_connect_conv(int *n_elem, int elem_type[],
210  int elem_node_index[], int elem_node_item[]) {
211  c_fstr2hecmw_connect_conv(*n_elem, elem_type, elem_node_index,
212  elem_node_item);
213 }
214 
215 void fstr2hecmw_connect_conv_(int *n_elem, int elem_type[],
216  int elem_node_index[], int elem_node_item[]) {
217  c_fstr2hecmw_connect_conv(*n_elem, elem_type, elem_node_index,
218  elem_node_item);
219 }
220 
221 void fstr2hecmw_connect_conv__(int *n_elem, int elem_type[],
222  int elem_node_index[], int elem_node_item[]) {
223  c_fstr2hecmw_connect_conv(*n_elem, elem_type, elem_node_index,
224  elem_node_item);
225 }
226 
227 void FSTR2HECMW_CONNECT_CONV(int *n_elem, int elem_type[],
228  int elem_node_index[], int elem_node_item[]) {
229  c_fstr2hecmw_connect_conv(*n_elem, elem_type, elem_node_index,
230  elem_node_item);
231 }
232 
233 void FSTR2HECMW_CONNECT_CONV_(int *n_elem, int elem_type[],
234  int elem_node_index[], int elem_node_item[]) {
235  c_fstr2hecmw_connect_conv(*n_elem, elem_type, elem_node_index,
236  elem_node_item);
237 }
238 
239 void FSTR2HECMW_CONNECT_CONV__(int *n_elem, int elem_type[],
240  int elem_node_index[], int elem_node_item[]) {
241  c_fstr2hecmw_connect_conv(*n_elem, elem_type, elem_node_index,
242  elem_node_item);
243 }
hecmw2fstr_connect_conv_
void hecmw2fstr_connect_conv_(int *n_elem, int elem_type[], int elem_node_index[], int elem_node_item[])
Definition: hecmw2fstr_connect_conv.c:177
HECMW2FSTR_CONNECT_CONV_
void HECMW2FSTR_CONNECT_CONV_(int *n_elem, int elem_type[], int elem_node_index[], int elem_node_item[])
Definition: hecmw2fstr_connect_conv.c:195
c_fstr2hecmw_elem_conv
void c_fstr2hecmw_elem_conv(int type, int node[])
Definition: hecmw2fstr_connect_conv.c:133
hecmw2fstr_connect_conv__
void hecmw2fstr_connect_conv__(int *n_elem, int elem_type[], int elem_node_index[], int elem_node_item[])
Definition: hecmw2fstr_connect_conv.c:183
Table232_Size
#define Table232_Size
I/O and Utility.
Definition: hecmw2fstr_connect_conv.c:13
hecmw2fstr_connect_conv
void hecmw2fstr_connect_conv(int *n_elem, int elem_type[], int elem_node_index[], int elem_node_item[])
Definition: hecmw2fstr_connect_conv.c:171
Table352
int Table352[]
Definition: hecmw2fstr_connect_conv.c:20
HECMW2FSTR_CONNECT_CONV
void HECMW2FSTR_CONNECT_CONV(int *n_elem, int elem_type[], int elem_node_index[], int elem_node_item[])
Definition: hecmw2fstr_connect_conv.c:189
Table342
int Table342[]
Definition: hecmw2fstr_connect_conv.c:19
FSTR2HECMW_CONNECT_CONV
void FSTR2HECMW_CONNECT_CONV(int *n_elem, int elem_type[], int elem_node_index[], int elem_node_item[])
Definition: hecmw2fstr_connect_conv.c:227
c_hecmw2fstr_connect_conv
void c_hecmw2fstr_connect_conv(int n_elem, int elem_type[], int elem_node_index[], int elem_node_item[])
Definition: hecmw2fstr_connect_conv.c:34
FSTR2HECMW_CONNECT_CONV_
void FSTR2HECMW_CONNECT_CONV_(int *n_elem, int elem_type[], int elem_node_index[], int elem_node_item[])
Definition: hecmw2fstr_connect_conv.c:233
MaxItemNumber
#define MaxItemNumber
Definition: hecmw2fstr_connect_conv.c:25
fstr2hecmw_connect_conv_
void fstr2hecmw_connect_conv_(int *n_elem, int elem_type[], int elem_node_index[], int elem_node_item[])
Definition: hecmw2fstr_connect_conv.c:215
c_fstr2hecmw_connect_conv
void c_fstr2hecmw_connect_conv(int n_elem, int elem_type[], int elem_node_index[], int elem_node_item[])
Definition: hecmw2fstr_connect_conv.c:87
HECMW2FSTR_CONNECT_CONV__
void HECMW2FSTR_CONNECT_CONV__(int *n_elem, int elem_type[], int elem_node_index[], int elem_node_item[])
Definition: hecmw2fstr_connect_conv.c:201
Table342_Size
#define Table342_Size
Definition: hecmw2fstr_connect_conv.c:14
Table352_Size
#define Table352_Size
Definition: hecmw2fstr_connect_conv.c:15
fstr2hecmw_connect_conv__
void fstr2hecmw_connect_conv__(int *n_elem, int elem_type[], int elem_node_index[], int elem_node_item[])
Definition: hecmw2fstr_connect_conv.c:221
FSTR2HECMW_CONNECT_CONV__
void FSTR2HECMW_CONNECT_CONV__(int *n_elem, int elem_type[], int elem_node_index[], int elem_node_item[])
Definition: hecmw2fstr_connect_conv.c:239
fstr2hecmw_connect_conv
void fstr2hecmw_connect_conv(int *n_elem, int elem_type[], int elem_node_index[], int elem_node_item[])
Definition: hecmw2fstr_connect_conv.c:209
Table232
int Table232[]
Definition: hecmw2fstr_connect_conv.c:18