26 #define HECMW_FLAG_VERSION 5
28 static int global_node_ID_max = -1;
29 static int global_elem_ID_max = -1;
51 static void do_logging(
int loglv,
int msgno,
const char *fmt, va_list ap) {
59 static void set_err(
int msgno,
const char *fmt, ...) {
67 static void set_warn(
int msgno,
const char *fmt, ...) {
77 static int get_gid2lid_node(
int gid) {
86 static int get_gid2lid_elem(
int gid) {
97 static int make_surf_key(
int elem_id,
int surf_id) {
100 return elem_id * 3 + surf_id - 1;
102 return -(elem_id * 3 + surf_id - 4);
106 static void decode_surf_key(
int key,
int *elem_id,
int *surf_id) {
111 *surf_id = key % 3 + 1;
113 *elem_id = (-key) / 3;
114 *surf_id = (-key) % 3 + 4;
118 static int clear(
void) {
121 snprintf(grid_filename,
sizeof(grid_filename),
"Unknown");
145 static void print_header(FILE *fp) {
148 fprintf(fp,
"HEADER:\n");
149 fprintf(fp,
"%s\n", _head ? _head->
header :
"none");
150 fprintf(fp,
"END of HEADER\n");
153 static void print_amp(FILE *fp) {
158 fprintf(fp,
"AMPLITUDE:\n");
159 for (p = _amp; p; p = p->
next) {
160 struct hecmw_io_amplitude_item *item;
161 fprintf(fp,
"NAME: %s, DEFINITION: %d, TIME: %d, VALUE: %d\n", p->
name,
163 for (item = p->
item; item; item = item->
next) {
164 fprintf(fp,
"VAL: %E, T: %E\n", item->val, item->table);
167 fprintf(fp,
"END of AMPLITUDE\n");
170 static void print_init(FILE *fp) {
175 fprintf(fp,
"INITIAL CONDITION:\n");
176 for (p = _init; p; p = p->
next) {
177 fprintf(fp,
"TYPE: %d, NODE: %d, NGRP: %s, VAL: %E\n", p->
type, p->
node,
180 fprintf(fp,
"END of INITIAL CONDITION\n");
183 static void print_node(FILE *fp) {
190 fprintf(fp,
"NODE:\n");
195 fprintf(fp,
"Node %d: ID=%d: %E %E %E\n", seq++,
id, p->x, p->y, p->z);
197 fprintf(fp,
"END of NODE\n");
200 static void print_elem(FILE *fp) {
207 fprintf(fp,
"ELEMENT:\n");
212 fprintf(fp,
"Element %d: ID=%d: TYPE=%d: ", seq++,
id, p->type);
214 for (j = 0; j < n; j++) {
215 fprintf(fp,
"%d ", p->node[j]);
217 fprintf(fp,
": MATITEM: ");
218 if (p->nmatitem == 0) {
221 for (j = 0; j < p->nmatitem; j++) {
222 fprintf(fp,
"%E ", p->matitem[j]);
228 fprintf(fp,
"END of ELEMENT\n");
231 static void print_ngrp(FILE *fp) {
233 const int NITEM = 10;
238 fprintf(fp,
"NGROUP:\n");
239 for (p = _ngrp; p; p = p->
next) {
241 fprintf(fp,
"NAME=%s:\n", p->
name);
244 fprintf(fp,
"%d %c",
id, (i + 1) % NITEM ?
' ' :
'\n');
250 fprintf(fp,
"END of NGROUP\n");
253 static void print_egrp(FILE *fp) {
255 const int NITEM = 10;
260 fprintf(fp,
"EGROUP:\n");
261 for (p = _egrp; p; p = p->
next) {
263 fprintf(fp,
"NAME=%s:\n", p->
name);
266 fprintf(fp,
"%d %c",
id, (i + 1) % NITEM ?
' ' :
'\n');
272 fprintf(fp,
"END of EGROUP\n");
275 static void print_sgrp(FILE *fp) {
277 const int NITEM = 10;
282 fprintf(fp,
"SGROUP:\n");
283 for (p = _sgrp; p; p = p->
next) {
285 fprintf(fp,
"NAME=%s:\n", p->
name);
288 decode_surf_key(
id, &eid, &sid);
289 fprintf(fp,
"%d %d %c", eid, sid, (i + 1) % NITEM ?
' ' :
'\n');
295 fprintf(fp,
"END of SGROUP\n");
298 static void print_sect(FILE *fp) {
303 fprintf(fp,
"SECTION:\n");
304 for (p = _sect; p; p = p->
next) {
305 fprintf(fp,
"EGRP: %s, MATERIAL: %s, COMPOSITE: %d, SECOPT: %d\n", p->
egrp,
310 fprintf(fp,
"TYPE: SHELL, THICKNESS: %E, INTEGPOINTS: %d\n",
313 fprintf(fp,
"TYPE: BEAM, Reference vector: %E %E %E, Iyy: %E\n",
318 "TYPE: INTERFACE, THICKNESS: %E, "
319 "GAPCON: %E, GAPRAD1: %E, GAPRAD2: %E\n",
324 fprintf(fp,
"END of SECTION\n");
327 static void print_mat(FILE *fp) {
333 fprintf(fp,
"MATERIAL:\n");
334 for (p = _mat; p; p = p->
next) {
335 fprintf(fp,
"NAME: %s\n", p->
name);
336 for (i = 0; i < p->
nitem; i++) {
337 struct hecmw_io_matitem *item = &p->
item[i];
338 struct hecmw_io_matsubitem *p;
339 fprintf(fp,
"ITEM=%d, SUBITEM=%d:\n", item->item, item->nval);
340 for (p = item->subitem; p; p = p->next) {
341 fprintf(fp,
"VAL: ");
342 for (j = 0; j < item->nval; j++) {
343 fprintf(fp,
"%E ", p->val[j]);
345 fprintf(fp,
"TEMP: %E\n", p->temp);
349 fprintf(fp,
"END of MATERIAL\n");
352 static void print_mpc(FILE *fp) {
358 fprintf(fp,
"EQUATION:\n");
359 for (p = _mpc; p; p = p->
next) {
360 fprintf(fp,
"NEQ: %d\n", p->
neq);
361 for (i = 0; i < p->
neq; i++) {
362 struct hecmw_io_mpcitem *item = &p->
item[i];
363 fprintf(fp,
"ngrp: %s, nod: %d, DOF: %d, A: %E\n",
364 (item->node == -1) ? item->ngrp :
"(none)", item->node, item->dof,
368 fprintf(fp,
"END of EQUATION\n");
371 static void print_system(FILE *fp) {
379 memset(¶m, 0,
sizeof(param));
382 fprintf(fp,
"SYSTEM:\n");
383 fprintf(fp,
"%E %E %E\n", param.xa, param.ya, param.za);
384 fprintf(fp,
"%E %E %E\n", param.xb, param.yb, param.zb);
385 fprintf(fp,
"%E %E %E\n", param.xc, param.yc, param.zc);
386 fprintf(fp,
"END of SYSTEM\n");
389 static void print_zero(FILE *fp) {
392 fprintf(fp,
"ZERO:\n");
393 fprintf(fp,
"%E\n", _zero ? _zero->
zero : 0.0);
394 fprintf(fp,
"END of ZERO\n");
397 static void print_contact(FILE *fp) {
403 fprintf(fp,
"CONTACT PAIR:\n");
404 for (p = _contact; p; p = p->
next) {
405 fprintf(fp,
"NAME=%s, ", p->
name);
407 fprintf(fp,
"TYPE=NODE-SURF, ");
409 fprintf(fp,
"TYPE=SURF-SURF, ");
411 fprintf(fp,
"TYPE=NODE-ELEM, ");
415 fprintf(fp,
"END of CONTACT PAIR\n");
456 if (header ==
NULL)
return 0;
463 if (zero ==
NULL)
return 0;
470 if (node ==
NULL)
return 0;
478 if (elem ==
NULL)
return 0;
488 for (p = ngrp; p; p = q) {
500 for (p = egrp; p; p = q) {
512 for (p = sgrp; p; p = q) {
524 for (p = mpc; p; p = q) {
534 struct hecmw_io_amplitude_item *pp, *qq;
536 for (p = amp; p; p = q) {
538 for (pp = p->
item; pp; pp = qq) {
550 for (p = init; p; p = q) {
560 struct hecmw_io_matsubitem *pp, *qq;
562 for (p = mat; p; p = q) {
564 for (i = 0; i < p->
nitem; i++) {
580 for (p =
sect; p; p = q) {
588 if (system ==
NULL)
return 0;
597 for (p = contact; p; p = q) {
605 if (free_header(_head))
return -1;
606 if (free_zero(_zero))
return -1;
607 if (free_node(_node))
return -1;
608 if (free_elem(_elem))
return -1;
609 if (free_ngrp(_ngrp))
return -1;
610 if (free_egrp(_egrp))
return -1;
611 if (free_sgrp(_sgrp))
return -1;
612 if (free_mpc(_mpc))
return -1;
613 if (free_amp(_amp))
return -1;
614 if (free_init(_init))
return -1;
615 if (free_material(_mat))
return -1;
616 if (free_sect(_sect))
return -1;
617 if (free_system(_system))
return -1;
618 if (free_contact(_contact))
return -1;
625 if (gridfile ==
NULL) gridfile =
"";
626 snprintf(grid_filename,
sizeof(grid_filename),
"%s", gridfile);
631 int time,
int value,
double val,
635 struct hecmw_io_amplitude_item *item;
646 if (prev_amp !=
NULL && strcmp(prev_amp->
name, name) == 0) {
654 snprintf(p->
name,
sizeof(p->
name),
"%s", name);
659 if (prev_amp ==
NULL) {
693 for (p = _init; p; p = p->
next) {
700 const char *
ngrp,
double val) {
723 if (prev_init ==
NULL) {
760 static void free_io_elem(
void *io_elem) {
790 if (new_node ==
NULL) {
794 memcpy(new_node,
node,
sizeof(*new_node) * nnode);
800 if (new_matitem ==
NULL) {
808 if (new_elem ==
NULL) {
813 new_elem->
node = new_node;
815 new_elem->
matitem = new_matitem;
836 if (
id > global_elem_ID_max) {
837 global_elem_ID_max = id;
855 if (egrp ==
NULL)
goto error;
943 for (i = 0; i < nelem; i++) {
960 printf(
"HECMW HASH TABLE PUT ERROR\n");
986 static void free_io_node(
void *io_node) {
997 if (new_node ==
NULL) {
1005 if (_node ==
NULL) {
1007 if (_node ==
NULL) {
1022 if (
id > global_node_ID_max) {
1023 global_node_ID_max = id;
1037 for (p = _ngrp; p; p = p->
next) {
1038 if (strcmp(p->
name,
name) == 0)
break;
1040 if (p ==
NULL)
return 0;
1152 if (prev_ngrp ==
NULL) {
1155 prev_ngrp->
next = p;
1160 for (i = 0; i < nnode; i++) {
1176 printf(
"HECMW HASH TABLE PUT ERROR\n");
1190 static int HECMW_io_remove_node_in_ngrp(
int node) {
1194 for (p = _ngrp; p; p =
next) {
1278 if (prev_sgrp ==
NULL) {
1281 prev_sgrp->
next = p;
1286 for (i = 0; i < n_item; i++) {
1302 printf(
"HECMW HASH TABLE PUT ERROR\n");
1317 const struct hecmw_io_mpcitem *mpcitem,
1322 struct hecmw_io_mpcitem *item;
1328 if (mpcitem ==
NULL) {
1345 for (i = 0; i < neq; i++) {
1346 const struct hecmw_io_mpcitem *src = &mpcitem[i];
1347 struct hecmw_io_mpcitem *dst = &item[i];
1348 HECMW_assert((src->node == -1) ? (strlen(src->ngrp) > 0) : 1);
1351 snprintf(dst->ngrp,
sizeof(dst->ngrp),
"%s", src->ngrp);
1352 dst->node = src->node;
1353 dst->dof = src->dof;
1362 if (prev_mpc ==
NULL) {
1390 if (prev_sect ==
NULL) {
1393 prev_sect->
next = p;
1432 printf(
"HECMW HASH TABLE PUT ERROR\n");
1435 if (prev_mat ==
NULL) {
1438 prev_mat->
next = mat;
1448 if (header ==
NULL) {
1505 if (prev_contact ==
NULL) {
1508 prev_contact->
next = p;
1554 p = _head ? _head->
header :
"";
1568 "!ZERO is not defined; using %E as absolute zero, assuming "
1569 "input temperatures are in Celsius. Define !ZERO as 0.0 if "
1570 "they are in Kelvin\n",
1590 for (p = _init; p; p = p->
next) {
1610 for (p = _init; p; p = p->
next) {
1611 int lid = get_gid2lid_node(p->
node);
1629 for (p = _init; p; p = p->
next) {
1630 int lid = get_gid2lid_node(p->
node);
1836 for (j = 0; j < n; j++) {
1854 int i, j, nngrp, nnode;
1880 for (p = _ngrp; p; p = p->
next) {
1884 ngrp->
n_grp = nngrp;
1886 if (ngrp->
n_grp <= 0) {
1908 size =
sizeof(*ngrp->
grp_item) * nnode;
1917 for (i = 0, p = _ngrp; p; p = p->
next, i++) {
1924 ngrp->
grp_item[start + j] = get_gid2lid_node(nid);
1945 int i, j, negrp, nelem;
1970 for (p = _egrp; p; p = p->
next) {
1974 egrp->
n_grp = negrp;
1976 if (egrp->
n_grp <= 0) {
1998 size =
sizeof(*egrp->
grp_item) * nelem;
2007 for (i = 0, p = _egrp; p; p = p->
next, i++) {
2016 egrp->
grp_item[start + j] = get_gid2lid_elem(eid);
2038 int i, j, nsgrp, nelem;
2063 for (p = _sgrp; p; p = p->
next) {
2067 sgrp->
n_grp = nsgrp;
2069 if (sgrp->
n_grp <= 0) {
2091 size =
sizeof(*sgrp->
grp_item) * nelem * 2;
2100 for (i = 0, p = _sgrp; p; p = p->
next, i++) {
2107 decode_surf_key(
id, &eid, &sid);
2109 sgrp->
grp_item[start + j * 2] = get_gid2lid_elem(eid);
2110 sgrp->
grp_item[start + j * 2 + 1] = sid;
2130 int i, j, nmpc, nneq, start;
2158 for (p = _mpc; p; p = p->
next) {
2175 size =
sizeof(*mpc->
mpc_item) * nneq;
2183 size =
sizeof(*mpc->
mpc_dof) * nneq;
2191 size =
sizeof(*mpc->
mpc_val) * nneq;
2209 for (p = _mpc; p; p = p->
next) {
2214 for (j = 0; j < p->
neq; j++) {
2243 int i, j, namp, nitem, start;
2273 for (p = _amp; p; p = p->
next) {
2274 struct hecmw_io_amplitude_item *item;
2275 for (item = p->
item; item; item = item->
next) {
2325 size =
sizeof(*amp->
amp_val) * nitem;
2343 for (p = _amp; p; p = p->
next) {
2344 struct hecmw_io_amplitude_item *item;
2346 for (item = p->
item; item; item = item->
next) {
2353 for (item = p->
item, j = 0; item; item = item->
next, j++) {
2354 amp->
amp_val[start + j] = item->val;
2355 amp->
amp_table[start + j] = item->table;
2450 const char *egrp_name,
int sectid) {
2451 int i, eid, egid, start, end;
2467 for (i = start; i <= end; i++) {
2480 int i, nsect, nint, nreal, nmat;
2488 size =
sizeof(*sect);
2504 nsect = nint = nreal = nmat = 0;
2505 for (p = _sect; p; p = p->
next) {
2528 sect->n_sect = nsect;
2539 if (
sect->n_sect <= 0) {
2545 size =
sizeof(*
sect->sect_type) *
sect->n_sect;
2553 size =
sizeof(*
sect->sect_opt) *
sect->n_sect;
2561 size =
sizeof(*
sect->sect_mat_ID_index) * (
sect->n_sect + 1);
2563 if (
sect->sect_mat_ID_index ==
NULL) {
2570 size =
sizeof(*
sect->sect_mat_ID_item) * nmat;
2572 if (
sect->sect_mat_ID_item ==
NULL) {
2578 size =
sizeof(*
sect->sect_I_index) * (
sect->n_sect + 1);
2588 size =
sizeof(*
sect->sect_I_item) * nint;
2597 size =
sizeof(*
sect->sect_R_index) * (
sect->n_sect + 1);
2607 size =
sizeof(*
sect->sect_R_item) * nreal;
2616 sect->sect_I_index[0] = 0;
2617 sect->sect_R_index[0] = 0;
2618 sect->sect_mat_ID_index[0] = 0;
2619 for (i = 0, p = _sect; p; p = p->
next, i++) {
2620 int iidx =
sect->sect_I_index[i];
2621 int ridx =
sect->sect_R_index[i];
2624 sect->sect_I_index[i + 1] =
sect->sect_I_index[i] + 0;
2625 sect->sect_R_index[i + 1] =
sect->sect_R_index[i] + 1;
2629 sect->sect_I_index[i + 1] =
sect->sect_I_index[i] + 1;
2630 sect->sect_R_index[i + 1] =
sect->sect_R_index[i] + 1;
2636 sect->sect_I_index[i + 1] =
sect->sect_I_index[i] + 0;
2637 sect->sect_R_index[i + 1] =
sect->sect_R_index[i] + 7;
2647 sect->sect_I_index[i + 1] =
sect->sect_I_index[i] + 0;
2648 sect->sect_R_index[i + 1] =
sect->sect_R_index[i] + 4;
2659 sect->sect_mat_ID_index[i + 1] =
sect->sect_mat_ID_index[i] + 1;
2660 midx =
sect->sect_mat_ID_index[i];
2663 sect->sect_mat_ID_item[midx] =
2669 if (setup_sect_set_sectid(mesh, p->
egrp, i + 1))
return -1;
2703 int i, j, k, l, nmat,
nmatitem, nmatsubitem, nmattable;
2711 size =
sizeof(*mat);
2719 nmat = nmatitem = nmatsubitem = nmattable = 0;
2720 for (p = _mat; p; p = p->
next) {
2722 nmatitem += p->
nitem;
2723 for (i = 0; i < p->
nitem; i++) {
2724 struct hecmw_io_matsubitem *msi = p->
item[i].
subitem;
2743 if (mat->
n_mat <= 0) {
2781 size =
sizeof(*mat->
mat_val) * nmattable;
2789 size =
sizeof(*mat->
mat_temp) * nmattable;
2800 for (i = 0, p = _mat; p; p = p->
next, i++) {
2808 for (j = 0; j < p->
nitem; j++) {
2810 struct hecmw_io_matitem *item = &p->
item[j];
2811 struct hecmw_io_matsubitem *subitem = item->
subitem;
2816 for (subitem = item->subitem; subitem; subitem = subitem->next) {
2819 for (k = 0; k < item->nval; k++) {
2825 for (k = 0, subitem = item->subitem; subitem;
2826 subitem = subitem->next, k++) {
2827 for (l = 0; l < item->nval; l++) {
2833 mat->
mat_val[idx] = subitem->val[l];
2834 mat->
mat_temp[idx] = subitem->temp;
2850 int i, j, n, id, idx, *start, sectid, nmat, *matid;
2898 if (matid ==
NULL) {
2902 for (j = 0; j < n; j++) {
2903 matid[j] = start[j];
2905 mat[i].matid = matid;
2930 for (j = 0; j < mat[i].n; j++) {
2946 int i, npair, slave_gid, master_gid, orislave_sgid;
2956 if (cpair ==
NULL) {
2968 if (_contact ==
NULL) {
2975 for (p = _contact; p; p = p->
next) {
2982 size =
sizeof(*cpair->
name) * (cpair->
n_pair);
2990 size =
sizeof(*cpair->
type) * (cpair->
n_pair);
3022 for (p = _contact, i = 0; p; p = p->
next, i++) {
3091 static int post_remove_unused_node(
void) {
3101 if (HECMW_io_remove_node_in_ngrp(
id) < 0) {
3111 static int post_node(
void) {
3127 static int post_elem_check_node_existence(
void) {
3143 for (j = 0; j < ncon; j++) {
3157 static char *post_elem_make_matname(
int id,
char *buf,
int bufsize) {
3158 const char *
matname =
"HECMW-MAT";
3163 snprintf(buf, bufsize,
"%s%d",
matname,
id);
3168 static int post_elem_make_mat(
void) {
3173 struct hecmw_io_matitem *matitem;
3174 struct hecmw_io_matsubitem *matsubitem;
3187 if (matitem ==
NULL) {
3193 if (matsubitem ==
NULL) {
3199 if (matsubitem->val ==
NULL) {
3204 for (j = 0; j < p->
nmatitem; j++) {
3205 matsubitem->val[j] = p->
matitem[j];
3207 matsubitem->temp = 0.0;
3208 matsubitem->next =
NULL;
3212 matitem->subitem = matsubitem;
3215 mat->
item = matitem;
3216 post_elem_make_matname(
id, name,
sizeof(name));
3218 snprintf(mat->
name,
sizeof(mat->
name),
"%s", name);
3226 static int post_elem(
void) {
3229 if (_elem ==
NULL) {
3239 if (post_elem_check_node_existence())
return -1;
3241 if (post_elem_make_mat())
return -1;
3246 static int post_ngrp(
void) {
3249 for (p = _ngrp; p; p = p->
next) {
3266 static int post_egrp(
void) {
3269 for (p = _egrp; p; p = p->
next) {
3287 static int post_sgrp(
void) {
3290 for (p = _sgrp; p; p = p->
next) {
3302 decode_surf_key(
id, &eid, &sid);
3306 if (element ==
NULL) {
3322 static int post_initial_check_node_exists(
void) {
3326 if (_init ==
NULL)
return 0;
3330 for (p = _init; p; p =
next) {
3332 if (p->
node == -1) {
3364 static int post_initial_ngrp_to_node(
void) {
3365 int i, nnode, ignore, *
node;
3369 if (_init ==
NULL)
return 0;
3373 for (p = _init; p; p = next) {
3375 if (p->
node != -1) {
3411 for (i = 0; i < nnode; i++) {
3413 if (new_init ==
NULL) {
3417 memcpy(new_init, p,
sizeof(*new_init));
3419 new_init->
node = node[i];
3424 prev->
next = new_init;
3435 static int post_initial_check_dup(
void) {
3440 if (_init ==
NULL)
return 0;
3445 for (p = _init; p; p = p->
next) {
3453 set_err(
HECMW_IO_E1018,
"Some nodes are initialized more than once");
3459 static int post_initial(
void) {
3460 if (_init ==
NULL)
return 0;
3462 if (post_initial_check_node_exists())
return -1;
3464 if (post_initial_ngrp_to_node())
return -1;
3466 if (post_initial_check_dup())
return -1;
3472 static int post_equation_check_node_exists(
void) {
3476 if (_mpc ==
NULL)
return 0;
3480 for (p = _mpc; p; p =
next) {
3492 for (i = 0; i < p->
neq; i++) {
3493 struct hecmw_io_mpcitem *item = &p->
item[i];
3514 static int post_equation_ngrp_to_node(
void) {
3515 int i, j, ignore, **node;
3518 if (_mpc ==
NULL)
return 0;
3522 for (p = _mpc; p; p =
next) {
3536 for (i = 0; i < p->
neq; i++) {
3537 struct hecmw_io_mpcitem *item = &p->
item[i];
3560 for (i = 1; i < p->
neq; i++) {
3561 struct hecmw_io_mpcitem *item = &p->
item[i];
3564 set_err(
HECMW_IO_E1021,
"%d node%s in %s, %d node%s in %s", nnode,
3565 (nnode != 0) ?
"s" :
"", p->
item[0].
ngrp, n,
3566 (n != 0) ?
"s" :
"", p->
item[i].
ngrp);
3578 for (i = 0; i < p->
neq; i++) {
3586 for (i = 0; i < nnode; i++) {
3588 if (new_mpc ==
NULL) {
3592 memcpy(new_mpc, p,
sizeof(*new_mpc));
3597 if (new_mpc ==
NULL) {
3602 for (j = 0; j < new_mpc->
neq; j++) {
3603 struct hecmw_io_mpcitem *item = &new_mpc->
item[j];
3604 item->
node = node[j][i];
3606 item->a = p->
item[j].
a;
3612 prev->
next = new_mpc;
3617 for (i = 0; i < p->
neq; i++) {
3631 static int post_equation_check_dup(
void) {
3635 if (_mpc ==
NULL)
return 0;
3638 for (p = _mpc; p; p = p->
next) {
3641 for (q = _mpc; q; q = q->
next) {
3643 for (i = 1; i < q->
neq; i++) {
3655 static int post_equation_add_elem(
void) {
3656 int i, j, mpc_id, elem_id, dof1, dof2, type;
3661 if (_mpc ==
NULL)
return 0;
3668 for (p = _mpc, mpc_id = 1; p; p = p->
next, mpc_id++) {
3670 for (j = 0; j < p->
neq - 1; j++) {
3672 for (i = j + 1; i < p->
neq; i++) {
3675 type = 900 + dof1 * 10 + dof2;
3688 elem->
mpc_matid = (j + 1) * 10 + (i + 1);
3701 static int post_equation(
void) {
3702 if (_mpc ==
NULL)
return 0;
3704 if (post_equation_check_node_exists())
return -1;
3705 if (post_equation_ngrp_to_node())
return -1;
3709 if (post_equation_add_elem())
return -1;
3714 static int post_section_check_exists(
void) {
3715 if (_sect ==
NULL) {
3722 static int post_section_check_egrp(
void) {
3726 for (p = _sect; p; p = p->
next) {
3766 set_err(
HECMW_IO_E1026,
"Only interface element allowed in EGRP %s",
3781 static int post_section_check_mat_exists(
void) {
3787 for (p = _sect; p; p = p->
next) {
3807 static int post_section(
void) {
3808 if (post_section_check_exists())
return -1;
3809 if (post_section_check_egrp())
return -1;
3810 if (post_section_check_mat_exists())
return -1;
3815 static int post_contact_check_grp(
void) {
3819 for (p = _contact; p; p = p->
next) {
3858 fprintf(stderr,
"ERROR: CONTACT_PAIR: TYPE=%d\n", p->
type);
3868 static int post_contact_convert_sgroup(
void)
3871 int elem_id, contact_id;
3876 for (p = _contact, contact_id = 1; p; p = p->
next, contact_id++) {
3878 int n_item, i, id, ret;
3888 if (n_item == 0)
continue;
3890 elem = (
int *) malloc(
sizeof(
int) * n_item);
3891 surf = (
int *) malloc(
sizeof(
int) * n_item);
3892 if (!elem || !surf) {
3899 int eid, sid, etype, surf_etype, surf_nnode, j;
3901 const int *surf_nodes;
3904 decode_surf_key(
id, &eid, &sid);
3908 etype = element->
type;
3916 for (j = 0; j < surf_nnode; j++) {
3917 nodes[j] = element->
node[surf_nodes[j] - 1];
3922 if (ptelem ==
NULL) {
3940 ret = snprintf(new_sgrp_name,
sizeof(new_sgrp_name),
"_PT_%s", sgrp->
name);
3941 if (ret >=
sizeof(new_sgrp_name)) {
3944 }
else if (HECMW_io_get_sgrp(new_sgrp_name) !=
NULL) {
3945 set_err(
HECMW_IO_E0003,
"Surface group name: %s", new_sgrp_name);
3962 static int post_contact(
void) {
3963 if (post_contact_check_grp())
return -1;
3964 if (post_contact_convert_sgroup())
return -1;
3972 if (dof < 1 || dof > 6)
return -1;
3977 if (name ==
NULL)
return 0;
3978 if (strncmp(
"HECMW", name, 5) == 0)
return 1;
4020 printf(
"ERROR:HECMW_HASHTABLE INIT \n");
4034 printf(
"ERROR:HECMW_HASHTABLE FINALIZE \n");
4049 if (post_node())
goto error;
4051 if (post_elem())
goto error;
4053 if (post_ngrp())
goto error;
4055 if (post_egrp())
goto error;
4057 if (post_sgrp())
goto error;
4059 if (post_remove_unused_node())
goto error;
4061 if (post_initial())
goto error;
4063 if (post_equation())
goto error;
4065 if (post_section())
goto error;
4067 if (post_contact())
goto error;
4085 if (setup_flags(
mesh))
goto error;
4087 if (setup_gridfile(
mesh))
goto error;
4089 if (setup_files(
mesh))
goto error;
4091 if (setup_header(
mesh))
goto error;
4093 if (setup_zero(
mesh))
goto error;
4095 if (setup_node(
mesh))
goto error;
4097 if (setup_init(
mesh))
goto error;
4099 if (setup_elem(
mesh))
goto error;
4101 if (setup_ngrp(
mesh))
goto error;
4103 if (setup_egrp(
mesh))
goto error;
4105 if (setup_sgrp(
mesh))
goto error;
4107 if (setup_pe(
mesh))
goto error;
4109 if (setup_adapt(
mesh))
goto error;
4111 if (setup_refine(
mesh))
goto error;
4113 if (setup_mpc(
mesh))
goto error;
4115 if (setup_amp(
mesh))
goto error;
4117 if (setup_mat(
mesh))
goto error;
4119 if (setup_sect(
mesh))
goto error;
4121 if (setup_mpc_sectid(
mesh))
goto error;
4123 if (setup_contact_sectid(
mesh))
goto error;
4125 if (setup_elem_check_sectid(
mesh))
goto error;
4127 if (setup_elem_mat(
mesh))
goto error;
4129 if (setup_mpc_reorder(
mesh))
goto error;
4131 if (setup_contact(
mesh))
goto error;
HECMW_Comm HECMW_comm_get_comm(void)
int HECMW_comm_get_rank(void)
int HECMW_comm_get_size(void)
#define HECMW_MAX_NODE_MAX
#define HECMW_FILENAME_LEN
int HECMW_dist_get_mat_id(const struct hecmwST_material *mat, const char *name)
int HECMW_dist_get_ngrp_id(const struct hecmwST_node_grp *ngrp, const char *name)
int HECMW_dist_get_egrp_id(const struct hecmwST_elem_grp *egrp, const char *name)
int HECMW_dist_get_sgrp_id(const struct hecmwST_surf_grp *sgrp, const char *name)
struct hecmwST_local_mesh * mesh
int HECMW_set_verror(int errorno, const char *fmt, va_list ap)
int HECMW_is_etype_interface(int etype)
int HECMW_get_max_node(int etype)
int HECMW_get_max_surf(int etype)
int HECMW_is_etype_link(int etype)
int HECMW_is_etype_patch(int etype)
int HECMW_is_etype_beam(int etype)
int HECMW_is_etype_solid(int etype)
int HECMW_is_etype_shell(int etype)
const int * HECMW_get_surf_nodes(int etype, int sid, int *surf_etype)
hecmw_hash_p * hecmw_hash_p_new(unsigned int index)
void * hecmw_hash_p_get(const hecmw_hash_p *hash, const char *key)
int hecmw_hash_p_put(hecmw_hash_p *hash, const char *key, void *value)
void hecmw_hash_p_delete(hecmw_hash_p *hash)
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)
struct hecmw_io_egrp * HECMW_io_get_egrp(const char *name)
struct hecmw_io_id_array * HECMW_io_get_node_in_ngrp(const char *name)
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)
#define HECMW_FLAG_VERSION
int HECMW_io_add_sgrp(const char *name, int n_item, int *elem, int *surf)
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)
struct hecmw_io_ngrp * HECMW_io_get_ngrp(const char *name)
int HECMW_io_add_egrp(const char *name, int nelem, int *elem)
struct hecmw_io_node * HECMW_io_get_node(int id)
struct hecmw_io_initial * HECMW_io_add_initial(int type, int node, const char *ngrp, double val)
struct hecmw_io_contact * HECMW_io_add_contact(const char *name, int type, const char *slave_grp, const char *master_grp)
int HECMW_io_free_all(void)
struct hecmw_io_element * HECMW_io_get_elem(int id)
struct hecmw_io_material * HECMW_io_add_mat(const char *name, struct hecmw_io_material *mat)
int HECMW_io_get_elem_max_id(void)
struct hecmw_io_initial * HECMW_io_get_initial(int node)
struct hecmwST_local_mesh * HECMW_io_make_local_mesh(void)
void HECMW_io_set_zero(struct hecmw_io_zero *zero)
int HECMW_io_get_version(void)
int HECMW_hash_finalize(void)
int HECMW_hash_init(void)
int HECMW_io_get_n_node(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)
void HECMW_io_print_all(FILE *fp)
struct hecmw_io_node * HECMW_io_add_node(int id, double x, double y, double z)
int HECMW_io_post_process(void)
int HECMW_io_get_n_elem(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)
int HECMW_io_get_nnode_in_ngrp(const char *name)
int HECMW_log(int loglv, const char *fmt,...)
#define HECMW_calloc(nmemb, size)
#define HECMW_malloc(size)
size_t HECMW_map_int_nval(const struct hecmw_map_int *map)
int HECMW_map_int_add(struct hecmw_map_int *map, int key, void *value)
int HECMW_map_int_iter_next(struct hecmw_map_int *map, int *key, void **value)
int HECMW_map_int_mark_init(struct hecmw_map_int *map)
int HECMW_map_int_mark(struct hecmw_map_int *map, int key)
int HECMW_map_int_iter_next_unmarked(struct hecmw_map_int *map, int *key, void **value)
int HECMW_map_int_del_unmarked(struct hecmw_map_int *map)
void * HECMW_map_int_get(const struct hecmw_map_int *map, int key)
size_t HECMW_map_int_check_dup(struct hecmw_map_int *map)
void HECMW_map_int_iter_init(struct hecmw_map_int *map)
void HECMW_map_int_finalize(struct hecmw_map_int *map)
int HECMW_map_int_key2local(const struct hecmw_map_int *map, int key, size_t *local)
int HECMW_map_int_init(struct hecmw_map_int *map, void(*free_fnc)(void *))
int HECMW_reorder(struct hecmwST_local_mesh *local_mesh)
int HECMW_set_int_iter_next(struct hecmw_set_int *set, int *value)
void HECMW_set_int_finalize(struct hecmw_set_int *set)
int HECMW_set_int_add(struct hecmw_set_int *set, int value)
int HECMW_set_int_init(struct hecmw_set_int *set)
void HECMW_set_int_iter_init(struct hecmw_set_int *set)
int HECMW_set_int_del(struct hecmw_set_int *set, int value)
size_t HECMW_set_int_check_dup(struct hecmw_set_int *set)
int HECMW_set_int_is_empty(const struct hecmw_set_int *set)
size_t HECMW_set_int_nval(struct hecmw_set_int *set)
#define HECMW_FLAG_PARTTYPE_UNKNOWN
#define HECMW_SECT_TYPE_SOLID
#define HECMW_SECT_TYPE_SHELL
#define HECMW_SECT_TYPE_INTERFACE
#define HECMW_CONTACT_TYPE_NODE_SURF
#define HECMW_CONTACT_TYPE_NODE_ELEM
#define HECMW_CONTACT_TYPE_SURF_SURF
#define HECMW_SECT_TYPE_BEAM
#define HECMW_FLAG_PARTCONTACT_UNKNOWN
void HECMW_print_vmsg(int loglv, int msgno, const char *fmt, va_list ap)
#define HECMW_assert(cond)
subroutine free_ngrp(grp)
subroutine free_node(mesh)
subroutine free_sect(sect)
subroutine free_egrp(grp)
subroutine free_sgrp(grp)
subroutine free_elem(mesh)
struct hecmw_io_amplitude_item * next
char name[HECMW_NAME_LEN+1]
struct hecmw_io_amplitude * next
struct hecmw_io_amplitude::hecmw_io_amplitude_item * item
struct hecmw_io_amplitude_item * last
char name[HECMW_NAME_LEN+1]
struct hecmw_set_int * elem
struct hecmw_io_egrp * next
char matname[HECMW_NAME_LEN+1]
struct hecmw_io_initial * next
char ngrp[HECMW_NAME_LEN+1]
struct hecmw_io_matsubitem * next
struct hecmw_io_material::hecmw_io_matitem::hecmw_io_matsubitem * subitem
struct hecmw_io_material * next
struct hecmw_io_material::hecmw_io_matitem * item
char name[HECMW_NAME_LEN+1]
char ngrp[HECMW_NAME_LEN+1]
struct hecmw_io_mpc * next
struct hecmw_io_mpc::hecmw_io_mpcitem * item
struct hecmw_set_int * node
struct hecmw_io_ngrp * next
char name[HECMW_NAME_LEN+1]
char egrp[HECMW_NAME_LEN+1]
struct hecmw_io_section * next
union hecmw_io_section::hecmw_io_section_item sect
char material[HECMW_NAME_LEN+1]
struct hecmw_set_int * item
struct hecmw_io_sgrp * next
char name[HECMW_NAME_LEN+1]
int * amp_type_definition
struct hecmwST_section * section
int * adapt_children_item
double * elem_mat_int_val
int * adapt_children_index
struct hecmwST_amplitude * amp
struct hecmwST_material * material
struct hecmwST_node_grp * node_group
double * node_init_val_item
struct hecmwST_contact_pair * contact_pair
struct hecmwST_surf_grp * surf_group
long long * elem_node_index
char gridfile[HECMW_FILENAME_LEN+1]
char header[HECMW_HEADER_LEN+1]
int hecmw_flag_partcontact
struct hecmwST_elem_grp * elem_group
int * node_init_val_index
int * when_i_was_refined_node
int * when_i_was_refined_elem
struct hecmw_io_section::hecmw_io_section_item::hecmw_io_section_interface interface
struct hecmw_io_section::hecmw_io_section_item::hecmw_io_section_solid solid
struct hecmw_io_section::hecmw_io_section_item::hecmw_io_section_shell shell
struct hecmw_io_section::hecmw_io_section_item::hecmw_io_section_beam beam