26#define HECMW_FLAG_VERSION 5
28static int global_node_ID_max = -1;
29static int global_elem_ID_max = -1;
51static void do_logging(
int loglv,
int msgno,
const char *fmt, va_list ap) {
59static void set_err(
int msgno,
const char *fmt, ...) {
67static void set_warn(
int msgno,
const char *fmt, ...) {
77static int get_gid2lid_node(
int gid) {
86static int get_gid2lid_elem(
int gid) {
97static 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);
106static 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;
118static int clear(
void) {
121 strcpy(grid_filename,
"Unkown");
145static 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");
153static 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");
170static 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");
183static 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");
200static 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");
231static 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");
253static 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");
275static 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");
298static 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");
327static 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");
352static 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");
371static 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");
389static 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");
397static 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, ");
413 fprintf(fp,
"END of CONTACT PAIR\n");
454 if (header ==
NULL)
return 0;
461 if (zero ==
NULL)
return 0;
468 if (node ==
NULL)
return 0;
476 if (elem ==
NULL)
return 0;
486 for (p = ngrp; p; p = q) {
498 for (p = egrp; p; p = q) {
510 for (p = sgrp; p; p = q) {
522 for (p = mpc; p; p = q) {
532 struct hecmw_io_amplitude_item *pp, *qq;
534 for (p = amp; p; p = q) {
536 for (pp = p->
item; pp; pp = qq) {
548 for (p = init; p; p = q) {
558 struct hecmw_io_matsubitem *pp, *qq;
560 for (p = mat; p; p = q) {
562 for (i = 0; i < p->
nitem; i++) {
578 for (p =
sect; p; p = q) {
586 if (system ==
NULL)
return 0;
595 for (p = contact; p; p = q) {
603 if (free_header(_head))
return -1;
604 if (free_zero(_zero))
return -1;
605 if (free_node(_node))
return -1;
606 if (free_elem(_elem))
return -1;
607 if (free_ngrp(_ngrp))
return -1;
608 if (free_egrp(_egrp))
return -1;
609 if (free_sgrp(_sgrp))
return -1;
610 if (free_mpc(_mpc))
return -1;
611 if (free_amp(_amp))
return -1;
612 if (free_init(_init))
return -1;
613 if (free_material(_mat))
return -1;
614 if (free_sect(_sect))
return -1;
615 if (free_system(_system))
return -1;
616 if (free_contact(_contact))
return -1;
623 if (gridfile ==
NULL) gridfile =
"";
625 strcpy(grid_filename, gridfile);
630 int time,
int value,
double val,
634 struct hecmw_io_amplitude_item *item;
645 if (prev_amp !=
NULL && strcmp(prev_amp->
name, name) == 0) {
653 strcpy(p->
name, name);
658 if (prev_amp ==
NULL) {
692 for (p = _init; p; p = p->
next) {
699 const char *
ngrp,
double val) {
722 if (prev_init ==
NULL) {
759static void free_io_elem(
void *io_elem) {
789 if (new_node ==
NULL) {
793 memcpy(new_node,
node,
sizeof(*new_node) *
nnode);
799 if (new_matitem ==
NULL) {
807 if (new_elem ==
NULL) {
812 new_elem->
node = new_node;
814 new_elem->
matitem = new_matitem;
835 if (
id > global_elem_ID_max) {
836 global_elem_ID_max = id;
854 if (egrp ==
NULL)
goto error;
942 for (i = 0; i <
nelem; i++) {
959 printf(
"HECMW HASH TABEL PUT ERROR\n");
985static void free_io_node(
void *io_node) {
996 if (new_node ==
NULL) {
1004 if (_node ==
NULL) {
1006 if (_node ==
NULL) {
1021 if (
id > global_node_ID_max) {
1022 global_node_ID_max = id;
1036 for (p = _ngrp; p; p = p->
next) {
1037 if (strcmp(p->
name,
name) == 0)
break;
1039 if (p ==
NULL)
return 0;
1151 if (prev_ngrp ==
NULL) {
1154 prev_ngrp->
next = p;
1159 for (i = 0; i <
nnode; i++) {
1175 printf(
"HECMW HASH TABEL PUT ERROR\n");
1189static int HECMW_io_remove_node_in_ngrp(
int node) {
1193 for (p = _ngrp; p; p =
next) {
1277 if (prev_sgrp ==
NULL) {
1280 prev_sgrp->
next = p;
1285 for (i = 0; i < n_item; i++) {
1301 printf(
"HECMW HASH TABEL PUT ERROR\n");
1316 const struct hecmw_io_mpcitem *mpcitem,
1321 struct hecmw_io_mpcitem *item;
1327 if (mpcitem ==
NULL) {
1344 for (i = 0; i < neq; i++) {
1345 const struct hecmw_io_mpcitem *src = &mpcitem[i];
1346 struct hecmw_io_mpcitem *dst = &item[i];
1347 HECMW_assert((src->node == -1) ? (strlen(src->ngrp) > 0) : 1);
1350 strcpy(dst->ngrp, src->ngrp);
1351 dst->node = src->node;
1352 dst->dof = src->dof;
1361 if (prev_mpc ==
NULL) {
1389 if (prev_sect ==
NULL) {
1392 prev_sect->
next = p;
1431 printf(
"HECMW HASH TABEL PUT ERROR\n");
1434 if (prev_mat ==
NULL) {
1437 prev_mat->
next = mat;
1447 if (header ==
NULL) {
1504 if (prev_contact ==
NULL) {
1507 prev_contact->
next = p;
1553 p = _head ? _head->
header :
"";
1583 for (p = _init; p; p = p->
next) {
1603 for (p = _init; p; p = p->
next) {
1604 int lid = get_gid2lid_node(p->
node);
1622 for (p = _init; p; p = p->
next) {
1623 int lid = get_gid2lid_node(p->
node);
1828 for (j = 0; j < n; j++) {
1846 int i, j, nngrp,
nnode;
1872 for (p = _ngrp; p; p = p->
next) {
1876 ngrp->
n_grp = nngrp;
1878 if (ngrp->
n_grp <= 0) {
1900 size =
sizeof(*ngrp->
grp_item) * nnode;
1909 for (i = 0, p = _ngrp; p; p = p->
next, i++) {
1916 ngrp->
grp_item[start + j] = get_gid2lid_node(nid);
1937 int i, j, negrp,
nelem;
1962 for (p = _egrp; p; p = p->
next) {
1966 egrp->
n_grp = negrp;
1968 if (egrp->
n_grp <= 0) {
1990 size =
sizeof(*egrp->
grp_item) * nelem;
1999 for (i = 0, p = _egrp; p; p = p->
next, i++) {
2008 egrp->
grp_item[start + j] = get_gid2lid_elem(eid);
2030 int i, j, nsgrp,
nelem;
2055 for (p = _sgrp; p; p = p->
next) {
2059 sgrp->
n_grp = nsgrp;
2061 if (sgrp->
n_grp <= 0) {
2083 size =
sizeof(*sgrp->
grp_item) * nelem * 2;
2092 for (i = 0, p = _sgrp; p; p = p->
next, i++) {
2099 decode_surf_key(
id, &eid, &sid);
2101 sgrp->
grp_item[start + j * 2] = get_gid2lid_elem(eid);
2102 sgrp->
grp_item[start + j * 2 + 1] = sid;
2122 int i, j, nmpc, nneq, start;
2150 for (p = _mpc; p; p = p->
next) {
2167 size =
sizeof(*mpc->
mpc_item) * nneq;
2175 size =
sizeof(*mpc->
mpc_dof) * nneq;
2183 size =
sizeof(*mpc->
mpc_val) * nneq;
2201 for (p = _mpc; p; p = p->
next) {
2206 for (j = 0; j < p->
neq; j++) {
2235 int i, j, namp, nitem, start;
2265 for (p = _amp; p; p = p->
next) {
2266 struct hecmw_io_amplitude_item *item;
2267 for (item = p->
item; item; item = item->
next) {
2317 size =
sizeof(*amp->
amp_val) * nitem;
2335 for (p = _amp; p; p = p->
next) {
2336 struct hecmw_io_amplitude_item *item;
2338 for (item = p->
item; item; item = item->
next) {
2345 for (item = p->
item, j = 0; item; item = item->
next, j++) {
2346 amp->
amp_val[start + j] = item->val;
2347 amp->
amp_table[start + j] = item->table;
2442 const char *egrp_name,
int sectid) {
2443 int i, eid, egid, start, end;
2459 for (i = start; i <= end; i++) {
2472 int i, nsect, nint, nreal, nmat;
2480 size =
sizeof(*sect);
2496 nsect = nint = nreal = nmat = 0;
2497 for (p = _sect; p; p = p->
next) {
2520 sect->n_sect = nsect;
2531 if (
sect->n_sect <= 0) {
2537 size =
sizeof(*
sect->sect_type) *
sect->n_sect;
2545 size =
sizeof(*
sect->sect_opt) *
sect->n_sect;
2553 size =
sizeof(*
sect->sect_mat_ID_index) * (
sect->n_sect + 1);
2555 if (
sect->sect_mat_ID_index ==
NULL) {
2562 size =
sizeof(*
sect->sect_mat_ID_item) * nmat;
2564 if (
sect->sect_mat_ID_item ==
NULL) {
2570 size =
sizeof(*
sect->sect_I_index) * (
sect->n_sect + 1);
2580 size =
sizeof(*
sect->sect_I_item) * nint;
2589 size =
sizeof(*
sect->sect_R_index) * (
sect->n_sect + 1);
2599 size =
sizeof(*
sect->sect_R_item) * nreal;
2608 sect->sect_I_index[0] = 0;
2609 sect->sect_R_index[0] = 0;
2610 sect->sect_mat_ID_index[0] = 0;
2611 for (i = 0, p = _sect; p; p = p->
next, i++) {
2612 int iidx =
sect->sect_I_index[i];
2613 int ridx =
sect->sect_R_index[i];
2616 sect->sect_I_index[i + 1] =
sect->sect_I_index[i] + 0;
2617 sect->sect_R_index[i + 1] =
sect->sect_R_index[i] + 1;
2621 sect->sect_I_index[i + 1] =
sect->sect_I_index[i] + 1;
2622 sect->sect_R_index[i + 1] =
sect->sect_R_index[i] + 1;
2628 sect->sect_I_index[i + 1] =
sect->sect_I_index[i] + 0;
2629 sect->sect_R_index[i + 1] =
sect->sect_R_index[i] + 7;
2639 sect->sect_I_index[i + 1] =
sect->sect_I_index[i] + 0;
2640 sect->sect_R_index[i + 1] =
sect->sect_R_index[i] + 4;
2651 sect->sect_mat_ID_index[i + 1] =
sect->sect_mat_ID_index[i] + 1;
2652 midx =
sect->sect_mat_ID_index[i];
2655 sect->sect_mat_ID_item[midx] =
2661 if (setup_sect_set_sectid(mesh, p->
egrp, i + 1))
return -1;
2695 int i, j, k, l, nmat,
nmatitem, nmatsubitem, nmattable;
2703 size =
sizeof(*mat);
2711 nmat = nmatitem = nmatsubitem = nmattable = 0;
2712 for (p = _mat; p; p = p->
next) {
2714 nmatitem += p->
nitem;
2715 for (i = 0; i < p->
nitem; i++) {
2716 struct hecmw_io_matsubitem *msi = p->
item[i].
subitem;
2735 if (mat->
n_mat <= 0) {
2773 size =
sizeof(*mat->
mat_val) * nmattable;
2781 size =
sizeof(*mat->
mat_temp) * nmattable;
2792 for (i = 0, p = _mat; p; p = p->
next, i++) {
2800 for (j = 0; j < p->
nitem; j++) {
2802 struct hecmw_io_matitem *item = &p->
item[j];
2803 struct hecmw_io_matsubitem *subitem = item->
subitem;
2808 for (subitem = item->subitem; subitem; subitem = subitem->next) {
2811 for (k = 0; k < item->nval; k++) {
2817 for (k = 0, subitem = item->subitem; subitem;
2818 subitem = subitem->next, k++) {
2819 for (l = 0; l < item->nval; l++) {
2825 mat->
mat_val[idx] = subitem->val[l];
2826 mat->
mat_temp[idx] = subitem->temp;
2842 int i, j, n, id, idx, *start, sectid, nmat, *matid;
2890 if (matid ==
NULL) {
2894 for (j = 0; j < n; j++) {
2895 matid[j] = start[j];
2897 mat[i].matid = matid;
2922 for (j = 0; j < mat[i].n; j++) {
2938 int i, npair, slave_gid, master_gid, orislave_sgid;
2948 if (cpair ==
NULL) {
2960 if (_contact ==
NULL) {
2967 for (p = _contact; p; p = p->
next) {
2974 size =
sizeof(*cpair->
name) * (cpair->
n_pair);
2982 size =
sizeof(*cpair->
type) * (cpair->
n_pair);
3014 for (p = _contact, i = 0; p; p = p->
next, i++) {
3075static int post_remove_unused_node(
void) {
3085 if (HECMW_io_remove_node_in_ngrp(
id) < 0) {
3095static int post_node(
void) {
3111static int post_elem_check_node_existence(
void) {
3127 for (j = 0; j < ncon; j++) {
3141static char *post_elem_make_matname(
int id,
char *buf,
int bufsize) {
3142 const char *
matname =
"HECMW-MAT";
3147 sprintf(buf,
"%s%d",
matname,
id);
3152static int post_elem_make_mat(
void) {
3157 struct hecmw_io_matitem *matitem;
3158 struct hecmw_io_matsubitem *matsubitem;
3171 if (matitem ==
NULL) {
3177 if (matsubitem ==
NULL) {
3183 if (matsubitem->val ==
NULL) {
3188 for (j = 0; j < p->
nmatitem; j++) {
3189 matsubitem->val[j] = p->
matitem[j];
3191 matsubitem->temp = 0.0;
3192 matsubitem->next =
NULL;
3196 matitem->subitem = matsubitem;
3199 mat->
item = matitem;
3200 post_elem_make_matname(
id, name,
sizeof(name));
3202 strcpy(mat->
name, name);
3210static int post_elem(
void) {
3213 if (_elem ==
NULL) {
3223 if (post_elem_check_node_existence())
return -1;
3225 if (post_elem_make_mat())
return -1;
3230static int post_ngrp(
void) {
3233 for (p = _ngrp; p; p = p->
next) {
3250static int post_egrp(
void) {
3253 for (p = _egrp; p; p = p->
next) {
3271static int post_sgrp(
void) {
3274 for (p = _sgrp; p; p = p->
next) {
3286 decode_surf_key(
id, &eid, &sid);
3290 if (element ==
NULL) {
3306static int post_initial_check_node_exists(
void) {
3310 if (_init ==
NULL)
return 0;
3314 for (p = _init; p; p =
next) {
3316 if (p->
node == -1) {
3348static int post_initial_ngrp_to_node(
void) {
3353 if (_init ==
NULL)
return 0;
3357 for (p = _init; p; p = next) {
3359 if (p->
node != -1) {
3395 for (i = 0; i <
nnode; i++) {
3397 if (new_init ==
NULL) {
3401 memcpy(new_init, p,
sizeof(*new_init));
3403 new_init->
node = node[i];
3408 prev->
next = new_init;
3419static int post_initial_check_dup(
void) {
3424 if (_init ==
NULL)
return 0;
3429 for (p = _init; p; p = p->
next) {
3437 set_err(
HECMW_IO_E1018,
"Some nodes are initialized more than once");
3443static int post_initial(
void) {
3444 if (_init ==
NULL)
return 0;
3446 if (post_initial_check_node_exists())
return -1;
3448 if (post_initial_ngrp_to_node())
return -1;
3450 if (post_initial_check_dup())
return -1;
3456static int post_equation_check_node_exists(
void) {
3460 if (_mpc ==
NULL)
return 0;
3464 for (p = _mpc; p; p =
next) {
3476 for (i = 0; i < p->
neq; i++) {
3477 struct hecmw_io_mpcitem *item = &p->
item[i];
3498static int post_equation_ngrp_to_node(
void) {
3499 int i, j, ignore, **node;
3502 if (_mpc ==
NULL)
return 0;
3506 for (p = _mpc; p; p =
next) {
3520 for (i = 0; i < p->
neq; i++) {
3521 struct hecmw_io_mpcitem *item = &p->
item[i];
3544 for (i = 1; i < p->
neq; i++) {
3545 struct hecmw_io_mpcitem *item = &p->
item[i];
3548 set_err(
HECMW_IO_E1021,
"%d node%s in %s, %d node%s in %s", nnode,
3549 (nnode != 0) ?
"s" :
"", p->
item[0].
ngrp, n,
3550 (n != 0) ?
"s" :
"", p->
item[i].
ngrp);
3562 for (i = 0; i < p->
neq; i++) {
3570 for (i = 0; i <
nnode; i++) {
3572 if (new_mpc ==
NULL) {
3576 memcpy(new_mpc, p,
sizeof(*new_mpc));
3581 if (new_mpc ==
NULL) {
3586 for (j = 0; j < new_mpc->
neq; j++) {
3587 struct hecmw_io_mpcitem *item = &new_mpc->
item[j];
3588 item->
node = node[j][i];
3590 item->a = p->
item[j].
a;
3596 prev->
next = new_mpc;
3601 for (i = 0; i < p->
neq; i++) {
3615static int post_equation_check_dup(
void) {
3619 if (_mpc ==
NULL)
return 0;
3622 for (p = _mpc; p; p = p->
next) {
3625 for (q = _mpc; q; q = q->
next) {
3627 for (i = 1; i < q->
neq; i++) {
3639static int post_equation_add_elem(
void) {
3640 int i, j, mpc_id, elem_id, dof1, dof2, type;
3645 if (_mpc ==
NULL)
return 0;
3652 for (p = _mpc, mpc_id = 1; p; p = p->
next, mpc_id++) {
3654 for (j = 0; j < p->
neq - 1; j++) {
3656 for (i = j + 1; i < p->
neq; i++) {
3659 type = 900 + dof1 * 10 + dof2;
3672 elem->
mpc_matid = (j + 1) * 10 + (i + 1);
3685static int post_equation(
void) {
3686 if (_mpc ==
NULL)
return 0;
3688 if (post_equation_check_node_exists())
return -1;
3689 if (post_equation_ngrp_to_node())
return -1;
3693 if (post_equation_add_elem())
return -1;
3698static int post_section_check_exists(
void) {
3699 if (_sect ==
NULL) {
3706static int post_section_check_egrp(
void) {
3710 for (p = _sect; p; p = p->
next) {
3750 set_err(
HECMW_IO_E1026,
"Only interface element allowed in EGRP %s",
3765static int post_section_check_mat_exists(
void) {
3771 for (p = _sect; p; p = p->
next) {
3791static int post_section(
void) {
3792 if (post_section_check_exists())
return -1;
3793 if (post_section_check_egrp())
return -1;
3794 if (post_section_check_mat_exists())
return -1;
3799static int post_contact_check_grp(
void) {
3803 for (p = _contact; p; p = p->
next) {
3820 fprintf(stderr,
"ERROR: CONTACT_PAIR: TYPE=%d\n", p->
type);
3835static int post_contact_convert_sgroup(
void)
3838 int elem_id, contact_id;
3843 for (p = _contact, contact_id = 1; p; p = p->
next, contact_id++) {
3845 int n_item, i, id, ret;
3855 if (n_item == 0)
continue;
3857 elem = (
int *) malloc(
sizeof(
int) * n_item);
3858 surf = (
int *) malloc(
sizeof(
int) * n_item);
3859 if (!elem || !surf) {
3866 int eid, sid, etype, surf_etype, surf_nnode, j;
3868 const int *surf_nodes;
3871 decode_surf_key(
id, &eid, &sid);
3875 etype = element->
type;
3883 for (j = 0; j < surf_nnode; j++) {
3884 nodes[j] = element->
node[surf_nodes[j] - 1];
3889 if (ptelem ==
NULL) {
3907 ret = snprintf(new_sgrp_name,
sizeof(new_sgrp_name),
"_PT_%s", sgrp->
name);
3908 if (ret >=
sizeof(new_sgrp_name)) {
3911 }
else if (HECMW_io_get_sgrp(new_sgrp_name) !=
NULL) {
3912 set_err(
HECMW_IO_E0003,
"Surface group name: %s", new_sgrp_name);
3929static int post_contact(
void) {
3930 if (post_contact_check_grp())
return -1;
3931 if (post_contact_convert_sgroup())
return -1;
3939 if (dof < 1 || dof > 6)
return -1;
3944 if (name ==
NULL)
return 0;
3945 if (strncmp(
"HECMW", name, 5) == 0)
return 1;
3987 printf(
"ERROE:HECMW_HASHTABLE INIT \n");
4001 printf(
"ERROE:HECMW_HASHTABLE FINALIZE \n");
4016 if (post_node())
goto error;
4018 if (post_elem())
goto error;
4020 if (post_ngrp())
goto error;
4022 if (post_egrp())
goto error;
4024 if (post_sgrp())
goto error;
4026 if (post_remove_unused_node())
goto error;
4028 if (post_initial())
goto error;
4030 if (post_equation())
goto error;
4032 if (post_section())
goto error;
4034 if (post_contact())
goto error;
4052 if (setup_flags(
mesh))
goto error;
4054 if (setup_gridfile(
mesh))
goto error;
4056 if (setup_files(
mesh))
goto error;
4058 if (setup_header(
mesh))
goto error;
4060 if (setup_zero(
mesh))
goto error;
4062 if (setup_node(
mesh))
goto error;
4064 if (setup_init(
mesh))
goto error;
4066 if (setup_elem(
mesh))
goto error;
4068 if (setup_ngrp(
mesh))
goto error;
4070 if (setup_egrp(
mesh))
goto error;
4072 if (setup_sgrp(
mesh))
goto error;
4074 if (setup_pe(
mesh))
goto error;
4076 if (setup_adapt(
mesh))
goto error;
4078 if (setup_refine(
mesh))
goto error;
4080 if (setup_mpc(
mesh))
goto error;
4082 if (setup_amp(
mesh))
goto error;
4084 if (setup_mat(
mesh))
goto error;
4086 if (setup_sect(
mesh))
goto error;
4088 if (setup_mpc_sectid(
mesh))
goto error;
4090 if (setup_contact_sectid(
mesh))
goto error;
4092 if (setup_elem_check_sectid(
mesh))
goto error;
4094 if (setup_elem_mat(
mesh))
goto error;
4096 if (setup_mpc_reorder(
mesh))
goto error;
4098 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)
const int * HECMW_get_surf_nodes(int etype, int sid, int *surf_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)
void * hecmw_hash_p_get(const hecmw_hash_p *hash, const char *key)
hecmw_hash_p * hecmw_hash_p_new(unsigned int index)
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_egrp * HECMW_io_get_egrp(const char *name)
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_material * HECMW_io_get_mat(const char *name)
struct hecmw_io_element * HECMW_io_add_elem(int id, int type, int *node, int nmatitem, double *matitem)
#define HECMW_FLAG_VERSION
int HECMW_io_add_sgrp(const char *name, int n_item, int *elem, int *surf)
struct hecmw_io_ngrp * HECMW_io_get_ngrp(const char *name)
int HECMW_io_add_egrp(const char *name, int nelem, int *elem)
int HECMW_io_free_all(void)
struct hecmwST_local_mesh * HECMW_io_make_local_mesh(void)
struct hecmw_io_contact * HECMW_io_add_contact(const char *name, int type, const char *slave_grp, const char *master_grp)
struct hecmw_io_node * HECMW_io_add_node(int id, double x, double y, double z)
int HECMW_io_get_elem_max_id(void)
void HECMW_io_set_zero(struct hecmw_io_zero *zero)
int HECMW_io_get_version(void)
struct hecmw_io_amplitude * HECMW_io_add_amp(const char *name, int definition, int time, int value, double val, double t)
struct hecmw_io_node * HECMW_io_get_node(int id)
struct hecmw_io_initial * HECMW_io_get_initial(int node)
int HECMW_hash_finalize(void)
struct hecmw_io_initial * HECMW_io_add_initial(int type, int node, const char *ngrp, double val)
struct hecmw_io_id_array * HECMW_io_get_node_in_ngrp(const char *name)
struct hecmw_io_section * HECMW_io_add_sect(struct hecmw_io_section *sect)
int HECMW_hash_init(void)
struct hecmw_io_mpc * HECMW_io_add_mpc(int neq, const struct hecmw_io_mpcitem *mpcitem, double cnst)
int HECMW_io_get_n_node(void)
int HECMW_io_pre_process(void)
struct hecmw_io_element * HECMW_io_get_elem(int id)
void HECMW_io_set_system(struct hecmw_system_param *system)
void HECMW_io_print_all(FILE *fp)
int HECMW_io_post_process(void)
int HECMW_io_get_n_elem(void)
struct hecmw_system_param * HECMW_io_get_system(void)
struct hecmw_io_id_array * HECMW_io_get_elem_in_egrp(const char *name)
int HECMW_io_set_gridfile(char *gridfile)
int HECMW_io_finalize(void)
struct hecmw_io_material * HECMW_io_add_mat(const char *name, struct hecmw_io_material *mat)
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)
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)
void * HECMW_map_int_get(const struct hecmw_map_int *map, int key)
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_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
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