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) {
402 fprintf(fp,
"CONTACT PAIR:\n");
403 for (p = _contact; p; p = p->
next) {
404 fprintf(fp,
"NAME=%s, ", p->
name);
406 fprintf(fp,
"TYPE=NODE-SURF, ");
408 fprintf(fp,
"TYPE=SURF-SURF, ");
410 fprintf(fp,
"TYPE=NODE-ELEM, ");
414 fprintf(fp,
"END of CONTACT PAIR\n");
455 if (header ==
NULL)
return 0;
462 if (zero ==
NULL)
return 0;
469 if (node ==
NULL)
return 0;
477 if (elem ==
NULL)
return 0;
487 for (p = ngrp; p; p = q) {
499 for (p = egrp; p; p = q) {
511 for (p = sgrp; p; p = q) {
523 for (p = mpc; p; p = q) {
533 struct hecmw_io_amplitude_item *pp, *qq;
535 for (p = amp; p; p = q) {
537 for (pp = p->
item; pp; pp = qq) {
549 for (p = init; p; p = q) {
559 struct hecmw_io_matsubitem *pp, *qq;
561 for (p = mat; p; p = q) {
563 for (i = 0; i < p->
nitem; i++) {
579 for (p =
sect; p; p = q) {
587 if (system ==
NULL)
return 0;
596 for (p = contact; p; p = q) {
604 if (free_header(_head))
return -1;
605 if (free_zero(_zero))
return -1;
606 if (free_node(_node))
return -1;
607 if (free_elem(_elem))
return -1;
608 if (free_ngrp(_ngrp))
return -1;
609 if (free_egrp(_egrp))
return -1;
610 if (free_sgrp(_sgrp))
return -1;
611 if (free_mpc(_mpc))
return -1;
612 if (free_amp(_amp))
return -1;
613 if (free_init(_init))
return -1;
614 if (free_material(_mat))
return -1;
615 if (free_sect(_sect))
return -1;
616 if (free_system(_system))
return -1;
617 if (free_contact(_contact))
return -1;
624 if (gridfile ==
NULL) gridfile =
"";
625 snprintf(grid_filename,
sizeof(grid_filename),
"%s", 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 snprintf(p->
name,
sizeof(p->
name),
"%s", 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) {
759 static 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 TABLE PUT ERROR\n");
985 static 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 TABLE PUT ERROR\n");
1189 static int compare_node_id(
const void *a,
const void *b) {
1190 const int node_a = *(
const int *)a;
1191 const int node_b = *(
const int *)b;
1193 return (node_a > node_b) - (node_a < node_b);
1196 static int find_node_id(
const int *node_ids,
int n_node,
int node_id) {
1198 int right = n_node - 1;
1200 while (left <= right) {
1201 int center = left + (right - left) / 2;
1203 if (node_ids[center] < node_id) {
1205 }
else if (node_ids[center] > node_id) {
1215 int elem_id, i, j, n_source_node = 0, n_unique_node = 0;
1216 int max_source_node;
1217 int has_3dof_elem = 0;
1218 int *source_node =
NULL;
1238 if (n_source_node == 0 || !has_3dof_elem)
return 0;
1240 source_node =
HECMW_malloc(
sizeof(*source_node) * n_source_node);
1241 if (source_node ==
NULL) {
1257 for (j = 0; j < nnode; j++) source_node[i++] = elem->
node[j];
1261 qsort(source_node, n_source_node,
sizeof(*source_node), compare_node_id);
1262 for (i = 0; i < n_source_node; i++) {
1263 if (i == 0 || source_node[i] != source_node[i - 1]) {
1264 source_node[n_unique_node++] = source_node[i];
1268 max_source_node = global_node_ID_max;
1269 for (i = 0; i < n_unique_node; i++) {
1271 int dummy_node_id = max_source_node + i + 1;
1300 new_node =
HECMW_malloc(
sizeof(*new_node) * nnode * 2);
1301 if (new_node ==
NULL) {
1306 for (j = 0; j < nnode; j++) {
1307 int index = find_node_id(source_node, n_unique_node, elem->
node[j]);
1310 new_node[j] = elem->
node[j];
1311 new_node[nnode + j] = max_source_node + index + 1;
1314 elem->
node = new_node;
1315 elem->
type = new_type;
1322 static int HECMW_io_remove_node_in_ngrp(
int node) {
1326 for (p = _ngrp; p; p =
next) {
1410 if (prev_sgrp ==
NULL) {
1413 prev_sgrp->
next = p;
1418 for (i = 0; i < n_item; i++) {
1434 printf(
"HECMW HASH TABLE PUT ERROR\n");
1449 const struct hecmw_io_mpcitem *mpcitem,
1454 struct hecmw_io_mpcitem *item;
1460 if (mpcitem ==
NULL) {
1477 for (i = 0; i < neq; i++) {
1478 const struct hecmw_io_mpcitem *src = &mpcitem[i];
1479 struct hecmw_io_mpcitem *dst = &item[i];
1480 HECMW_assert((src->node == -1) ? (strlen(src->ngrp) > 0) : 1);
1483 snprintf(dst->ngrp,
sizeof(dst->ngrp),
"%s", src->ngrp);
1484 dst->node = src->node;
1485 dst->dof = src->dof;
1494 if (prev_mpc ==
NULL) {
1522 if (prev_sect ==
NULL) {
1525 prev_sect->
next = p;
1564 printf(
"HECMW HASH TABLE PUT ERROR\n");
1567 if (prev_mat ==
NULL) {
1570 prev_mat->
next = mat;
1580 if (header ==
NULL) {
1637 if (prev_contact ==
NULL) {
1640 prev_contact->
next = p;
1686 p = _head ? _head->
header :
"";
1700 "!ZERO is not defined; using %E as absolute zero, assuming "
1701 "input temperatures are in Celsius. Define !ZERO as 0.0 if "
1702 "they are in Kelvin\n",
1722 for (p = _init; p; p = p->
next) {
1742 for (p = _init; p; p = p->
next) {
1743 int lid = get_gid2lid_node(p->
node);
1761 for (p = _init; p; p = p->
next) {
1762 int lid = get_gid2lid_node(p->
node);
1968 for (j = 0; j < n; j++) {
1986 int i, j, nngrp, nnode;
2012 for (p = _ngrp; p; p = p->
next) {
2016 ngrp->
n_grp = nngrp;
2018 if (ngrp->
n_grp <= 0) {
2040 size =
sizeof(*ngrp->
grp_item) * nnode;
2049 for (i = 0, p = _ngrp; p; p = p->
next, i++) {
2056 ngrp->
grp_item[start + j] = get_gid2lid_node(nid);
2077 int i, j, negrp, nelem;
2102 for (p = _egrp; p; p = p->
next) {
2106 egrp->
n_grp = negrp;
2108 if (egrp->
n_grp <= 0) {
2130 size =
sizeof(*egrp->
grp_item) * nelem;
2139 for (i = 0, p = _egrp; p; p = p->
next, i++) {
2148 egrp->
grp_item[start + j] = get_gid2lid_elem(eid);
2170 int i, j, nsgrp, nelem;
2195 for (p = _sgrp; p; p = p->
next) {
2199 sgrp->
n_grp = nsgrp;
2201 if (sgrp->
n_grp <= 0) {
2223 size =
sizeof(*sgrp->
grp_item) * nelem * 2;
2232 for (i = 0, p = _sgrp; p; p = p->
next, i++) {
2239 decode_surf_key(
id, &eid, &sid);
2241 sgrp->
grp_item[start + j * 2] = get_gid2lid_elem(eid);
2242 sgrp->
grp_item[start + j * 2 + 1] = sid;
2262 int i, j, nmpc, nneq, start;
2290 for (p = _mpc; p; p = p->
next) {
2307 size =
sizeof(*mpc->
mpc_item) * nneq;
2315 size =
sizeof(*mpc->
mpc_dof) * nneq;
2323 size =
sizeof(*mpc->
mpc_val) * nneq;
2341 for (p = _mpc; p; p = p->
next) {
2346 for (j = 0; j < p->
neq; j++) {
2375 int i, j, namp, nitem, start;
2405 for (p = _amp; p; p = p->
next) {
2406 struct hecmw_io_amplitude_item *item;
2407 for (item = p->
item; item; item = item->
next) {
2457 size =
sizeof(*amp->
amp_val) * nitem;
2475 for (p = _amp; p; p = p->
next) {
2476 struct hecmw_io_amplitude_item *item;
2478 for (item = p->
item; item; item = item->
next) {
2485 for (item = p->
item, j = 0; item; item = item->
next, j++) {
2486 amp->
amp_val[start + j] = item->val;
2487 amp->
amp_table[start + j] = item->table;
2582 const char *egrp_name,
int sectid) {
2583 int i, eid, egid, start, end;
2599 for (i = start; i <= end; i++) {
2612 int i, nsect, nint, nreal, nmat;
2620 size =
sizeof(*sect);
2636 nsect = nint = nreal = nmat = 0;
2637 for (p = _sect; p; p = p->
next) {
2660 sect->n_sect = nsect;
2671 if (
sect->n_sect <= 0) {
2677 size =
sizeof(*
sect->sect_type) *
sect->n_sect;
2685 size =
sizeof(*
sect->sect_opt) *
sect->n_sect;
2693 size =
sizeof(*
sect->sect_mat_ID_index) * (
sect->n_sect + 1);
2695 if (
sect->sect_mat_ID_index ==
NULL) {
2702 size =
sizeof(*
sect->sect_mat_ID_item) * nmat;
2704 if (
sect->sect_mat_ID_item ==
NULL) {
2710 size =
sizeof(*
sect->sect_I_index) * (
sect->n_sect + 1);
2720 size =
sizeof(*
sect->sect_I_item) * nint;
2729 size =
sizeof(*
sect->sect_R_index) * (
sect->n_sect + 1);
2739 size =
sizeof(*
sect->sect_R_item) * nreal;
2748 sect->sect_I_index[0] = 0;
2749 sect->sect_R_index[0] = 0;
2750 sect->sect_mat_ID_index[0] = 0;
2751 for (i = 0, p = _sect; p; p = p->
next, i++) {
2752 int iidx =
sect->sect_I_index[i];
2753 int ridx =
sect->sect_R_index[i];
2756 sect->sect_I_index[i + 1] =
sect->sect_I_index[i] + 0;
2757 sect->sect_R_index[i + 1] =
sect->sect_R_index[i] + 1;
2761 sect->sect_I_index[i + 1] =
sect->sect_I_index[i] + 1;
2762 sect->sect_R_index[i + 1] =
sect->sect_R_index[i] + 1;
2768 sect->sect_I_index[i + 1] =
sect->sect_I_index[i] + 0;
2769 sect->sect_R_index[i + 1] =
sect->sect_R_index[i] + 7;
2779 sect->sect_I_index[i + 1] =
sect->sect_I_index[i] + 0;
2780 sect->sect_R_index[i + 1] =
sect->sect_R_index[i] + 4;
2791 sect->sect_mat_ID_index[i + 1] =
sect->sect_mat_ID_index[i] + 1;
2792 midx =
sect->sect_mat_ID_index[i];
2795 sect->sect_mat_ID_item[midx] =
2801 if (setup_sect_set_sectid(mesh, p->
egrp, i + 1))
return -1;
2835 int i, j, k, l, nmat,
nmatitem, nmatsubitem, nmattable;
2843 size =
sizeof(*mat);
2851 nmat = nmatitem = nmatsubitem = nmattable = 0;
2852 for (p = _mat; p; p = p->
next) {
2854 nmatitem += p->
nitem;
2855 for (i = 0; i < p->
nitem; i++) {
2856 struct hecmw_io_matsubitem *msi = p->
item[i].
subitem;
2875 if (mat->
n_mat <= 0) {
2913 size =
sizeof(*mat->
mat_val) * nmattable;
2921 size =
sizeof(*mat->
mat_temp) * nmattable;
2932 for (i = 0, p = _mat; p; p = p->
next, i++) {
2940 for (j = 0; j < p->
nitem; j++) {
2942 struct hecmw_io_matitem *item = &p->
item[j];
2943 struct hecmw_io_matsubitem *subitem = item->
subitem;
2948 for (subitem = item->subitem; subitem; subitem = subitem->next) {
2951 for (k = 0; k < item->nval; k++) {
2957 for (k = 0, subitem = item->subitem; subitem;
2958 subitem = subitem->next, k++) {
2959 for (l = 0; l < item->nval; l++) {
2965 mat->
mat_val[idx] = subitem->val[l];
2966 mat->
mat_temp[idx] = subitem->temp;
2982 int i, j, n, id, idx, *start, sectid, nmat, *matid;
3030 if (matid ==
NULL) {
3034 for (j = 0; j < n; j++) {
3035 matid[j] = start[j];
3037 mat[i].matid = matid;
3062 for (j = 0; j < mat[i].n; j++) {
3078 int i, npair, slave_gid, master_gid, orislave_sgid;
3088 if (cpair ==
NULL) {
3100 if (_contact ==
NULL) {
3107 for (p = _contact; p; p = p->
next) {
3114 size =
sizeof(*cpair->
name) * (cpair->
n_pair);
3122 size =
sizeof(*cpair->
type) * (cpair->
n_pair);
3154 for (p = _contact, i = 0; p; p = p->
next, i++) {
3223 static int post_remove_unused_node(
void) {
3233 if (HECMW_io_remove_node_in_ngrp(
id) < 0) {
3243 static int post_node(
void) {
3259 static int post_elem_check_node_existence(
void) {
3275 for (j = 0; j < ncon; j++) {
3289 static char *post_elem_make_matname(
int id,
char *buf,
int bufsize) {
3290 const char *
matname =
"HECMW-MAT";
3295 snprintf(buf, bufsize,
"%s%d",
matname,
id);
3300 static int post_elem_make_mat(
void) {
3305 struct hecmw_io_matitem *matitem;
3306 struct hecmw_io_matsubitem *matsubitem;
3310 if (p->nmatitem <= 0)
continue;
3319 if (matitem ==
NULL) {
3325 if (matsubitem ==
NULL) {
3330 matsubitem->val =
HECMW_malloc(
sizeof(*matsubitem->val) * p->nmatitem);
3331 if (matsubitem->val ==
NULL) {
3336 for (j = 0; j < p->nmatitem; j++) {
3337 matsubitem->val[j] = p->matitem[j];
3339 matsubitem->temp = 0.0;
3340 matsubitem->next =
NULL;
3343 matitem->nval = p->nmatitem;
3344 matitem->subitem = matsubitem;
3347 mat->
item = matitem;
3348 post_elem_make_matname(
id, name,
sizeof(name));
3349 snprintf(p->matname,
sizeof(p->matname),
"%s", name);
3350 snprintf(mat->
name,
sizeof(mat->
name),
"%s", name);
3358 static int post_elem(
void) {
3361 if (_elem ==
NULL) {
3371 if (post_elem_check_node_existence())
return -1;
3373 if (post_elem_make_mat())
return -1;
3378 static int post_ngrp(
void) {
3381 for (p = _ngrp; p; p = p->
next) {
3398 static int post_egrp(
void) {
3401 for (p = _egrp; p; p = p->
next) {
3419 static int post_sgrp(
void) {
3422 for (p = _sgrp; p; p = p->
next) {
3434 decode_surf_key(
id, &eid, &sid);
3438 if (element ==
NULL) {
3454 static int post_initial_check_node_exists(
void) {
3458 if (_init ==
NULL)
return 0;
3462 for (p = _init; p; p =
next) {
3464 if (p->
node == -1) {
3496 static int post_initial_ngrp_to_node(
void) {
3497 int i, nnode, ignore, *
node;
3501 if (_init ==
NULL)
return 0;
3505 for (p = _init; p; p = next) {
3507 if (p->
node != -1) {
3543 for (i = 0; i < nnode; i++) {
3545 if (new_init ==
NULL) {
3549 memcpy(new_init, p,
sizeof(*new_init));
3551 new_init->
node = node[i];
3556 prev->
next = new_init;
3567 static int post_initial_check_dup(
void) {
3572 if (_init ==
NULL)
return 0;
3577 for (p = _init; p; p = p->
next) {
3585 set_err(
HECMW_IO_E1018,
"Some nodes are initialized more than once");
3591 static int post_initial(
void) {
3592 if (_init ==
NULL)
return 0;
3594 if (post_initial_check_node_exists())
return -1;
3596 if (post_initial_ngrp_to_node())
return -1;
3598 if (post_initial_check_dup())
return -1;
3604 static int post_equation_check_node_exists(
void) {
3608 if (_mpc ==
NULL)
return 0;
3612 for (p = _mpc; p; p =
next) {
3624 for (i = 0; i < p->
neq; i++) {
3625 struct hecmw_io_mpcitem *item = &p->
item[i];
3646 static int post_equation_ngrp_to_node(
void) {
3647 int i, j, ignore, **node;
3650 if (_mpc ==
NULL)
return 0;
3654 for (p = _mpc; p; p =
next) {
3668 for (i = 0; i < p->
neq; i++) {
3669 struct hecmw_io_mpcitem *item = &p->
item[i];
3692 for (i = 1; i < p->
neq; i++) {
3693 struct hecmw_io_mpcitem *item = &p->
item[i];
3696 set_err(
HECMW_IO_E1021,
"%d node%s in %s, %d node%s in %s", nnode,
3697 (nnode != 0) ?
"s" :
"", p->
item[0].
ngrp, n,
3698 (n != 0) ?
"s" :
"", p->
item[i].
ngrp);
3710 for (i = 0; i < p->
neq; i++) {
3718 for (i = 0; i < nnode; i++) {
3720 if (new_mpc ==
NULL) {
3724 memcpy(new_mpc, p,
sizeof(*new_mpc));
3729 if (new_mpc ==
NULL) {
3734 for (j = 0; j < new_mpc->
neq; j++) {
3735 struct hecmw_io_mpcitem *item = &new_mpc->
item[j];
3736 item->
node = node[j][i];
3738 item->a = p->
item[j].
a;
3744 prev->
next = new_mpc;
3749 for (i = 0; i < p->
neq; i++) {
3763 static int post_equation_check_dup(
void) {
3767 if (_mpc ==
NULL)
return 0;
3770 for (p = _mpc; p; p = p->
next) {
3773 for (q = _mpc; q; q = q->
next) {
3775 for (i = 1; i < q->
neq; i++) {
3787 static int post_equation_add_elem(
void) {
3788 int i, j, mpc_id, elem_id, dof1, dof2, type;
3793 if (_mpc ==
NULL)
return 0;
3800 for (p = _mpc, mpc_id = 1; p; p = p->
next, mpc_id++) {
3802 for (j = 0; j < p->
neq - 1; j++) {
3804 for (i = j + 1; i < p->
neq; i++) {
3807 type = 900 + dof1 * 10 + dof2;
3820 elem->
mpc_matid = (j + 1) * 10 + (i + 1);
3833 static int post_equation(
void) {
3834 if (_mpc ==
NULL)
return 0;
3836 if (post_equation_check_node_exists())
return -1;
3837 if (post_equation_ngrp_to_node())
return -1;
3841 if (post_equation_add_elem())
return -1;
3846 static int post_section_check_exists(
void) {
3847 if (_sect ==
NULL) {
3854 static int post_section_check_egrp(
void) {
3858 for (p = _sect; p; p = p->
next) {
3898 set_err(
HECMW_IO_E1026,
"Only interface element allowed in EGRP %s",
3913 static int post_section_check_mat_exists(
void) {
3918 for (p = _sect; p; p = p->
next) {
3932 static int post_section(
void) {
3933 if (post_section_check_exists())
return -1;
3934 if (post_section_check_egrp())
return -1;
3935 if (post_section_check_mat_exists())
return -1;
3940 static int post_contact_check_grp(
void) {
3943 for (p = _contact; p; p = p->
next) {
3982 fprintf(stderr,
"ERROR: CONTACT_PAIR: TYPE=%d\n", p->
type);
3992 static int post_contact_convert_sgroup(
void)
3995 int elem_id, contact_id;
4000 for (p = _contact, contact_id = 1; p; p = p->
next, contact_id++) {
4002 int n_item, i, id, ret;
4012 if (n_item == 0)
continue;
4014 elem = (
int *) malloc(
sizeof(
int) * n_item);
4015 surf = (
int *) malloc(
sizeof(
int) * n_item);
4016 if (!elem || !surf) {
4023 int eid, sid, etype, surf_etype, surf_nnode, j;
4025 const int *surf_nodes;
4028 decode_surf_key(
id, &eid, &sid);
4032 etype = element->
type;
4040 for (j = 0; j < surf_nnode; j++) {
4041 nodes[j] = element->
node[surf_nodes[j] - 1];
4046 if (ptelem ==
NULL) {
4064 ret = snprintf(new_sgrp_name,
sizeof(new_sgrp_name),
"_PT_%s", sgrp->
name);
4065 if (ret >=
sizeof(new_sgrp_name)) {
4068 }
else if (HECMW_io_get_sgrp(new_sgrp_name) !=
NULL) {
4069 set_err(
HECMW_IO_E0003,
"Surface group name: %s", new_sgrp_name);
4086 static int post_contact(
void) {
4087 if (post_contact_check_grp())
return -1;
4088 if (post_contact_convert_sgroup())
return -1;
4096 if (dof < 1 || dof > 6)
return -1;
4101 if (name ==
NULL)
return 0;
4102 if (strncmp(
"HECMW", name, 5) == 0)
return 1;
4144 printf(
"ERROR:HECMW_HASHTABLE INIT \n");
4158 printf(
"ERROR:HECMW_HASHTABLE FINALIZE \n");
4173 if (post_node())
goto error;
4175 if (post_elem())
goto error;
4177 if (post_ngrp())
goto error;
4179 if (post_egrp())
goto error;
4181 if (post_sgrp())
goto error;
4183 if (post_remove_unused_node())
goto error;
4185 if (post_initial())
goto error;
4187 if (post_equation())
goto error;
4189 if (post_section())
goto error;
4191 if (post_contact())
goto error;
4209 if (setup_flags(
mesh))
goto error;
4211 if (setup_gridfile(
mesh))
goto error;
4213 if (setup_files(
mesh))
goto error;
4215 if (setup_header(
mesh))
goto error;
4217 if (setup_zero(
mesh))
goto error;
4219 if (setup_node(
mesh))
goto error;
4221 if (setup_init(
mesh))
goto error;
4223 if (setup_elem(
mesh))
goto error;
4225 if (setup_ngrp(
mesh))
goto error;
4227 if (setup_egrp(
mesh))
goto error;
4229 if (setup_sgrp(
mesh))
goto error;
4231 if (setup_pe(
mesh))
goto error;
4233 if (setup_adapt(
mesh))
goto error;
4235 if (setup_refine(
mesh))
goto error;
4237 if (setup_mpc(
mesh))
goto error;
4239 if (setup_amp(
mesh))
goto error;
4241 if (setup_mat(
mesh))
goto error;
4243 if (setup_sect(
mesh))
goto error;
4245 if (setup_mpc_sectid(
mesh))
goto error;
4247 if (setup_contact_sectid(
mesh))
goto error;
4249 if (setup_elem_check_sectid(
mesh))
goto error;
4251 if (setup_elem_mat(
mesh))
goto error;
4253 if (setup_mpc_reorder(
mesh))
goto error;
4255 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_33struct(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)
int HECMW_io_create_dummy_nodes(void)
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