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 strcpy(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 =
"";
627 strcpy(grid_filename, gridfile);
632 int time,
int value,
double val,
636 struct hecmw_io_amplitude_item *item;
647 if (prev_amp !=
NULL && strcmp(prev_amp->
name, name) == 0) {
655 strcpy(p->
name, name);
660 if (prev_amp ==
NULL) {
694 for (p = _init; p; p = p->
next) {
701 const char *
ngrp,
double val) {
724 if (prev_init ==
NULL) {
761 static void free_io_elem(
void *io_elem) {
791 if (new_node ==
NULL) {
795 memcpy(new_node,
node,
sizeof(*new_node) * nnode);
801 if (new_matitem ==
NULL) {
809 if (new_elem ==
NULL) {
814 new_elem->
node = new_node;
816 new_elem->
matitem = new_matitem;
837 if (
id > global_elem_ID_max) {
838 global_elem_ID_max = id;
856 if (egrp ==
NULL)
goto error;
944 for (i = 0; i < nelem; i++) {
961 printf(
"HECMW HASH TABLE PUT ERROR\n");
987 static void free_io_node(
void *io_node) {
998 if (new_node ==
NULL) {
1006 if (_node ==
NULL) {
1008 if (_node ==
NULL) {
1023 if (
id > global_node_ID_max) {
1024 global_node_ID_max = id;
1038 for (p = _ngrp; p; p = p->
next) {
1039 if (strcmp(p->
name,
name) == 0)
break;
1041 if (p ==
NULL)
return 0;
1153 if (prev_ngrp ==
NULL) {
1156 prev_ngrp->
next = p;
1161 for (i = 0; i < nnode; i++) {
1177 printf(
"HECMW HASH TABLE PUT ERROR\n");
1191 static int HECMW_io_remove_node_in_ngrp(
int node) {
1195 for (p = _ngrp; p; p =
next) {
1279 if (prev_sgrp ==
NULL) {
1282 prev_sgrp->
next = p;
1287 for (i = 0; i < n_item; i++) {
1303 printf(
"HECMW HASH TABLE PUT ERROR\n");
1318 const struct hecmw_io_mpcitem *mpcitem,
1323 struct hecmw_io_mpcitem *item;
1329 if (mpcitem ==
NULL) {
1346 for (i = 0; i < neq; i++) {
1347 const struct hecmw_io_mpcitem *src = &mpcitem[i];
1348 struct hecmw_io_mpcitem *dst = &item[i];
1349 HECMW_assert((src->node == -1) ? (strlen(src->ngrp) > 0) : 1);
1352 strcpy(dst->ngrp, src->ngrp);
1353 dst->node = src->node;
1354 dst->dof = src->dof;
1363 if (prev_mpc ==
NULL) {
1391 if (prev_sect ==
NULL) {
1394 prev_sect->
next = p;
1433 printf(
"HECMW HASH TABLE PUT ERROR\n");
1436 if (prev_mat ==
NULL) {
1439 prev_mat->
next = mat;
1449 if (header ==
NULL) {
1506 if (prev_contact ==
NULL) {
1509 prev_contact->
next = p;
1555 p = _head ? _head->
header :
"";
1585 for (p = _init; p; p = p->
next) {
1605 for (p = _init; p; p = p->
next) {
1606 int lid = get_gid2lid_node(p->
node);
1624 for (p = _init; p; p = p->
next) {
1625 int lid = get_gid2lid_node(p->
node);
1831 for (j = 0; j < n; j++) {
1849 int i, j, nngrp, nnode;
1875 for (p = _ngrp; p; p = p->
next) {
1879 ngrp->
n_grp = nngrp;
1881 if (ngrp->
n_grp <= 0) {
1903 size =
sizeof(*ngrp->
grp_item) * nnode;
1912 for (i = 0, p = _ngrp; p; p = p->
next, i++) {
1919 ngrp->
grp_item[start + j] = get_gid2lid_node(nid);
1940 int i, j, negrp, nelem;
1965 for (p = _egrp; p; p = p->
next) {
1969 egrp->
n_grp = negrp;
1971 if (egrp->
n_grp <= 0) {
1993 size =
sizeof(*egrp->
grp_item) * nelem;
2002 for (i = 0, p = _egrp; p; p = p->
next, i++) {
2011 egrp->
grp_item[start + j] = get_gid2lid_elem(eid);
2033 int i, j, nsgrp, nelem;
2058 for (p = _sgrp; p; p = p->
next) {
2062 sgrp->
n_grp = nsgrp;
2064 if (sgrp->
n_grp <= 0) {
2086 size =
sizeof(*sgrp->
grp_item) * nelem * 2;
2095 for (i = 0, p = _sgrp; p; p = p->
next, i++) {
2102 decode_surf_key(
id, &eid, &sid);
2104 sgrp->
grp_item[start + j * 2] = get_gid2lid_elem(eid);
2105 sgrp->
grp_item[start + j * 2 + 1] = sid;
2125 int i, j, nmpc, nneq, start;
2153 for (p = _mpc; p; p = p->
next) {
2170 size =
sizeof(*mpc->
mpc_item) * nneq;
2178 size =
sizeof(*mpc->
mpc_dof) * nneq;
2186 size =
sizeof(*mpc->
mpc_val) * nneq;
2204 for (p = _mpc; p; p = p->
next) {
2209 for (j = 0; j < p->
neq; j++) {
2238 int i, j, namp, nitem, start;
2268 for (p = _amp; p; p = p->
next) {
2269 struct hecmw_io_amplitude_item *item;
2270 for (item = p->
item; item; item = item->
next) {
2320 size =
sizeof(*amp->
amp_val) * nitem;
2338 for (p = _amp; p; p = p->
next) {
2339 struct hecmw_io_amplitude_item *item;
2341 for (item = p->
item; item; item = item->
next) {
2348 for (item = p->
item, j = 0; item; item = item->
next, j++) {
2349 amp->
amp_val[start + j] = item->val;
2350 amp->
amp_table[start + j] = item->table;
2445 const char *egrp_name,
int sectid) {
2446 int i, eid, egid, start, end;
2462 for (i = start; i <= end; i++) {
2475 int i, nsect, nint, nreal, nmat;
2483 size =
sizeof(*sect);
2499 nsect = nint = nreal = nmat = 0;
2500 for (p = _sect; p; p = p->
next) {
2523 sect->n_sect = nsect;
2534 if (
sect->n_sect <= 0) {
2540 size =
sizeof(*
sect->sect_type) *
sect->n_sect;
2548 size =
sizeof(*
sect->sect_opt) *
sect->n_sect;
2556 size =
sizeof(*
sect->sect_mat_ID_index) * (
sect->n_sect + 1);
2558 if (
sect->sect_mat_ID_index ==
NULL) {
2565 size =
sizeof(*
sect->sect_mat_ID_item) * nmat;
2567 if (
sect->sect_mat_ID_item ==
NULL) {
2573 size =
sizeof(*
sect->sect_I_index) * (
sect->n_sect + 1);
2583 size =
sizeof(*
sect->sect_I_item) * nint;
2592 size =
sizeof(*
sect->sect_R_index) * (
sect->n_sect + 1);
2602 size =
sizeof(*
sect->sect_R_item) * nreal;
2611 sect->sect_I_index[0] = 0;
2612 sect->sect_R_index[0] = 0;
2613 sect->sect_mat_ID_index[0] = 0;
2614 for (i = 0, p = _sect; p; p = p->
next, i++) {
2615 int iidx =
sect->sect_I_index[i];
2616 int ridx =
sect->sect_R_index[i];
2619 sect->sect_I_index[i + 1] =
sect->sect_I_index[i] + 0;
2620 sect->sect_R_index[i + 1] =
sect->sect_R_index[i] + 1;
2624 sect->sect_I_index[i + 1] =
sect->sect_I_index[i] + 1;
2625 sect->sect_R_index[i + 1] =
sect->sect_R_index[i] + 1;
2631 sect->sect_I_index[i + 1] =
sect->sect_I_index[i] + 0;
2632 sect->sect_R_index[i + 1] =
sect->sect_R_index[i] + 7;
2642 sect->sect_I_index[i + 1] =
sect->sect_I_index[i] + 0;
2643 sect->sect_R_index[i + 1] =
sect->sect_R_index[i] + 4;
2654 sect->sect_mat_ID_index[i + 1] =
sect->sect_mat_ID_index[i] + 1;
2655 midx =
sect->sect_mat_ID_index[i];
2658 sect->sect_mat_ID_item[midx] =
2664 if (setup_sect_set_sectid(mesh, p->
egrp, i + 1))
return -1;
2698 int i, j, k, l, nmat,
nmatitem, nmatsubitem, nmattable;
2706 size =
sizeof(*mat);
2714 nmat = nmatitem = nmatsubitem = nmattable = 0;
2715 for (p = _mat; p; p = p->
next) {
2717 nmatitem += p->
nitem;
2718 for (i = 0; i < p->
nitem; i++) {
2719 struct hecmw_io_matsubitem *msi = p->
item[i].
subitem;
2738 if (mat->
n_mat <= 0) {
2776 size =
sizeof(*mat->
mat_val) * nmattable;
2784 size =
sizeof(*mat->
mat_temp) * nmattable;
2795 for (i = 0, p = _mat; p; p = p->
next, i++) {
2803 for (j = 0; j < p->
nitem; j++) {
2805 struct hecmw_io_matitem *item = &p->
item[j];
2806 struct hecmw_io_matsubitem *subitem = item->
subitem;
2811 for (subitem = item->subitem; subitem; subitem = subitem->next) {
2814 for (k = 0; k < item->nval; k++) {
2820 for (k = 0, subitem = item->subitem; subitem;
2821 subitem = subitem->next, k++) {
2822 for (l = 0; l < item->nval; l++) {
2828 mat->
mat_val[idx] = subitem->val[l];
2829 mat->
mat_temp[idx] = subitem->temp;
2845 int i, j, n, id, idx, *start, sectid, nmat, *matid;
2893 if (matid ==
NULL) {
2897 for (j = 0; j < n; j++) {
2898 matid[j] = start[j];
2900 mat[i].matid = matid;
2925 for (j = 0; j < mat[i].n; j++) {
2941 int i, npair, slave_gid, master_gid, orislave_sgid;
2951 if (cpair ==
NULL) {
2963 if (_contact ==
NULL) {
2970 for (p = _contact; p; p = p->
next) {
2977 size =
sizeof(*cpair->
name) * (cpair->
n_pair);
2985 size =
sizeof(*cpair->
type) * (cpair->
n_pair);
3017 for (p = _contact, i = 0; p; p = p->
next, i++) {
3086 static int post_remove_unused_node(
void) {
3096 if (HECMW_io_remove_node_in_ngrp(
id) < 0) {
3106 static int post_node(
void) {
3122 static int post_elem_check_node_existence(
void) {
3138 for (j = 0; j < ncon; j++) {
3152 static char *post_elem_make_matname(
int id,
char *buf,
int bufsize) {
3153 const char *
matname =
"HECMW-MAT";
3158 sprintf(buf,
"%s%d",
matname,
id);
3163 static int post_elem_make_mat(
void) {
3168 struct hecmw_io_matitem *matitem;
3169 struct hecmw_io_matsubitem *matsubitem;
3182 if (matitem ==
NULL) {
3188 if (matsubitem ==
NULL) {
3194 if (matsubitem->val ==
NULL) {
3199 for (j = 0; j < p->
nmatitem; j++) {
3200 matsubitem->val[j] = p->
matitem[j];
3202 matsubitem->temp = 0.0;
3203 matsubitem->next =
NULL;
3207 matitem->subitem = matsubitem;
3210 mat->
item = matitem;
3211 post_elem_make_matname(
id, name,
sizeof(name));
3213 strcpy(mat->
name, name);
3221 static int post_elem(
void) {
3224 if (_elem ==
NULL) {
3234 if (post_elem_check_node_existence())
return -1;
3236 if (post_elem_make_mat())
return -1;
3241 static int post_ngrp(
void) {
3244 for (p = _ngrp; p; p = p->
next) {
3261 static int post_egrp(
void) {
3264 for (p = _egrp; p; p = p->
next) {
3282 static int post_sgrp(
void) {
3285 for (p = _sgrp; p; p = p->
next) {
3297 decode_surf_key(
id, &eid, &sid);
3301 if (element ==
NULL) {
3317 static int post_initial_check_node_exists(
void) {
3321 if (_init ==
NULL)
return 0;
3325 for (p = _init; p; p =
next) {
3327 if (p->
node == -1) {
3359 static int post_initial_ngrp_to_node(
void) {
3360 int i, nnode, ignore, *
node;
3364 if (_init ==
NULL)
return 0;
3368 for (p = _init; p; p = next) {
3370 if (p->
node != -1) {
3406 for (i = 0; i < nnode; i++) {
3408 if (new_init ==
NULL) {
3412 memcpy(new_init, p,
sizeof(*new_init));
3414 new_init->
node = node[i];
3419 prev->
next = new_init;
3430 static int post_initial_check_dup(
void) {
3435 if (_init ==
NULL)
return 0;
3440 for (p = _init; p; p = p->
next) {
3448 set_err(
HECMW_IO_E1018,
"Some nodes are initialized more than once");
3454 static int post_initial(
void) {
3455 if (_init ==
NULL)
return 0;
3457 if (post_initial_check_node_exists())
return -1;
3459 if (post_initial_ngrp_to_node())
return -1;
3461 if (post_initial_check_dup())
return -1;
3467 static int post_equation_check_node_exists(
void) {
3471 if (_mpc ==
NULL)
return 0;
3475 for (p = _mpc; p; p =
next) {
3487 for (i = 0; i < p->
neq; i++) {
3488 struct hecmw_io_mpcitem *item = &p->
item[i];
3509 static int post_equation_ngrp_to_node(
void) {
3510 int i, j, ignore, **node;
3513 if (_mpc ==
NULL)
return 0;
3517 for (p = _mpc; p; p =
next) {
3531 for (i = 0; i < p->
neq; i++) {
3532 struct hecmw_io_mpcitem *item = &p->
item[i];
3555 for (i = 1; i < p->
neq; i++) {
3556 struct hecmw_io_mpcitem *item = &p->
item[i];
3559 set_err(
HECMW_IO_E1021,
"%d node%s in %s, %d node%s in %s", nnode,
3560 (nnode != 0) ?
"s" :
"", p->
item[0].
ngrp, n,
3561 (n != 0) ?
"s" :
"", p->
item[i].
ngrp);
3573 for (i = 0; i < p->
neq; i++) {
3581 for (i = 0; i < nnode; i++) {
3583 if (new_mpc ==
NULL) {
3587 memcpy(new_mpc, p,
sizeof(*new_mpc));
3592 if (new_mpc ==
NULL) {
3597 for (j = 0; j < new_mpc->
neq; j++) {
3598 struct hecmw_io_mpcitem *item = &new_mpc->
item[j];
3599 item->
node = node[j][i];
3601 item->a = p->
item[j].
a;
3607 prev->
next = new_mpc;
3612 for (i = 0; i < p->
neq; i++) {
3626 static int post_equation_check_dup(
void) {
3630 if (_mpc ==
NULL)
return 0;
3633 for (p = _mpc; p; p = p->
next) {
3636 for (q = _mpc; q; q = q->
next) {
3638 for (i = 1; i < q->
neq; i++) {
3650 static int post_equation_add_elem(
void) {
3651 int i, j, mpc_id, elem_id, dof1, dof2, type;
3656 if (_mpc ==
NULL)
return 0;
3663 for (p = _mpc, mpc_id = 1; p; p = p->
next, mpc_id++) {
3665 for (j = 0; j < p->
neq - 1; j++) {
3667 for (i = j + 1; i < p->
neq; i++) {
3670 type = 900 + dof1 * 10 + dof2;
3683 elem->
mpc_matid = (j + 1) * 10 + (i + 1);
3696 static int post_equation(
void) {
3697 if (_mpc ==
NULL)
return 0;
3699 if (post_equation_check_node_exists())
return -1;
3700 if (post_equation_ngrp_to_node())
return -1;
3704 if (post_equation_add_elem())
return -1;
3709 static int post_section_check_exists(
void) {
3710 if (_sect ==
NULL) {
3717 static int post_section_check_egrp(
void) {
3721 for (p = _sect; p; p = p->
next) {
3761 set_err(
HECMW_IO_E1026,
"Only interface element allowed in EGRP %s",
3776 static int post_section_check_mat_exists(
void) {
3782 for (p = _sect; p; p = p->
next) {
3802 static int post_section(
void) {
3803 if (post_section_check_exists())
return -1;
3804 if (post_section_check_egrp())
return -1;
3805 if (post_section_check_mat_exists())
return -1;
3810 static int post_contact_check_grp(
void) {
3814 for (p = _contact; p; p = p->
next) {
3853 fprintf(stderr,
"ERROR: CONTACT_PAIR: TYPE=%d\n", p->
type);
3863 static int post_contact_convert_sgroup(
void)
3866 int elem_id, contact_id;
3871 for (p = _contact, contact_id = 1; p; p = p->
next, contact_id++) {
3873 int n_item, i, id, ret;
3883 if (n_item == 0)
continue;
3885 elem = (
int *) malloc(
sizeof(
int) * n_item);
3886 surf = (
int *) malloc(
sizeof(
int) * n_item);
3887 if (!elem || !surf) {
3894 int eid, sid, etype, surf_etype, surf_nnode, j;
3896 const int *surf_nodes;
3899 decode_surf_key(
id, &eid, &sid);
3903 etype = element->
type;
3911 for (j = 0; j < surf_nnode; j++) {
3912 nodes[j] = element->
node[surf_nodes[j] - 1];
3917 if (ptelem ==
NULL) {
3935 ret = snprintf(new_sgrp_name,
sizeof(new_sgrp_name),
"_PT_%s", sgrp->
name);
3936 if (ret >=
sizeof(new_sgrp_name)) {
3939 }
else if (HECMW_io_get_sgrp(new_sgrp_name) !=
NULL) {
3940 set_err(
HECMW_IO_E0003,
"Surface group name: %s", new_sgrp_name);
3957 static int post_contact(
void) {
3958 if (post_contact_check_grp())
return -1;
3959 if (post_contact_convert_sgroup())
return -1;
3967 if (dof < 1 || dof > 6)
return -1;
3972 if (name ==
NULL)
return 0;
3973 if (strncmp(
"HECMW", name, 5) == 0)
return 1;
4015 printf(
"ERROE:HECMW_HASHTABLE INIT \n");
4029 printf(
"ERROE:HECMW_HASHTABLE FINALIZE \n");
4044 if (post_node())
goto error;
4046 if (post_elem())
goto error;
4048 if (post_ngrp())
goto error;
4050 if (post_egrp())
goto error;
4052 if (post_sgrp())
goto error;
4054 if (post_remove_unused_node())
goto error;
4056 if (post_initial())
goto error;
4058 if (post_equation())
goto error;
4060 if (post_section())
goto error;
4062 if (post_contact())
goto error;
4080 if (setup_flags(
mesh))
goto error;
4082 if (setup_gridfile(
mesh))
goto error;
4084 if (setup_files(
mesh))
goto error;
4086 if (setup_header(
mesh))
goto error;
4088 if (setup_zero(
mesh))
goto error;
4090 if (setup_node(
mesh))
goto error;
4092 if (setup_init(
mesh))
goto error;
4094 if (setup_elem(
mesh))
goto error;
4096 if (setup_ngrp(
mesh))
goto error;
4098 if (setup_egrp(
mesh))
goto error;
4100 if (setup_sgrp(
mesh))
goto error;
4102 if (setup_pe(
mesh))
goto error;
4104 if (setup_adapt(
mesh))
goto error;
4106 if (setup_refine(
mesh))
goto error;
4108 if (setup_mpc(
mesh))
goto error;
4110 if (setup_amp(
mesh))
goto error;
4112 if (setup_mat(
mesh))
goto error;
4114 if (setup_sect(
mesh))
goto error;
4116 if (setup_mpc_sectid(
mesh))
goto error;
4118 if (setup_contact_sectid(
mesh))
goto error;
4120 if (setup_elem_check_sectid(
mesh))
goto error;
4122 if (setup_elem_mat(
mesh))
goto error;
4124 if (setup_mpc_reorder(
mesh))
goto error;
4126 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