31 static void do_logging(
int loglv,
int msgno,
int add_location,
const char *fmt,
40 if (strlen(msg) > 0) s =
": ";
51 static void set_err_noloc(
int msgno,
const char *fmt, ...) {
59 static void set_err(
int msgno,
const char *fmt, ...) {
67 static void set_err_token(
int token,
int msgno,
const char *fmt, ...) {
81 static void log_warn(
int msgno,
const char *fmt, ...) {
95 static void free_Integer(
void *v) {
104 static struct material_keywords {
107 } material_keywords[] = {
114 #define N_MAT_KEYS (sizeof(material_keywords) / sizeof(material_keywords[0]))
116 static int is_material_keyword(
int keyword) {
120 if (keyword == material_keywords[i].keyword)
return 1;
125 static char *get_material_string(
int keyword) {
129 if (keyword == material_keywords[i].keyword) {
130 return material_keywords[i].string;
138 static int flag_material_zone;
141 static struct material_data {
143 struct hecmw_io_matitem *matitem;
144 struct material_data *next;
147 static int is_material_zone(
void) {
return flag_material_zone; }
149 static void set_material_zone(
int flag) { flag_material_zone = flag ? 1 : 0; }
151 static int add_mat_data(
int keyword,
struct hecmw_io_matitem *matitem) {
153 struct material_data *p, *q, *mdata;
155 for (p = matdata; p; p = p->next) {
156 if (p->keyword == keyword)
break;
159 struct hecmw_io_matsubitem *sip, *siq;
160 struct hecmw_io_matitem *item = p->matitem;
161 p->matitem = matitem;
162 matitem->item = item->item;
163 for (sip = item->subitem; sip; sip = siq) {
170 get_material_string(keyword), matname);
180 mdata->keyword = keyword;
181 mdata->matitem = matitem;
185 for (i = 0, p = matdata; p; p = (q = p)->next, i++)
187 matitem->item = i + 1;
197 static int count_mat_item(
void) {
199 struct material_data *p;
201 for (n = 0, p = matdata; p; p = p->next, n++)
206 static int regist_material(
void) {
209 struct material_data *p, *q;
211 n = count_mat_item();
212 if (n == 0)
return 0;
223 snprintf(mat->
name,
sizeof(mat->
name),
"%s", matname);
231 for (i = 0, p = matdata; p; p = q, i++) {
234 mat->
item[i] = *p->matitem;
253 static int read_mat_data_line_common(
int nval,
int nval_line,
double *val,
261 for (i = 0; i < nval; i++) {
269 set_err_token(token, errmsgno,
"VAL or ',' or NL reuqired");
274 }
else if (token ==
',') {
283 set_err_token(token, errmsgno,
"',' or NL required after VAL");
289 i += nval_line - (i % nval_line);
296 set_err_token(token, errmsgno,
"NL required");
306 static int read_mat_data_common(
int nval,
int nval_line,
int temp_col,
307 struct hecmw_io_matitem **matitem,
int msgno) {
309 struct hecmw_io_matitem *item =
NULL;
310 struct hecmw_io_matsubitem *subitem =
NULL;
311 struct hecmw_io_matsubitem *q, *p =
NULL;
321 item->subitem =
NULL;
325 if (subitem ==
NULL) {
330 subitem->val =
HECMW_malloc(
sizeof(*subitem->val) * nval);
331 if (subitem->val ==
NULL) {
336 if (read_mat_data_line_common(nval, nval_line, subitem->val, msgno))
339 subitem->temp = subitem->val[temp_col - 1];
340 subitem->next =
NULL;
343 item->subitem = subitem;
361 for (p = item->subitem; p; p = q) {
373 static int read_param_dependencies(
int *dependencies,
int msgno) {
378 set_err_token(token, msgno,
"'=' required after DEPENDENCIES");
383 set_err_token(token, msgno,
"Invalid DEPENDENCIES");
387 if (*dependencies <= 0) {
388 set_err_token(token, msgno,
"DEPENDENCIES must be positive integer");
396 static struct etype_conv {
432 static int get_HECMW_etype(
int inp_etype) {
435 for (i = 0; i <
sizeof(etype_conv) /
sizeof(etype_conv[0]); i++) {
436 if (etype_conv[i].inp_etype == inp_etype) {
437 return etype_conv[i].hecmw_etype;
443 static int get_secopt_inp(
int inp_etype) {
446 for (i = 0; i <
sizeof(etype_conv) /
sizeof(etype_conv[0]); i++) {
447 if (etype_conv[i].inp_etype == inp_etype) {
448 return etype_conv[i].secopt;
454 static int get_secopt(
char *elset,
int msgno) {
459 if (elem ==
NULL)
return -1;
462 for (i = 0; i < elem->
n; i++) {
464 if (secopt ==
NULL) {
465 set_err_noloc(msgno,
"");
469 secopt_prev = secopt->
i;
471 if (secopt_prev != secopt->
i)
goto error;
489 static int read_input(
int msgno_invalid_token) {
495 set_err_token(token, msgno_invalid_token,
"'=' required after INPUT");
500 set_err_token(token, msgno_invalid_token,
"Invalid filename for INPUT");
509 snprintf(include_filename,
sizeof(include_filename),
"%s", p);
518 snprintf(include_filename,
sizeof(include_filename),
"%s%s%s", dname,
separator, p);
525 static int read_amplitude_keyword(
void) {
538 "',' required after *AMPLITUDE");
544 static int read_amplitude_param_name(
char *name,
size_t name_len) {
556 "NAME must begin with a letter");
564 snprintf(name, name_len,
"%s", p);
573 static int read_amplitude_param_definition(
int *definition) {
579 "'=' required after DEFINITION");
591 static int read_amplitude_param_time(
int *time) {
608 static int read_amplitude_param_value(
int *value) {
628 static int read_amplitude_data(
char *name,
int definition,
int time,
685 if (token ==
',' && i == NITEM) {
689 "Only %d items allow per line", NITEM);
700 static int read_amplitude(
void) {
711 ST_KEYWORD_LINE_PARAM,
716 state = ST_KEYWORD_LINE;
717 while (state != ST_FINISHED) {
718 if (state == ST_KEYWORD_LINE) {
719 if (read_amplitude_keyword())
return -1;
720 state = ST_KEYWORD_LINE_PARAM;
721 }
else if (state == ST_KEYWORD_LINE_PARAM) {
725 if (read_amplitude_param_name(name,
sizeof(name)))
return -1;
729 if (read_amplitude_param_definition(&definition))
return -1;
732 if (read_amplitude_param_time(&time))
return -1;
735 if (read_amplitude_param_value(&value))
return -1;
753 state = flag_input ? ST_DATA_INCLUDE : ST_DATA_LINE;
754 }
else if (token ==
',') {
760 }
else if (state == ST_DATA_INCLUDE) {
764 state = ST_DATA_LINE;
765 }
else if (state == ST_DATA_LINE) {
768 if (read_amplitude_data(name, definition, time, value))
return -1;
788 fprintf(stderr,
"*ECOPY has not implemented yet\n");
799 fprintf(stderr,
"*EGEN has not implemented yet\n");
807 static int read_elset_keyword(
void) {
825 static int read_elset_param_elset(
char *elset,
size_t elset_len,
int *isAll) {
837 "ELSET must begin with a letter");
845 snprintf(elset, elset_len,
"%s", p);
851 if (strcmp(elset,
"ALL") == 0) {
859 static int read_elset_data(
int *nelem,
int **elem_array) {
860 int token, i,
n, *elem;
898 "',' or NL required after element ID");
913 for (p = head; p; p = q) {
924 for (p = head; p; p = q) {
932 static int read_elset_data_generate(
int *nelem,
int **elem_array) {
933 int token, i, n,
id, *elem;
934 int elem1, elem2, elem3;
986 "NL required after increment");
993 "',' or NL required after elem2");
1001 "Cannot generate between %d and %d with an increment of %d", elem1,
1005 if ((elem2 - elem1) % elem3) {
1007 "Cannot generate between %d and %d with an increment of %d", elem1,
1012 n = (elem2 - elem1) / elem3 + 1;
1020 for (
id = elem1;
id <= elem2;
id += elem3) {
1030 static int read_elset(
void) {
1033 int flag_generate = 0;
1039 ST_KEYWORD_LINE_PARAM,
1041 ST_DATA_LINE_GENERATE
1044 state = ST_KEYWORD_LINE;
1045 while (state != ST_FINISHED) {
1046 if (state == ST_KEYWORD_LINE) {
1047 if (read_elset_keyword())
return -1;
1048 state = ST_KEYWORD_LINE_PARAM;
1049 }
else if (state == ST_KEYWORD_LINE_PARAM) {
1053 if (read_elset_param_elset(elset,
sizeof(elset), &isAll))
return -1;
1071 state = flag_generate ? ST_DATA_LINE_GENERATE : ST_DATA_LINE;
1072 }
else if (token ==
',') {
1078 }
else if (state == ST_DATA_LINE) {
1084 if (read_elset_data(&n, &elem))
return -1;
1092 state = ST_FINISHED;
1094 state = ST_DATA_LINE;
1097 }
else if (state == ST_DATA_LINE_GENERATE) {
1103 if (read_elset_data_generate(&n, &elem))
return -1;
1111 state = ST_FINISHED;
1123 static int read_element_header(
void) {
1141 static int read_element_param_type(
int *
hecmw_etype,
int *inp_etype) {
1163 static int read_element_param_elset(
char *elset,
size_t elset_len) {
1175 "ELSET must begin with a letter");
1183 snprintf(elset, elset_len,
"%s", p);
1189 if (strcmp(elset,
"ALL") == 0) {
1191 snprintf(elset, elset_len,
"INP_ESET_ALL");
1197 static int read_element_data(
int *
id,
int nnode,
int *node) {
1242 if (i == nnode - 1)
break;
1248 "',' or NL required after connectivity");
1268 static int read_element(
void) {
1282 ST_KEYWORD_LINE_PARAM,
1288 state = ST_KEYWORD_LINE;
1289 while (state != ST_FINISHED) {
1290 if (state == ST_KEYWORD_LINE) {
1291 if (read_element_header())
return -1;
1292 state = ST_KEYWORD_LINE_PARAM;
1293 }
else if (state == ST_KEYWORD_LINE_PARAM) {
1297 if (read_element_param_type(&
hecmw_etype, &type))
return -1;
1306 if (read_element_param_elset(elset,
sizeof(elset)))
return -1;
1325 state = flag_input ? ST_DATA_INCLUDE : ST_DATA_LINE;
1326 }
else if (token ==
',') {
1332 }
else if (state == ST_DATA_INCLUDE) {
1336 state = ST_DATA_LINE;
1337 }
else if (state == ST_DATA_LINE) {
1339 if (read_element_data(&
id, nnode, node))
return -1;
1340 state = ST_DATA_LINE_REGIST;
1341 }
else if (state == ST_DATA_LINE_REGIST) {
1355 if (secopt ==
NULL) {
1359 secopt->
i = get_secopt_inp(type);
1361 if (elem_secopt ==
NULL) {
1364 if (elem_secopt ==
NULL)
return -1;
1379 state = ST_DATA_LINE;
1381 state = ST_FINISHED;
1393 static int read_equation_keyword(
int *token) {
1403 "',' or NL required after *EQUATION");
1409 static int read_equation_data_line1(
int *neq) {
1433 static int read_equation_data_line2(
int neq) {
1438 struct hecmw_io_mpcitem *mpcitem =
NULL;
1441 if (mpcitem ==
NULL) {
1446 for (i = 0; i < neq; i++) {
1457 mpcitem[i].ngrp[0] =
'\0';
1469 snprintf(mpcitem[i].ngrp,
sizeof(mpcitem[i].ngrp),
"%s", p);
1475 mpcitem[i].node = -1;
1520 "',' or NL required after coefficient");
1523 if (token ==
',' && i == NITEM - 1) {
1543 static int read_equation(
void) {
1550 ST_KEYWORD_LINE_PARAM,
1556 state = ST_KEYWORD_LINE;
1557 while (state != ST_FINISHED) {
1558 if (state == ST_KEYWORD_LINE) {
1559 if (read_equation_keyword(&token))
return -1;
1561 state = ST_KEYWORD_LINE_PARAM;
1563 state = ST_DATA_LINE1;
1567 }
else if (state == ST_KEYWORD_LINE_PARAM) {
1581 state = flag_input ? ST_DATA_INCLUDE : ST_DATA_LINE1;
1586 }
else if (state == ST_DATA_INCLUDE) {
1589 state = ST_DATA_LINE1;
1590 }
else if (state == ST_DATA_LINE1) {
1591 if (read_equation_data_line1(&neq))
return -1;
1593 state = ST_DATA_LINE2;
1594 }
else if (state == ST_DATA_LINE2) {
1596 if (read_equation_data_line2(neq))
return -1;
1600 state = ST_DATA_LINE1;
1602 state = ST_FINISHED;
1614 static int read_heading(
void) {
1636 "TITLE required after *HEADING");
1644 while (*p && *p ==
' ') p++;
1645 if (p ==
NULL) p =
"";
1646 snprintf(
header->header,
sizeof(
header->header),
"%s", p);
1664 static int read_include(
void) {
1695 "NL required after INPUT value");
1707 static int read_initial_keyword(
void) {
1726 static int read_initial_param_type(
int *type) {
1743 static int read_initial_data(
int type) {
1775 "Node ID or NGROUP name required");
1816 static int read_initial(
void) {
1824 ST_KEYWORD_LINE_PARAM,
1829 state = ST_KEYWORD_LINE;
1830 while (state != ST_FINISHED) {
1831 if (state == ST_KEYWORD_LINE) {
1832 if (read_initial_keyword())
return -1;
1833 state = ST_KEYWORD_LINE_PARAM;
1834 }
else if (state == ST_KEYWORD_LINE_PARAM) {
1838 if (read_initial_param_type(&type))
return -1;
1853 state = ST_DATA_INCLUDE;
1855 state = ST_DATA_LINE;
1862 }
else if (token ==
',') {
1868 }
else if (state == ST_DATA_INCLUDE) {
1872 state = ST_DATA_LINE;
1873 }
else if (state == ST_DATA_LINE) {
1875 if (read_initial_data(type))
return -1;
1879 state = ST_FINISHED;
1891 static int read_conductivity_keyword(
int *last_token) {
1904 "',' or NL required after *CONDUCTIVITY");
1907 *last_token = token;
1912 static int read_conductivity_param_dependencies(
int *dependencies) {
1916 static int read_conductivity_param_type(
int *type) {
1939 static int read_conductivity_data(
int type,
int dependencies,
1940 struct hecmw_io_matitem **matitem) {
1958 return read_mat_data_common(n + dependencies, 8, temp_col, matitem,
1962 static int read_conductivity(
void) {
1964 int dependencies = 0;
1966 enum { ST_FINISHED, ST_KEYWORD_LINE, ST_KEYWORD_LINE_PARAM, ST_DATA_LINE };
1968 state = ST_KEYWORD_LINE;
1969 while (state != ST_FINISHED) {
1970 if (state == ST_KEYWORD_LINE) {
1971 if (read_conductivity_keyword(&token))
return -1;
1973 state = ST_KEYWORD_LINE_PARAM;
1975 state = ST_DATA_LINE;
1979 }
else if (state == ST_KEYWORD_LINE_PARAM) {
1982 if (read_conductivity_param_dependencies(&dependencies))
return -1;
1984 if (read_conductivity_param_type(&type))
return -1;
1995 state = ST_DATA_LINE;
1997 }
else if (state == ST_DATA_LINE) {
1998 struct hecmw_io_matitem *item;
1999 if (read_conductivity_data(type, dependencies, &item))
return -1;
2001 state = ST_FINISHED;
2011 static int read_density_keyword(
int *last_token) {
2024 "',' or NL required after *DENSITY");
2027 *last_token = token;
2032 static int read_density_param_dependencies(
int *dependencies) {
2036 static int read_density_data(
int dependencies,
2037 struct hecmw_io_matitem **matitem) {
2038 return read_mat_data_common(2 + dependencies, 8, 2, matitem,
2042 static int read_density(
void) {
2044 int dependencies = 0;
2045 enum { ST_FINISHED, ST_KEYWORD_LINE, ST_KEYWORD_LINE_PARAM, ST_DATA_LINE };
2047 state = ST_KEYWORD_LINE;
2048 while (state != ST_FINISHED) {
2049 if (state == ST_KEYWORD_LINE) {
2050 if (read_density_keyword(&token))
return -1;
2052 state = ST_KEYWORD_LINE_PARAM;
2054 state = ST_DATA_LINE;
2058 }
else if (state == ST_KEYWORD_LINE_PARAM) {
2061 if (read_density_param_dependencies(&dependencies))
return -1;
2071 state = ST_DATA_LINE;
2072 }
else if (state == ST_DATA_LINE) {
2073 struct hecmw_io_matitem *item;
2074 if (read_density_data(dependencies, &item))
return -1;
2076 state = ST_FINISHED;
2086 static int read_elastic_keyword(
int *last_token) {
2099 "',' or NL required after *ELASTIC");
2102 *last_token = token;
2107 static int read_elastic_param_dependencies(
int *dependencies) {
2111 static int read_elastic_param_type(
int *type) {
2136 static int read_elastic_param_moduli(
int *moduli) {
2157 static int read_elastic_data(
int type,
int dependencies,
2158 struct hecmw_io_matitem **matitem) {
2180 return read_mat_data_common(n + dependencies, 8, temp_col, matitem,
2184 static int read_elastic(
void) {
2186 int dependencies = 0;
2189 enum { ST_FINISHED, ST_KEYWORD_LINE, ST_KEYWORD_LINE_PARAM, ST_DATA_LINE };
2191 state = ST_KEYWORD_LINE;
2192 while (state != ST_FINISHED) {
2193 if (state == ST_KEYWORD_LINE) {
2194 if (read_elastic_keyword(&token))
return -1;
2196 state = ST_KEYWORD_LINE_PARAM;
2198 state = ST_DATA_LINE;
2202 }
else if (state == ST_KEYWORD_LINE_PARAM) {
2205 if (read_elastic_param_dependencies(&dependencies))
return -1;
2207 if (read_elastic_param_type(&type))
return -1;
2209 if (read_elastic_param_moduli(&moduli))
return -1;
2220 state = ST_DATA_LINE;
2222 }
else if (state == ST_DATA_LINE) {
2223 struct hecmw_io_matitem *item;
2224 if (read_elastic_data(type, dependencies, &item))
return -1;
2226 state = ST_FINISHED;
2236 static int read_specific_keyword(
int *last_token) {
2249 "',' or NL required after *SPECIFIC HEAT");
2252 *last_token = token;
2257 static int read_specific_param_dependencies(
int *dependencies) {
2261 static int read_specific_data(
int dependencies,
2262 struct hecmw_io_matitem **matitem) {
2263 return read_mat_data_common(2 + dependencies, 8, 2, matitem,
2267 static int read_specific_heat(
void) {
2269 int dependencies = 0;
2270 enum { ST_FINISHED, ST_KEYWORD_LINE, ST_KEYWORD_LINE_PARAM, ST_DATA_LINE };
2272 state = ST_KEYWORD_LINE;
2273 while (state != ST_FINISHED) {
2274 if (state == ST_KEYWORD_LINE) {
2275 if (read_specific_keyword(&token))
return -1;
2277 state = ST_KEYWORD_LINE_PARAM;
2279 state = ST_DATA_LINE;
2283 }
else if (state == ST_KEYWORD_LINE_PARAM) {
2286 if (read_specific_param_dependencies(&dependencies))
return -1;
2296 state = ST_DATA_LINE;
2297 }
else if (state == ST_DATA_LINE) {
2298 struct hecmw_io_matitem *item;
2299 if (read_specific_data(dependencies, &item))
return -1;
2301 state = ST_FINISHED;
2311 static int read_material_param_name(
char *name,
size_t name_len) {
2323 "NAME must begin with a letter");
2331 snprintf(name, name_len,
"%s", p);
2344 static int read_material(
void) {
2367 if (read_material_param_name(name,
sizeof(name)))
return -1;
2375 snprintf(matname,
sizeof(matname),
"%s", name);
2385 fprintf(stderr,
"*NCOPY has not implemented yet\n");
2396 fprintf(stderr,
"*NFILL has not implemented yet\n");
2407 fprintf(stderr,
"*NGEN has not implemented yet\n");
2415 static int read_nset_keyword(
void) {
2433 static int read_nset_param_nset(
char *nset,
size_t nset_len,
int *isAll) {
2445 "NSET must begin with a letter");
2453 snprintf(nset, nset_len,
"%s", p);
2459 if (strcmp(nset,
"EQUATION_BLOCK") == 0) {
2463 if (strcmp(nset,
"ALL") == 0) {
2465 snprintf(nset, nset_len,
"INP_NSET_ALL");
2472 static int read_nset_param_instance() {
2483 "NSET must begin with a letter");
2489 static int read_nset_data(
int *nnode,
int **node_array) {
2490 int i, n, *node, token;
2532 "',' or NL required after node ID");
2547 for (p = head; p; p = q) {
2558 for (p = head; p; p = q) {
2566 static int read_nset_data_generate(
int *nnode,
int **node_array) {
2567 int token, i, n,
id, *node, nod1, nod2, nod3;
2619 "NL required after increment");
2626 "',' or NL required after nod2");
2634 "Cannot generate between %d and %d with an increment of %d", nod1,
2638 if ((nod2 - nod1) % nod3) {
2640 "Cannot generate between %d and %d with an increment of %d", nod1,
2645 n = (nod2 - nod1) / nod3 + 1;
2653 for (
id = nod1;
id <= nod2;
id += nod3) {
2664 static int read_nset(
void) {
2667 int flag_generate = 0;
2673 ST_KEYWORD_LINE_PARAM,
2675 ST_DATA_LINE_GENERATE
2678 state = ST_KEYWORD_LINE;
2679 while (state != ST_FINISHED) {
2680 if (state == ST_KEYWORD_LINE) {
2681 if (read_nset_keyword())
return -1;
2682 state = ST_KEYWORD_LINE_PARAM;
2683 }
else if (state == ST_KEYWORD_LINE_PARAM) {
2687 if (read_nset_param_nset(nset,
sizeof(nset), &isAll))
return -1;
2696 read_nset_param_instance();
2710 if (flag_generate) {
2711 state = ST_DATA_LINE_GENERATE;
2713 state = ST_DATA_LINE;
2715 }
else if (token ==
',') {
2721 }
else if (state == ST_DATA_LINE) {
2725 if (read_nset_data(&n, &node))
return -1;
2734 state = ST_FINISHED;
2736 state = ST_DATA_LINE;
2739 }
else if (state == ST_DATA_LINE_GENERATE) {
2745 if (read_nset_data_generate(&n, &node))
return -1;
2754 state = ST_FINISHED;
2766 static int read_node_keyword(
int *token) {
2777 "',' or NL required after *NODE");
2783 static int read_node_param_system(
int *system) {
2792 if (token !=
'C' && token !=
'R') {
2800 static int read_node_param_nset(
char *nset,
size_t nset_len,
int *isAll) {
2812 "NSET must begin with a letter");
2820 snprintf(nset, nset_len,
"%s", p);
2826 if (strcmp(nset,
"ALL") == 0) {
2828 snprintf(nset, nset_len,
"INP_ESET_ALL");
2835 static int read_node_data(
int *
id,
double *x,
double *y,
double *z) {
2929 static int read_node_data_system(
int system,
double *x,
double *y,
double *z) {
2938 if (system ==
'C') {
2957 static int read_node(
void) {
2967 ST_KEYWORD_LINE_PARAM,
2972 state = ST_KEYWORD_LINE;
2973 while (state != ST_FINISHED) {
2974 if (state == ST_KEYWORD_LINE) {
2975 if (read_node_keyword(&token))
return -1;
2977 state = ST_DATA_LINE;
2978 }
else if (token ==
',') {
2979 state = ST_KEYWORD_LINE_PARAM;
2983 }
else if (state == ST_KEYWORD_LINE_PARAM) {
2987 if (read_node_param_system(&system))
return -1;
2990 if (read_node_param_nset(nset,
sizeof(nset), &isAll))
return -1;
3006 state = flag_input ? ST_DATA_INCLUDE : ST_DATA_LINE;
3007 }
else if (token ==
',') {
3013 }
else if (state == ST_DATA_INCLUDE) {
3016 state = ST_DATA_LINE;
3017 }
else if (state == ST_DATA_LINE) {
3021 if (read_node_data(&
id, &
x, &
y, &
z))
return -1;
3026 state = ST_FINISHED;
3028 state = ST_DATA_LINE;
3033 if (read_node_data_system(system, &
x, &
y, &
z))
return -1;
3052 static int read_shellsect_keyword(
void) {
3065 "',' required after *SHELL SECTION");
3071 static int read_shellsect_param_elset(
char *elset,
size_t elset_len) {
3083 "ELSET must begin with a letter");
3091 snprintf(elset, elset_len,
"%s", p);
3100 static int read_shellsect_param_material(
char *material,
size_t material_len) {
3112 "MATERIAL must begin with a letter");
3120 snprintf(material, material_len,
"%s", p);
3129 static int read_shellsect_data(
double *thickness,
int *integpoints) {
3143 if (*thickness <= 0.0) {
3166 if (*integpoints <= 0) {
3175 "NL required after INTEGPOINTS");
3182 static int read_shell_section(
void) {
3186 int flag_material = 0;
3187 int flag_composite = 0;
3190 enum { ST_FINISHED, ST_KEYWORD_LINE, ST_KEYWORD_LINE_PARAM, ST_DATA_LINE };
3192 state = ST_KEYWORD_LINE;
3193 while (state != ST_FINISHED) {
3194 if (state == ST_KEYWORD_LINE) {
3195 if (read_shellsect_keyword())
return -1;
3196 state = ST_KEYWORD_LINE_PARAM;
3197 }
else if (state == ST_KEYWORD_LINE_PARAM) {
3201 if (read_shellsect_param_elset(elset,
sizeof(elset)))
return -1;
3205 if (flag_composite) {
3209 if (read_shellsect_param_material(material,
sizeof(material)))
return -1;
3224 if (!flag_material) {
3229 state = ST_DATA_LINE;
3230 }
else if (token ==
',') {
3236 }
else if (state == ST_DATA_LINE) {
3240 union hecmw_io_section_item sect_item;
3244 if (read_shellsect_data(&thickness, &integpoints))
return -1;
3247 sect_item.shell.thickness = thickness;
3248 sect_item.shell.integpoints = integpoints;
3249 snprintf(sect.egrp,
sizeof(sect.egrp),
"%s", elset);
3250 snprintf(sect.material,
sizeof(sect.material),
"%s", material);
3251 sect.composite = composite;
3254 sect.sect = sect_item;
3261 state = ST_FINISHED;
3271 static int read_solidsect_keyword(
void) {
3284 "',' required after *SOLID SECTION");
3290 static int read_solidsect_param_elset(
char *elset,
size_t elset_len) {
3302 "ELSET must begin with a letter");
3310 snprintf(elset, elset_len,
"%s", p);
3319 static int read_solidsect_param_material(
char *material,
size_t material_len) {
3331 "MATERIAL must begin with a letter");
3339 snprintf(material, material_len,
"%s", p);
3348 static int read_solidsect_param_orientation(
char *orientation,
size_t orientation_len) {
3355 "'=' reuqired after ORIENTATION");
3361 "ORIENTATION must begin with a letter");
3369 snprintf(orientation, orientation_len,
"%s", p);
3378 static int read_solidsect_data(
double *thickness) {
3401 if (*thickness <= 0.0) {
3409 static int read_solid_section(
void) {
3413 int flag_material = 0;
3414 int flag_composite = 0;
3418 enum { ST_FINISHED, ST_KEYWORD_LINE, ST_KEYWORD_LINE_PARAM, ST_DATA_LINE };
3420 state = ST_KEYWORD_LINE;
3421 while (state != ST_FINISHED) {
3422 if (state == ST_KEYWORD_LINE) {
3423 if (read_solidsect_keyword())
return -1;
3424 state = ST_KEYWORD_LINE_PARAM;
3425 }
else if (state == ST_KEYWORD_LINE_PARAM) {
3429 if (read_solidsect_param_elset(elset,
sizeof(elset)))
return -1;
3433 if (flag_composite) {
3437 if (read_solidsect_param_material(material,
sizeof(material)))
return -1;
3440 if (read_solidsect_param_orientation(orientation,
sizeof(orientation)))
return -1;
3454 if (!flag_material) {
3459 state = ST_DATA_LINE;
3460 }
else if (token ==
',') {
3466 }
else if (state == ST_DATA_LINE) {
3470 union hecmw_io_section_item sect_item;
3474 if (read_solidsect_data(&thickness))
return -1;
3478 set_err_noloc(
HECMW_IO_E1026,
"Two or more secopt found in %s", elset);
3483 sect_item.solid.thickness = thickness;
3484 snprintf(sect.egrp,
sizeof(sect.egrp),
"%s", elset);
3485 snprintf(sect.material,
sizeof(sect.material),
"%s", material);
3486 sect.composite = composite;
3487 sect.secopt = secopt;
3489 sect.sect = sect_item;
3496 state = ST_FINISHED;
3507 read_system_keyword(
void)
3537 }
else if(token ==
',') {
3556 }
else if(token ==
',') {
3589 *last_token = token;
3603 }
else if(token ==
',') {
3622 }
else if(token ==
',') {
3669 }
else if(token ==
',') {
3688 }
else if(token ==
',') {
3738 fprintf(stderr,
"*SYSTEM has not implemented yet\n");
3742 if(system ==
NULL) {
3758 state = ST_KEYWORD_LINE;
3759 while(state != ST_FINISHED) {
3760 if(state == ST_KEYWORD_LINE) {
3761 if(read_system_keyword())
return -1;
3768 state = ST_FINISHED;
3770 state = ST_DATA_LINE1;
3773 }
else if(state == ST_DATA_LINE1) {
3774 if(read_system_data_line1a(system, &token))
return -1;
3776 state = ST_FINISHED;
3781 if(read_system_data_line1b(system))
return -1;
3784 state = ST_FINISHED;
3786 state = ST_DATA_LINE2;
3789 }
else if(state == ST_DATA_LINE2) {
3790 if(read_system_data_line2(system))
return -1;
3791 state = ST_FINISHED;
3805 static int read_boundary_keyword(
void) {
3818 "',' is not required after *BOUNDARY SECTION");
3823 "Auto-generated cards should be added in !BOUNDARY section of *.cnt "
3830 static int read_boundary_data(
int *nnode,
int **node_array) {
3831 int i, n, *node, token;
3832 int isSuggest, isNode;
3861 fprintf(stderr,
"%s", c);
3865 fprintf(stderr,
", %d", i);
3869 fprintf(stderr,
", %f", a);
3898 "',' or NL required after node ID");
3910 for (p = head; p; p = q) {
3921 if (isSuggest == 1) {
3922 fprintf(stderr,
"\n");
3928 for (p = head; p; p = q) {
3936 static int read_boundary(
void) {
3938 int flag_boundary = 0;
3939 int isNodeInput = 0;
3940 static int nbound = 0;
3942 enum { ST_FINISHED, ST_KEYWORD_LINE, ST_KEYWORD_LINE_PARAM, ST_DATA_LINE };
3944 state = ST_KEYWORD_LINE;
3945 while (state != ST_FINISHED) {
3946 if (state == ST_KEYWORD_LINE) {
3947 if (read_boundary_keyword())
return -1;
3948 state = ST_DATA_LINE;
3950 }
else if (state == ST_KEYWORD_LINE_PARAM) {
3952 }
else if (state == ST_DATA_LINE) {
3957 if (read_boundary_data(&n, &node))
return -1;
3963 snprintf(nset,
sizeof(nset),
"BND%d", nbound);
3971 state = ST_FINISHED;
3973 state = ST_DATA_LINE;
3981 if (isNodeInput == 1) {
3982 fprintf(stderr,
"NGRP=BND%d\n", nbound);
3990 static int read_cload_keyword(
void) {
4002 "',' is not required after *CLOAD SECTION");
4006 "Auto-generated cards should be added in !CLOAD section of *.cnt "
4011 static int read_cload(
void) {
4015 static int ncload = 0;
4017 enum { ST_FINISHED, ST_KEYWORD_LINE, ST_KEYWORD_LINE_PARAM, ST_DATA_LINE };
4019 state = ST_KEYWORD_LINE;
4020 while (state != ST_FINISHED) {
4021 if (state == ST_KEYWORD_LINE) {
4022 if (read_cload_keyword())
return -1;
4023 state = ST_DATA_LINE;
4025 }
else if (state == ST_KEYWORD_LINE_PARAM) {
4027 }
else if (state == ST_DATA_LINE) {
4031 if (read_boundary_data(&n, &node))
return -1;
4037 snprintf(nset,
sizeof(nset),
"CLOAD%d", ncload);
4045 state = ST_FINISHED;
4047 state = ST_DATA_LINE;
4056 fprintf(stderr,
"NGRP=CLOAD%d\n", ncload);
4064 static int read_dload_keyword(
void) {
4076 "',' is not required after *DLOAD SECTION");
4080 "Auto-generated cards should be added in !DLOAD section of *.cnt "
4085 static int read_dload(
void) {
4089 static int ndload = 0;
4091 enum { ST_FINISHED, ST_KEYWORD_LINE, ST_KEYWORD_LINE_PARAM, ST_DATA_LINE };
4093 state = ST_KEYWORD_LINE;
4094 while (state != ST_FINISHED) {
4095 if (state == ST_KEYWORD_LINE) {
4096 if (read_dload_keyword())
return -1;
4097 state = ST_DATA_LINE;
4099 }
else if (state == ST_KEYWORD_LINE_PARAM) {
4101 }
else if (state == ST_DATA_LINE) {
4105 if (read_boundary_data(&n, &elem))
return -1;
4110 snprintf(elset,
sizeof(elset),
"DLOAD%d", ndload);
4118 state = ST_FINISHED;
4120 state = ST_DATA_LINE;
4129 fprintf(stderr,
"NGRP=DLOAD%d is automatically generated\n", ndload);
4142 static struct read_func_table {
4145 } read_func_table[] = {
4173 #define N_READ_FUNC (sizeof(read_func_table) / sizeof(read_func_table[0]))
4176 static ReadFunc get_read_func(
int token) {
4180 if (token == read_func_table[i].token) {
4181 return read_func_table[i].func;
4187 static int parse(
void) {
4194 func = get_read_func(token);
4208 if (p[0] ==
'*')
break;
4214 if (is_material_keyword(token) && !is_material_zone()) {
4218 if (!is_material_keyword(token) && is_material_zone()) {
4219 if (regist_material())
return -1;
4220 set_material_zone(0);
4223 if ((*func)())
return -1;
4225 set_material_zone(1);
4228 if (is_material_zone()) {
4229 if (regist_material())
return -1;
4230 set_material_zone(0);
4237 static int post_inp(
void) {
4249 if (filename ==
NULL) {
4251 "Not specified filename for INP mesh input routine");
4261 snprintf(grid_filename,
sizeof(grid_filename),
"%s", filename);
4264 if ((fp = fopen(filename,
"r")) ==
NULL) {
4287 snprintf(grid_filename,
sizeof(grid_filename),
"Unknown");
4300 if (local_mesh ==
NULL)
return NULL;
4303 snprintf(grid_filename,
sizeof(grid_filename),
"Unknown");
HECMW_Comm HECMW_comm_get_comm(void)
#define HECMW_MAX_NODE_MAX
#define HECMW_FILENAME_LEN
int HECMW_convert_connectivity(int from, int hecmw_etype, int *conn)
#define HECMW_CONNTYPE_INP
int HECMW_set_error(int errorno, const char *fmt,...)
int HECMW_get_max_node(int etype)
int HECMW_cylindrical_to_cartesian(const struct hecmw_coord *coord, struct hecmw_coord *result)
double HECMW_degree_to_radian(double deg)
int HECMW_inplex_unput_token(void)
int HECMW_inplex_next_token(void)
double HECMW_inplex_get_number(void)
int HECMW_inplex_set_input(FILE *fp)
char * HECMW_inplex_get_text(void)
@ HECMW_INPLEX_H_SOLID_SECTION
@ HECMW_INPLEX_K_ANISOTROPIC
@ HECMW_INPLEX_K_ORTHOTROPIC
@ HECMW_INPLEX_K_DEFINITION
@ HECMW_INPLEX_H_MATERIAL
@ HECMW_INPLEX_H_AMPLITUDE
@ HECMW_INPLEX_K_UNSORTED
@ HECMW_INPLEX_K_GENERATE
@ HECMW_INPLEX_K_INSTANTANEOUS
@ HECMW_INPLEX_H_BOUNDARY
@ HECMW_INPLEX_K_RELATIVE
@ HECMW_INPLEX_H_EQUATION
@ HECMW_INPLEX_K_ABSOLUTE
@ HECMW_INPLEX_K_ISOTROPIC
@ HECMW_INPLEX_H_CONDUCTIVITY
@ HECMW_INPLEX_K_TEMPERATURE
@ HECMW_INPLEX_K_ORIENTATION
@ HECMW_INPLEX_K_MATERIAL
@ HECMW_INPLEX_H_SHELL_SECTION
@ HECMW_INPLEX_K_ENGINEERING_CONSTANTS
@ HECMW_INPLEX_K_DEPENDENCIES
@ HECMW_INPLEX_K_INSTANCE
@ HECMW_INPLEX_H_SPECIFIC_HEAT
@ HECMW_INPLEX_K_STEP_TIME
int HECMW_inplex_get_lineno(void)
int HECMW_inplex_is_including(void)
int HECMW_inplex_switch_to_include(const char *filename)
struct hecmwST_local_mesh * HECMW_get_inp_mesh(const char *filename)
int HECMW_read_inp_mesh(const char *filename)
struct hecmw_io_mpc * HECMW_io_add_mpc(int neq, const struct hecmw_io_mpcitem *mpcitem, double cnst)
int HECMW_io_check_mpc_dof(int dof)
int HECMW_io_is_reserved_name(const char *name)
int HECMW_io_add_ngrp(const char *name, int nnode, int *node)
struct hecmw_io_section * HECMW_io_add_sect(struct hecmw_io_section *sect)
struct hecmw_io_id_array * HECMW_io_get_elem_in_egrp(const char *name)
struct hecmw_io_amplitude * HECMW_io_add_amp(const char *name, int definition, int time, int value, double val, double t)
int HECMW_io_add_egrp(const char *name, int nelem, int *elem)
struct hecmw_io_initial * HECMW_io_add_initial(int type, int node, const char *ngrp, double val)
struct hecmw_io_material * HECMW_io_add_mat(const char *name, struct hecmw_io_material *mat)
struct hecmwST_local_mesh * HECMW_io_make_local_mesh(void)
struct hecmw_io_element * HECMW_io_add_elem(int id, int type, int *node, int nmatitem, double *matitem)
int HECMW_io_pre_process(void)
void HECMW_io_set_system(struct hecmw_system_param *system)
struct hecmw_io_node * HECMW_io_add_node(int id, double x, double y, double z)
int HECMW_io_post_process(void)
struct hecmw_io_material * HECMW_io_get_mat(const char *name)
int HECMW_io_set_gridfile(char *gridfile)
int HECMW_io_finalize(void)
struct hecmw_system_param * HECMW_io_get_system(void)
void HECMW_io_set_header(struct hecmw_io_header *header)
#define HECMW_INITIAL_TYPE_TEMPERATURE
int HECMW_log(int loglv, const char *fmt,...)
#define HECMW_calloc(nmemb, size)
#define HECMW_malloc(size)
int HECMW_map_int_add(struct hecmw_map_int *map, int key, void *value)
void * HECMW_map_int_get(const struct hecmw_map_int *map, int key)
void HECMW_map_int_finalize(struct hecmw_map_int *map)
int HECMW_map_int_init(struct hecmw_map_int *map, void(*free_fnc)(void *))
#define HECMW_IO_INP_E0100
#define HECMW_IO_INP_E0703
#define HECMW_IO_INP_E0700
#define HECMW_IO_INP_E1100
#define HECMW_IO_INP_E2107
#define HECMW_IO_INP_E2103
#define HECMW_IO_INP_E0002
#define HECMW_IO_INP_E1703
#define HECMW_IO_INP_E0601
#define HECMW_IO_INP_E1702
#define HECMW_IO_INP_E1502
#define HECMW_IO_INP_E1705
#define HECMW_IO_INP_E1500
#define HECMW_IO_INP_E1101
#define HECMW_IO_INP_E1600
#define HECMW_IO_INP_E1001
#define HECMW_IO_INP_E0900
#define HECMW_IO_INP_E0600
#define HECMW_IO_INP_E1503
#define HECMW_IO_INP_E0603
#define HECMW_IO_INP_E1601
#define HECMW_IO_INP_E0901
#define HECMW_IO_INP_E1102
#define HECMW_IO_INP_E2200
#define HECMW_IO_INP_E1501
#define HECMW_IO_INP_E0003
#define HECMW_IO_INP_E0500
#define HECMW_IO_INP_E2500
#define HECMW_IO_INP_E0001
#define HECMW_IO_INP_E1700
#define HECMW_IO_INP_E0502
#define HECMW_IO_INP_E2400
#define HECMW_IO_INP_E2105
#define HECMW_IO_INP_E0501
#define HECMW_IO_INP_W0097
#define HECMW_IO_INP_E0702
#define HECMW_IO_INP_E2300
#define HECMW_IO_INP_E0098
#define HECMW_IO_INP_E0606
#define HECMW_IO_INP_W0099
#define HECMW_IO_INP_E1002
#define HECMW_IO_INP_E0503
#define HECMW_IO_INP_E1000
#define HECMW_IO_INP_E0101
#define HECMW_IO_INP_E2108
#define HECMW_IO_INP_E2100
#define HECMW_IO_INP_E0096
#define HECMW_IO_INP_E2102
#define HECMW_IO_INP_W0095
#define HECMW_IO_INP_E0800
#define HECMW_IO_INP_E1707
#define HECMW_IO_INP_E0604
#define HECMW_IO_INP_E1706
#define HECMW_IO_INP_E0701
#define HECMW_IO_INP_E1900
char * HECMW_dirname(const char *path)
int HECMW_get_path_separator(void)
int HECMW_is_absolute_path(const char *path)
#define HECMW_AMP_TYPEDEF_TABULAR
#define HECMW_SECT_TYPE_SOLID
#define HECMW_SECT_TYPE_SHELL
#define HECMW_AMP_TYPEVAL_RELATIVE
#define HECMW_AMP_TYPEVAL_ABSOLUTE
#define HECMW_AMP_TYPETIME_STEP
int HECMW_system(struct hecmw_system_param *param, struct hecmw_coord *coord, struct hecmw_coord *result)
void HECMW_abort(HECMW_Comm comm)
char * HECMW_toupper(char *s)
void HECMW_print_msg(int loglv, int msgno, const char *fmt,...)
int HECMW_vsnprintf(char *str, size_t size, const char *format, va_list ap)
#define HECMW_assert(cond)
Separator_result * separator
struct hecmw_io_id * next
struct hecmw_io_material::hecmw_io_matitem * item
char name[HECMW_NAME_LEN+1]
union hecmw_io_section::hecmw_io_section_item sect