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);
1830 for (j = 0; j < n; j++) {
1848 int i, j, nngrp, nnode;
1874 for (p = _ngrp; p; p = p->
next) {
1878 ngrp->
n_grp = nngrp;
1880 if (ngrp->
n_grp <= 0) {
1902 size =
sizeof(*ngrp->
grp_item) * nnode;
1911 for (i = 0, p = _ngrp; p; p = p->
next, i++) {
1918 ngrp->
grp_item[start + j] = get_gid2lid_node(nid);
1939 int i, j, negrp, nelem;
1964 for (p = _egrp; p; p = p->
next) {
1968 egrp->
n_grp = negrp;
1970 if (egrp->
n_grp <= 0) {
1992 size =
sizeof(*egrp->
grp_item) * nelem;
2001 for (i = 0, p = _egrp; p; p = p->
next, i++) {
2010 egrp->
grp_item[start + j] = get_gid2lid_elem(eid);
2032 int i, j, nsgrp, nelem;
2057 for (p = _sgrp; p; p = p->
next) {
2061 sgrp->
n_grp = nsgrp;
2063 if (sgrp->
n_grp <= 0) {
2085 size =
sizeof(*sgrp->
grp_item) * nelem * 2;
2094 for (i = 0, p = _sgrp; p; p = p->
next, i++) {
2101 decode_surf_key(
id, &eid, &sid);
2103 sgrp->
grp_item[start + j * 2] = get_gid2lid_elem(eid);
2104 sgrp->
grp_item[start + j * 2 + 1] = sid;
2124 int i, j, nmpc, nneq, start;
2152 for (p = _mpc; p; p = p->
next) {
2169 size =
sizeof(*mpc->
mpc_item) * nneq;
2177 size =
sizeof(*mpc->
mpc_dof) * nneq;
2185 size =
sizeof(*mpc->
mpc_val) * nneq;
2203 for (p = _mpc; p; p = p->
next) {
2208 for (j = 0; j < p->
neq; j++) {
2237 int i, j, namp, nitem, start;
2267 for (p = _amp; p; p = p->
next) {
2268 struct hecmw_io_amplitude_item *item;
2269 for (item = p->
item; item; item = item->
next) {
2319 size =
sizeof(*amp->
amp_val) * nitem;
2337 for (p = _amp; p; p = p->
next) {
2338 struct hecmw_io_amplitude_item *item;
2340 for (item = p->
item; item; item = item->
next) {
2347 for (item = p->
item, j = 0; item; item = item->
next, j++) {
2348 amp->
amp_val[start + j] = item->val;
2349 amp->
amp_table[start + j] = item->table;
2444 const char *egrp_name,
int sectid) {
2445 int i, eid, egid, start, end;
2461 for (i = start; i <= end; i++) {
2474 int i, nsect, nint, nreal, nmat;
2482 size =
sizeof(*sect);
2498 nsect = nint = nreal = nmat = 0;
2499 for (p = _sect; p; p = p->
next) {
2522 sect->n_sect = nsect;
2533 if (
sect->n_sect <= 0) {
2539 size =
sizeof(*
sect->sect_type) *
sect->n_sect;
2547 size =
sizeof(*
sect->sect_opt) *
sect->n_sect;
2555 size =
sizeof(*
sect->sect_mat_ID_index) * (
sect->n_sect + 1);
2557 if (
sect->sect_mat_ID_index ==
NULL) {
2564 size =
sizeof(*
sect->sect_mat_ID_item) * nmat;
2566 if (
sect->sect_mat_ID_item ==
NULL) {
2572 size =
sizeof(*
sect->sect_I_index) * (
sect->n_sect + 1);
2582 size =
sizeof(*
sect->sect_I_item) * nint;
2591 size =
sizeof(*
sect->sect_R_index) * (
sect->n_sect + 1);
2601 size =
sizeof(*
sect->sect_R_item) * nreal;
2610 sect->sect_I_index[0] = 0;
2611 sect->sect_R_index[0] = 0;
2612 sect->sect_mat_ID_index[0] = 0;
2613 for (i = 0, p = _sect; p; p = p->
next, i++) {
2614 int iidx =
sect->sect_I_index[i];
2615 int ridx =
sect->sect_R_index[i];
2618 sect->sect_I_index[i + 1] =
sect->sect_I_index[i] + 0;
2619 sect->sect_R_index[i + 1] =
sect->sect_R_index[i] + 1;
2623 sect->sect_I_index[i + 1] =
sect->sect_I_index[i] + 1;
2624 sect->sect_R_index[i + 1] =
sect->sect_R_index[i] + 1;
2630 sect->sect_I_index[i + 1] =
sect->sect_I_index[i] + 0;
2631 sect->sect_R_index[i + 1] =
sect->sect_R_index[i] + 7;
2641 sect->sect_I_index[i + 1] =
sect->sect_I_index[i] + 0;
2642 sect->sect_R_index[i + 1] =
sect->sect_R_index[i] + 4;
2653 sect->sect_mat_ID_index[i + 1] =
sect->sect_mat_ID_index[i] + 1;
2654 midx =
sect->sect_mat_ID_index[i];
2657 sect->sect_mat_ID_item[midx] =
2663 if (setup_sect_set_sectid(mesh, p->
egrp, i + 1))
return -1;
2697 int i, j, k, l, nmat,
nmatitem, nmatsubitem, nmattable;
2705 size =
sizeof(*mat);
2713 nmat = nmatitem = nmatsubitem = nmattable = 0;
2714 for (p = _mat; p; p = p->
next) {
2716 nmatitem += p->
nitem;
2717 for (i = 0; i < p->
nitem; i++) {
2718 struct hecmw_io_matsubitem *msi = p->
item[i].
subitem;
2737 if (mat->
n_mat <= 0) {
2775 size =
sizeof(*mat->
mat_val) * nmattable;
2783 size =
sizeof(*mat->
mat_temp) * nmattable;
2794 for (i = 0, p = _mat; p; p = p->
next, i++) {
2802 for (j = 0; j < p->
nitem; j++) {
2804 struct hecmw_io_matitem *item = &p->
item[j];
2805 struct hecmw_io_matsubitem *subitem = item->
subitem;
2810 for (subitem = item->subitem; subitem; subitem = subitem->next) {
2813 for (k = 0; k < item->nval; k++) {
2819 for (k = 0, subitem = item->subitem; subitem;
2820 subitem = subitem->next, k++) {
2821 for (l = 0; l < item->nval; l++) {
2827 mat->
mat_val[idx] = subitem->val[l];
2828 mat->
mat_temp[idx] = subitem->temp;
2844 int i, j, n, id, idx, *start, sectid, nmat, *matid;
2892 if (matid ==
NULL) {
2896 for (j = 0; j < n; j++) {
2897 matid[j] = start[j];
2899 mat[i].matid = matid;
2924 for (j = 0; j < mat[i].n; j++) {
2940 int i, npair, slave_gid, master_gid, orislave_sgid;
2950 if (cpair ==
NULL) {
2962 if (_contact ==
NULL) {
2969 for (p = _contact; p; p = p->
next) {
2976 size =
sizeof(*cpair->
name) * (cpair->
n_pair);
2984 size =
sizeof(*cpair->
type) * (cpair->
n_pair);
3016 for (p = _contact, i = 0; p; p = p->
next, i++) {
3085 static int post_remove_unused_node(
void) {
3095 if (HECMW_io_remove_node_in_ngrp(
id) < 0) {
3105 static int post_node(
void) {
3121 static int post_elem_check_node_existence(
void) {
3137 for (j = 0; j < ncon; j++) {
3151 static char *post_elem_make_matname(
int id,
char *buf,
int bufsize) {
3152 const char *
matname =
"HECMW-MAT";
3157 sprintf(buf,
"%s%d",
matname,
id);
3162 static int post_elem_make_mat(
void) {
3167 struct hecmw_io_matitem *matitem;
3168 struct hecmw_io_matsubitem *matsubitem;
3181 if (matitem ==
NULL) {
3187 if (matsubitem ==
NULL) {
3193 if (matsubitem->val ==
NULL) {
3198 for (j = 0; j < p->
nmatitem; j++) {
3199 matsubitem->val[j] = p->
matitem[j];
3201 matsubitem->temp = 0.0;
3202 matsubitem->next =
NULL;
3206 matitem->subitem = matsubitem;
3209 mat->
item = matitem;
3210 post_elem_make_matname(
id, name,
sizeof(name));
3212 strcpy(mat->
name, name);
3220 static int post_elem(
void) {
3223 if (_elem ==
NULL) {
3233 if (post_elem_check_node_existence())
return -1;
3235 if (post_elem_make_mat())
return -1;
3240 static int post_ngrp(
void) {
3243 for (p = _ngrp; p; p = p->
next) {
3260 static int post_egrp(
void) {
3263 for (p = _egrp; p; p = p->
next) {
3281 static int post_sgrp(
void) {
3284 for (p = _sgrp; p; p = p->
next) {
3296 decode_surf_key(
id, &eid, &sid);
3300 if (element ==
NULL) {
3316 static int post_initial_check_node_exists(
void) {
3320 if (_init ==
NULL)
return 0;
3324 for (p = _init; p; p =
next) {
3326 if (p->
node == -1) {
3358 static int post_initial_ngrp_to_node(
void) {
3359 int i, nnode, ignore, *
node;
3363 if (_init ==
NULL)
return 0;
3367 for (p = _init; p; p = next) {
3369 if (p->
node != -1) {
3405 for (i = 0; i < nnode; i++) {
3407 if (new_init ==
NULL) {
3411 memcpy(new_init, p,
sizeof(*new_init));
3413 new_init->
node = node[i];
3418 prev->
next = new_init;
3429 static int post_initial_check_dup(
void) {
3434 if (_init ==
NULL)
return 0;
3439 for (p = _init; p; p = p->
next) {
3447 set_err(
HECMW_IO_E1018,
"Some nodes are initialized more than once");
3453 static int post_initial(
void) {
3454 if (_init ==
NULL)
return 0;
3456 if (post_initial_check_node_exists())
return -1;
3458 if (post_initial_ngrp_to_node())
return -1;
3460 if (post_initial_check_dup())
return -1;
3466 static int post_equation_check_node_exists(
void) {
3470 if (_mpc ==
NULL)
return 0;
3474 for (p = _mpc; p; p =
next) {
3486 for (i = 0; i < p->
neq; i++) {
3487 struct hecmw_io_mpcitem *item = &p->
item[i];
3508 static int post_equation_ngrp_to_node(
void) {
3509 int i, j, ignore, **node;
3512 if (_mpc ==
NULL)
return 0;
3516 for (p = _mpc; p; p =
next) {
3530 for (i = 0; i < p->
neq; i++) {
3531 struct hecmw_io_mpcitem *item = &p->
item[i];
3554 for (i = 1; i < p->
neq; i++) {
3555 struct hecmw_io_mpcitem *item = &p->
item[i];
3558 set_err(
HECMW_IO_E1021,
"%d node%s in %s, %d node%s in %s", nnode,
3559 (nnode != 0) ?
"s" :
"", p->
item[0].
ngrp, n,
3560 (n != 0) ?
"s" :
"", p->
item[i].
ngrp);
3572 for (i = 0; i < p->
neq; i++) {
3580 for (i = 0; i < nnode; i++) {
3582 if (new_mpc ==
NULL) {
3586 memcpy(new_mpc, p,
sizeof(*new_mpc));
3591 if (new_mpc ==
NULL) {
3596 for (j = 0; j < new_mpc->
neq; j++) {
3597 struct hecmw_io_mpcitem *item = &new_mpc->
item[j];
3598 item->
node = node[j][i];
3600 item->a = p->
item[j].
a;
3606 prev->
next = new_mpc;
3611 for (i = 0; i < p->
neq; i++) {
3625 static int post_equation_check_dup(
void) {
3629 if (_mpc ==
NULL)
return 0;
3632 for (p = _mpc; p; p = p->
next) {
3635 for (q = _mpc; q; q = q->
next) {
3637 for (i = 1; i < q->
neq; i++) {
3649 static int post_equation_add_elem(
void) {
3650 int i, j, mpc_id, elem_id, dof1, dof2, type;
3655 if (_mpc ==
NULL)
return 0;
3662 for (p = _mpc, mpc_id = 1; p; p = p->
next, mpc_id++) {
3664 for (j = 0; j < p->
neq - 1; j++) {
3666 for (i = j + 1; i < p->
neq; i++) {
3669 type = 900 + dof1 * 10 + dof2;
3682 elem->
mpc_matid = (j + 1) * 10 + (i + 1);
3695 static int post_equation(
void) {
3696 if (_mpc ==
NULL)
return 0;
3698 if (post_equation_check_node_exists())
return -1;
3699 if (post_equation_ngrp_to_node())
return -1;
3703 if (post_equation_add_elem())
return -1;
3708 static int post_section_check_exists(
void) {
3709 if (_sect ==
NULL) {
3716 static int post_section_check_egrp(
void) {
3720 for (p = _sect; p; p = p->
next) {
3760 set_err(
HECMW_IO_E1026,
"Only interface element allowed in EGRP %s",
3775 static int post_section_check_mat_exists(
void) {
3781 for (p = _sect; p; p = p->
next) {
3801 static int post_section(
void) {
3802 if (post_section_check_exists())
return -1;
3803 if (post_section_check_egrp())
return -1;
3804 if (post_section_check_mat_exists())
return -1;
3809 static int post_contact_check_grp(
void) {
3813 for (p = _contact; p; p = p->
next) {
3852 fprintf(stderr,
"ERROR: CONTACT_PAIR: TYPE=%d\n", p->
type);
3862 static int post_contact_convert_sgroup(
void)
3865 int elem_id, contact_id;
3870 for (p = _contact, contact_id = 1; p; p = p->
next, contact_id++) {
3872 int n_item, i, id, ret;
3882 if (n_item == 0)
continue;
3884 elem = (
int *) malloc(
sizeof(
int) * n_item);
3885 surf = (
int *) malloc(
sizeof(
int) * n_item);
3886 if (!elem || !surf) {
3893 int eid, sid, etype, surf_etype, surf_nnode, j;
3895 const int *surf_nodes;
3898 decode_surf_key(
id, &eid, &sid);
3902 etype = element->
type;
3910 for (j = 0; j < surf_nnode; j++) {
3911 nodes[j] = element->
node[surf_nodes[j] - 1];
3916 if (ptelem ==
NULL) {
3934 ret = snprintf(new_sgrp_name,
sizeof(new_sgrp_name),
"_PT_%s", sgrp->
name);
3935 if (ret >=
sizeof(new_sgrp_name)) {
3938 }
else if (HECMW_io_get_sgrp(new_sgrp_name) !=
NULL) {
3939 set_err(
HECMW_IO_E0003,
"Surface group name: %s", new_sgrp_name);
3956 static int post_contact(
void) {
3957 if (post_contact_check_grp())
return -1;
3958 if (post_contact_convert_sgroup())
return -1;
3966 if (dof < 1 || dof > 6)
return -1;
3971 if (name ==
NULL)
return 0;
3972 if (strncmp(
"HECMW", name, 5) == 0)
return 1;
4014 printf(
"ERROE:HECMW_HASHTABLE INIT \n");
4028 printf(
"ERROE:HECMW_HASHTABLE FINALIZE \n");
4043 if (post_node())
goto error;
4045 if (post_elem())
goto error;
4047 if (post_ngrp())
goto error;
4049 if (post_egrp())
goto error;
4051 if (post_sgrp())
goto error;
4053 if (post_remove_unused_node())
goto error;
4055 if (post_initial())
goto error;
4057 if (post_equation())
goto error;
4059 if (post_section())
goto error;
4061 if (post_contact())
goto error;
4079 if (setup_flags(
mesh))
goto error;
4081 if (setup_gridfile(
mesh))
goto error;
4083 if (setup_files(
mesh))
goto error;
4085 if (setup_header(
mesh))
goto error;
4087 if (setup_zero(
mesh))
goto error;
4089 if (setup_node(
mesh))
goto error;
4091 if (setup_init(
mesh))
goto error;
4093 if (setup_elem(
mesh))
goto error;
4095 if (setup_ngrp(
mesh))
goto error;
4097 if (setup_egrp(
mesh))
goto error;
4099 if (setup_sgrp(
mesh))
goto error;
4101 if (setup_pe(
mesh))
goto error;
4103 if (setup_adapt(
mesh))
goto error;
4105 if (setup_refine(
mesh))
goto error;
4107 if (setup_mpc(
mesh))
goto error;
4109 if (setup_amp(
mesh))
goto error;
4111 if (setup_mat(
mesh))
goto error;
4113 if (setup_sect(
mesh))
goto error;
4115 if (setup_mpc_sectid(
mesh))
goto error;
4117 if (setup_contact_sectid(
mesh))
goto error;
4119 if (setup_elem_check_sectid(
mesh))
goto error;
4121 if (setup_elem_mat(
mesh))
goto error;
4123 if (setup_mpc_reorder(
mesh))
goto error;
4125 if (setup_contact(
mesh))
goto error;