FrontISTR  5.7.0
Large-scale structural analysis program with finit element method
hecmw_io_mesh.c
Go to the documentation of this file.
1 /*****************************************************************************
2  * Copyright (c) 2019 FrontISTR Commons
3  * This software is released under the MIT License, see LICENSE.txt
4  *****************************************************************************/
5 
6 #include <stdio.h>
7 #include <stdlib.h>
8 #include <errno.h>
9 #include "hecmw_util.h"
10 #include "hecmw_heclex.h"
11 #include "hecmw_io_hec.h"
12 #include "hecmw_io_mesh.h"
13 #include "hecmw_io_struct.h"
14 #include "hecmw_struct.h"
15 #include "hecmw_config.h"
16 #include "hecmw_system.h"
17 #include "hecmw_dist.h"
18 #include "hecmw_dist_print.h"
19 #include "hecmw_dist_free.h"
20 #include "hecmw_common.h"
21 #include "hecmw_reorder.h"
22 #include "hecmw_map_int.h"
23 #include "hecmw_set_int.h"
24 #include "hecmw_hash.h"
25 
26 #define HECMW_FLAG_VERSION 5
27 
28 static int global_node_ID_max = -1;
29 static int global_elem_ID_max = -1;
30 
31 /* temporary data structures */
32 static struct hecmw_io_header *_head;
33 static struct hecmw_io_initial *_init;
34 static struct hecmw_io_amplitude *_amp;
35 static struct hecmw_map_int *_node;
36 static struct hecmw_map_int *_elem;
37 static struct hecmw_io_egrp *_egrp;
38 static struct hecmw_io_ngrp *_ngrp;
39 static struct hecmw_io_sgrp *_sgrp;
40 static struct hecmw_io_mpc *_mpc;
41 static struct hecmw_io_material *_mat;
42 static struct hecmw_io_section *_sect;
43 static struct hecmw_system_param *_system;
44 static struct hecmw_io_zero *_zero;
45 static struct hecmw_io_contact *_contact;
46 
47 static char grid_filename[HECMW_FILENAME_LEN + 1] = "Unknown";
48 
49 /*----------------------------------------------------------------------------*/
50 
51 static void do_logging(int loglv, int msgno, const char *fmt, va_list ap) {
52  if (loglv == HECMW_LOG_ERROR) {
53  HECMW_set_verror(msgno, fmt, ap);
54  } else {
55  HECMW_print_vmsg(loglv, msgno, fmt, ap);
56  }
57 }
58 
59 static void set_err(int msgno, const char *fmt, ...) {
60  va_list ap;
61 
62  va_start(ap, fmt);
63  do_logging(HECMW_LOG_ERROR, msgno, fmt, ap);
64  va_end(ap);
65 }
66 
67 static void set_warn(int msgno, const char *fmt, ...) {
68  va_list ap;
69 
70  va_start(ap, fmt);
71  do_logging(HECMW_LOG_WARN, msgno, fmt, ap);
72  va_end(ap);
73 }
74 
75 /*----------------------------------------------------------------------------*/
76 
77 static int get_gid2lid_node(int gid) {
78  size_t clocal;
79  int ret;
80  HECMW_assert(_node);
81  ret = HECMW_map_int_key2local(_node, gid, &clocal);
83  return clocal + 1;
84 }
85 
86 static int get_gid2lid_elem(int gid) {
87  size_t clocal;
88  int ret;
89  HECMW_assert(_elem);
90  ret = HECMW_map_int_key2local(_elem, gid, &clocal);
92  return clocal + 1;
93 }
94 
95 /*----------------------------------------------------------------------------*/
96 
97 static int make_surf_key(int elem_id, int surf_id) {
98  /* return elem_id*10 + surf_id - 1; */
99  if (surf_id < 4) {
100  return elem_id * 3 + surf_id - 1;
101  } else {
102  return -(elem_id * 3 + surf_id - 4);
103  }
104 }
105 
106 static void decode_surf_key(int key, int *elem_id, int *surf_id) {
107  /* *elem_id = key/10; */
108  /* *surf_id = key%10 + 1; */
109  if (key > 0) {
110  *elem_id = key / 3;
111  *surf_id = key % 3 + 1;
112  } else {
113  *elem_id = (-key) / 3;
114  *surf_id = (-key) % 3 + 4;
115  }
116 }
117 
118 static int clear(void) {
119  if (HECMW_io_free_all()) return -1;
120 
121  strcpy(grid_filename, "Unknown");
122 
123  _head = NULL;
124  _init = NULL;
125  _amp = NULL;
126  _node = NULL;
127  _elem = NULL;
128  _egrp = NULL;
129  _ngrp = NULL;
130  _sgrp = NULL;
131  _mpc = NULL;
132  _mat = NULL;
133  _sect = NULL;
134  _system = NULL;
135  _zero = NULL;
136  _contact = NULL;
137 
138  return 0;
139 }
140 
141 /*------------------------------------------------------------------------------
142  print functions
143 */
144 
145 static void print_header(FILE *fp) {
146  HECMW_assert(fp);
147 
148  fprintf(fp, "HEADER:\n");
149  fprintf(fp, "%s\n", _head ? _head->header : "none");
150  fprintf(fp, "END of HEADER\n");
151 }
152 
153 static void print_amp(FILE *fp) {
154  struct hecmw_io_amplitude *p;
155 
156  HECMW_assert(fp);
157 
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,
162  p->type_def, p->type_time, p->type_val);
163  for (item = p->item; item; item = item->next) {
164  fprintf(fp, "VAL: %E, T: %E\n", item->val, item->table);
165  }
166  }
167  fprintf(fp, "END of AMPLITUDE\n");
168 }
169 
170 static void print_init(FILE *fp) {
171  struct hecmw_io_initial *p;
172 
173  HECMW_assert(fp);
174 
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,
178  (*p->ngrp != '\0') ? p->ngrp : "none", p->val);
179  }
180  fprintf(fp, "END of INITIAL CONDITION\n");
181 }
182 
183 static void print_node(FILE *fp) {
184  int seq, id;
185  struct hecmw_io_node *p;
186 
187  HECMW_assert(fp);
188  HECMW_assert(_node);
189 
190  fprintf(fp, "NODE:\n");
191 
192  seq = 1;
194  while (HECMW_map_int_iter_next(_node, &id, (void **)&p))
195  fprintf(fp, "Node %d: ID=%d: %E %E %E\n", seq++, id, p->x, p->y, p->z);
196 
197  fprintf(fp, "END of NODE\n");
198 }
199 
200 static void print_elem(FILE *fp) {
201  int seq, n, id, j;
202  struct hecmw_io_element *p;
203 
204  HECMW_assert(fp);
205  HECMW_assert(_elem);
206 
207  fprintf(fp, "ELEMENT:\n");
208 
209  seq = 1;
211  while (HECMW_map_int_iter_next(_elem, &id, (void **)&p)) {
212  fprintf(fp, "Element %d: ID=%d: TYPE=%d: ", seq++, id, p->type);
213  n = HECMW_get_max_node(p->type);
214  for (j = 0; j < n; j++) {
215  fprintf(fp, "%d ", p->node[j]);
216  }
217  fprintf(fp, ": MATITEM: ");
218  if (p->nmatitem == 0) {
219  fprintf(fp, "none");
220  } else {
221  for (j = 0; j < p->nmatitem; j++) {
222  fprintf(fp, "%E ", p->matitem[j]);
223  }
224  }
225  fprintf(fp, "\n");
226  }
227 
228  fprintf(fp, "END of ELEMENT\n");
229 }
230 
231 static void print_ngrp(FILE *fp) {
232  int i;
233  const int NITEM = 10;
234  struct hecmw_io_ngrp *p;
235 
236  HECMW_assert(fp);
237 
238  fprintf(fp, "NGROUP:\n");
239  for (p = _ngrp; p; p = p->next) {
240  int id;
241  fprintf(fp, "NAME=%s:\n", p->name);
243  for (i = 0; HECMW_set_int_iter_next(p->node, &id); i++) {
244  fprintf(fp, "%d %c", id, (i + 1) % NITEM ? ' ' : '\n');
245  }
246  if (i % NITEM) {
247  fprintf(fp, "\n");
248  }
249  }
250  fprintf(fp, "END of NGROUP\n");
251 }
252 
253 static void print_egrp(FILE *fp) {
254  int i;
255  const int NITEM = 10;
256  struct hecmw_io_egrp *p;
257 
258  HECMW_assert(fp);
259 
260  fprintf(fp, "EGROUP:\n");
261  for (p = _egrp; p; p = p->next) {
262  int id;
263  fprintf(fp, "NAME=%s:\n", p->name);
265  for (i = 0; HECMW_set_int_iter_next(p->elem, &id); i++) {
266  fprintf(fp, "%d %c", id, (i + 1) % NITEM ? ' ' : '\n');
267  }
268  if (i % NITEM) {
269  fprintf(fp, "\n");
270  }
271  }
272  fprintf(fp, "END of EGROUP\n");
273 }
274 
275 static void print_sgrp(FILE *fp) {
276  int i;
277  const int NITEM = 10;
278  struct hecmw_io_sgrp *p;
279 
280  HECMW_assert(fp);
281 
282  fprintf(fp, "SGROUP:\n");
283  for (p = _sgrp; p; p = p->next) {
284  int id, eid, sid;
285  fprintf(fp, "NAME=%s:\n", p->name);
287  for (i = 0; HECMW_set_int_iter_next(p->item, &id); i++) {
288  decode_surf_key(id, &eid, &sid);
289  fprintf(fp, "%d %d %c", eid, sid, (i + 1) % NITEM ? ' ' : '\n');
290  }
291  if (i % NITEM) {
292  fprintf(fp, "\n");
293  }
294  }
295  fprintf(fp, "END of SGROUP\n");
296 }
297 
298 static void print_sect(FILE *fp) {
299  struct hecmw_io_section *p;
300 
301  HECMW_assert(fp);
302 
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,
306  p->material, p->composite, p->secopt);
307  if (p->type == HECMW_SECT_TYPE_SOLID) {
308  fprintf(fp, "TYPE: SOLID, THICKNESS: %E\n", p->sect.solid.thickness);
309  } else if (p->type == HECMW_SECT_TYPE_SHELL) {
310  fprintf(fp, "TYPE: SHELL, THICKNESS: %E, INTEGPOINTS: %d\n",
312  } else if (p->type == HECMW_SECT_TYPE_BEAM) {
313  fprintf(fp, "TYPE: BEAM, Reference vector: %E %E %E, Iyy: %E\n",
314  p->sect.beam.vxyz[0], p->sect.beam.vxyz[1], p->sect.beam.vxyz[2],
315  p->sect.beam.Iyy);
316  } else if (p->type == HECMW_SECT_TYPE_INTERFACE) {
317  fprintf(fp,
318  "TYPE: INTERFACE, THICKNESS: %E, "
319  "GAPCON: %E, GAPRAD1: %E, GAPRAD2: %E\n",
322  }
323  }
324  fprintf(fp, "END of SECTION\n");
325 }
326 
327 static void print_mat(FILE *fp) {
328  int i, j;
329  struct hecmw_io_material *p;
330 
331  HECMW_assert(fp);
332 
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]);
344  }
345  fprintf(fp, "TEMP: %E\n", p->temp);
346  }
347  }
348  }
349  fprintf(fp, "END of MATERIAL\n");
350 }
351 
352 static void print_mpc(FILE *fp) {
353  int i;
354  struct hecmw_io_mpc *p;
355 
356  HECMW_assert(fp);
357 
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,
365  item->a);
366  }
367  }
368  fprintf(fp, "END of EQUATION\n");
369 }
370 
371 static void print_system(FILE *fp) {
372  struct hecmw_system_param param;
373 
374  HECMW_assert(fp);
375 
376  if (_system) {
377  param = *_system;
378  } else {
379  memset(&param, 0, sizeof(param));
380  }
381 
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");
387 }
388 
389 static void print_zero(FILE *fp) {
390  HECMW_assert(fp);
391 
392  fprintf(fp, "ZERO:\n");
393  fprintf(fp, "%E\n", _zero ? _zero->zero : 0.0);
394  fprintf(fp, "END of ZERO\n");
395 }
396 
397 static void print_contact(FILE *fp) {
398  int i;
399  struct hecmw_io_contact *p;
400 
401  HECMW_assert(fp);
402 
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, ");
408  } else if (p->type == HECMW_CONTACT_TYPE_SURF_SURF) {
409  fprintf(fp, "TYPE=SURF-SURF, ");
410  } else if (p->type == HECMW_CONTACT_TYPE_NODE_ELEM) {
411  fprintf(fp, "TYPE=NODE-ELEM, ");
412  }
413  fprintf(fp, "SLAVE_GRP=%s, MASTER_GRP=%s\n", p->slave_grp, p->master_grp);
414  }
415  fprintf(fp, "END of CONTACT PAIR\n");
416 }
417 
418 void HECMW_io_print_all(FILE *fp) {
419  HECMW_assert(fp);
420 
421  print_header(fp);
422  fprintf(fp, "\n");
423  print_zero(fp);
424  fprintf(fp, "\n");
425  print_init(fp);
426  fprintf(fp, "\n");
427  print_amp(fp);
428  fprintf(fp, "\n");
429  print_system(fp);
430  fprintf(fp, "\n");
431  print_node(fp);
432  fprintf(fp, "\n");
433  print_elem(fp);
434  fprintf(fp, "\n");
435  print_ngrp(fp);
436  fprintf(fp, "\n");
437  print_egrp(fp);
438  fprintf(fp, "\n");
439  print_sgrp(fp);
440  fprintf(fp, "\n");
441  print_sect(fp);
442  fprintf(fp, "\n");
443  print_mat(fp);
444  fprintf(fp, "\n");
445  print_mpc(fp);
446  fprintf(fp, "\n");
447  print_contact(fp);
448  fprintf(fp, "\n");
449 }
450 
451 /*------------------------------------------------------------------------------
452  free
453 */
454 
455 static int free_header(struct hecmw_io_header *header) {
456  if (header == NULL) return 0;
457 
458  HECMW_free(header);
459  return 0;
460 }
461 
462 static int free_zero(struct hecmw_io_zero *zero) {
463  if (zero == NULL) return 0;
464 
465  HECMW_free(zero);
466  return 0;
467 }
468 
469 static int free_node(struct hecmw_map_int *node) {
470  if (node == NULL) return 0;
471 
473  HECMW_free(node);
474  return 0;
475 }
476 
477 static int free_elem(struct hecmw_map_int *elem) {
478  if (elem == NULL) return 0;
479 
481  HECMW_free(elem);
482  return 0;
483 }
484 
485 static int free_ngrp(struct hecmw_io_ngrp *ngrp) {
486  struct hecmw_io_ngrp *p, *q;
487 
488  for (p = ngrp; p; p = q) {
489  q = p->next;
491  HECMW_free(p->node);
492  HECMW_free(p);
493  }
494  return 0;
495 }
496 
497 static int free_egrp(struct hecmw_io_egrp *egrp) {
498  struct hecmw_io_egrp *p, *q;
499 
500  for (p = egrp; p; p = q) {
501  q = p->next;
503  HECMW_free(p->elem);
504  HECMW_free(p);
505  }
506  return 0;
507 }
508 
509 static int free_sgrp(struct hecmw_io_sgrp *sgrp) {
510  struct hecmw_io_sgrp *p, *q;
511 
512  for (p = sgrp; p; p = q) {
513  q = p->next;
515  HECMW_free(p->item);
516  HECMW_free(p);
517  }
518  return 0;
519 }
520 
521 static int free_mpc(struct hecmw_io_mpc *mpc) {
522  struct hecmw_io_mpc *p, *q;
523 
524  for (p = mpc; p; p = q) {
525  q = p->next;
526  HECMW_free(p->item);
527  HECMW_free(p);
528  }
529  return 0;
530 }
531 
532 static int free_amp(struct hecmw_io_amplitude *amp) {
533  struct hecmw_io_amplitude *p, *q;
534  struct hecmw_io_amplitude_item *pp, *qq;
535 
536  for (p = amp; p; p = q) {
537  q = p->next;
538  for (pp = p->item; pp; pp = qq) {
539  qq = pp->next;
540  HECMW_free(pp);
541  }
542  HECMW_free(p);
543  }
544  return 0;
545 }
546 
547 static int free_init(struct hecmw_io_initial *init) {
548  struct hecmw_io_initial *p, *q;
549 
550  for (p = init; p; p = q) {
551  q = p->next;
552  HECMW_free(p);
553  }
554  return 0;
555 }
556 
557 static int free_material(struct hecmw_io_material *mat) {
558  int i;
559  struct hecmw_io_material *p, *q;
560  struct hecmw_io_matsubitem *pp, *qq;
561 
562  for (p = mat; p; p = q) {
563  q = p->next;
564  for (i = 0; i < p->nitem; i++) {
565  for (pp = p->item[i].subitem; pp; pp = qq) {
566  qq = pp->next;
567  HECMW_free(pp->val);
568  HECMW_free(pp);
569  }
570  }
571  HECMW_free(p->item);
572  HECMW_free(p);
573  }
574  return 0;
575 }
576 
577 static int free_sect(struct hecmw_io_section *sect) {
578  struct hecmw_io_section *p, *q;
579 
580  for (p = sect; p; p = q) {
581  q = p->next;
582  HECMW_free(p);
583  }
584  return 0;
585 }
586 
587 static int free_system(struct hecmw_system_param *system) {
588  if (system == NULL) return 0;
589 
590  HECMW_free(system);
591  return 0;
592 }
593 
594 static int free_contact(struct hecmw_io_contact *contact) {
595  struct hecmw_io_contact *p, *q;
596 
597  for (p = contact; p; p = q) {
598  q = p->next;
599  HECMW_free(p);
600  }
601  return 0;
602 }
603 
604 int HECMW_io_free_all(void) {
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;
619  return 0;
620 }
621 
622 /*----------------------------------------------------------------------------*/
623 
624 int HECMW_io_set_gridfile(char *gridfile) {
625  if (gridfile == NULL) gridfile = "";
626 
627  strcpy(grid_filename, gridfile);
628  return 0;
629 }
630 
631 struct hecmw_io_amplitude *HECMW_io_add_amp(const char *name, int definition,
632  int time, int value, double val,
633  double t) {
634  static struct hecmw_io_amplitude *prev_amp = NULL;
635  struct hecmw_io_amplitude *p;
636  struct hecmw_io_amplitude_item *item;
637 
638  if (name == NULL) {
639  set_err(HECMW_ALL_E0101, "HECMW_io_add_amp(): name");
640  return NULL;
641  }
642  if (strlen(name) > HECMW_NAME_LEN) {
643  set_err(HECMW_ALL_E0101, "HECMW_io_add_amp(): name too long");
644  return NULL;
645  }
646 
647  if (prev_amp != NULL && strcmp(prev_amp->name, name) == 0) {
648  p = prev_amp;
649  } else {
650  p = HECMW_malloc(sizeof(*p));
651  if (p == NULL) {
652  set_err(errno, "");
653  return NULL;
654  }
655  strcpy(p->name, name);
656  p->next = NULL;
657  p->item = NULL;
658  p->last = NULL;
659 
660  if (prev_amp == NULL) {
661  _amp = p;
662  } else {
663  prev_amp->next = p;
664  }
665  prev_amp = p;
666  }
667  p->type_def = definition;
668  p->type_time = time;
669  p->type_val = value;
670 
671  item = HECMW_malloc(sizeof(*item));
672  if (item == NULL) {
673  set_err(errno, "");
674  return NULL;
675  }
676  item->next = NULL;
677  item->val = val;
678  item->table = t;
679 
680  if (p->last == NULL) {
681  p->item = item;
682  p->last = item;
683  } else {
684  p->last->next = item;
685  p->last = item;
686  }
687 
688  return p;
689 }
690 
692  struct hecmw_io_initial *p;
693 
694  for (p = _init; p; p = p->next) {
695  if (p->node == node) return p;
696  }
697  return NULL;
698 }
699 
701  const char *ngrp, double val) {
702  static struct hecmw_io_initial *prev_init = NULL;
703  struct hecmw_io_initial *p;
704 
705  if (ngrp == NULL && node <= 0) {
706  set_err(HECMW_ALL_E0101, "HECMW_io_add_initial(): ngrp,node");
707  return NULL;
708  }
709 
710  p = HECMW_malloc(sizeof(*p));
711  if (p == NULL) {
712  set_err(errno, "");
713  return NULL;
714  }
715 
716  if (ngrp) {
717  strcpy(p->ngrp, ngrp);
718  }
719  p->type = type;
720  p->node = ngrp ? -1 : node;
721  p->val = val;
722  p->next = NULL;
723 
724  if (prev_init == NULL) {
725  _init = p;
726  } else {
727  prev_init->next = p;
728  }
729  prev_init = p;
730 
731  return p;
732 }
733 
735  HECMW_assert(_elem);
736 
737  return (struct hecmw_io_element *)HECMW_map_int_get(_elem, id);
738 }
739 
741  HECMW_assert(_elem);
742 
743  return HECMW_map_int_nval(_elem);
744 }
745 
747  int id, max = 0;
748  struct hecmw_io_element *val;
749 
750  HECMW_assert(_elem);
751 
753  while (HECMW_map_int_iter_next(_elem, &id, (void **)&val)) {
754  if (id > max) {
755  max = id;
756  }
757  }
758  return max;
759 }
760 
761 static void free_io_elem(void *io_elem) {
762  struct hecmw_io_element *p;
763  p = (struct hecmw_io_element *)io_elem;
764  HECMW_free(p->node);
765  HECMW_free(p->matitem);
766  HECMW_free(p);
767 }
768 
769 struct hecmw_io_element *HECMW_io_add_elem(int id, int type, int *node,
770  int nmatitem, double *matitem) {
771  int nnode;
772  int *new_node;
773  double *new_matitem;
774  struct hecmw_io_element *new_elem;
775 
776  if (node == NULL) {
777  set_err(HECMW_ALL_E0101, "HECMW_io_add_elem(): node");
778  return NULL;
779  }
780  if (nmatitem < 0) {
781  set_err(HECMW_ALL_E0101, "HECMW_io_add_elem(): nmatitem");
782  return NULL;
783  }
784 
785  /* get # of connectivity */
786  nnode = HECMW_get_max_node(type);
787  HECMW_assert(nnode > 0);
789 
790  new_node = HECMW_malloc(sizeof(*new_node) * nnode);
791  if (new_node == NULL) {
792  set_err(errno, "");
793  return NULL;
794  }
795  memcpy(new_node, node, sizeof(*new_node) * nnode);
796 
797  /* material */
798  new_matitem = NULL;
799  if (nmatitem > 0) {
800  new_matitem = HECMW_malloc(sizeof(*new_matitem) * nmatitem);
801  if (new_matitem == NULL) {
802  set_err(errno, "");
803  return NULL;
804  }
805  memcpy(new_matitem, matitem, sizeof(*new_matitem) * nmatitem);
806  }
807 
808  new_elem = HECMW_malloc(sizeof(*new_elem));
809  if (new_elem == NULL) {
810  set_err(errno, "");
811  return NULL;
812  }
813  new_elem->type = type;
814  new_elem->node = new_node;
815  new_elem->nmatitem = nmatitem;
816  new_elem->matitem = new_matitem;
817  new_elem->mpc_matid = -1;
818  new_elem->mpc_sectid = -1;
819 
820  if (_elem == NULL) {
821  _elem = (struct hecmw_map_int *)HECMW_malloc(sizeof(struct hecmw_map_int));
822  if (_elem == NULL) {
823  set_err(errno, "");
824  return NULL;
825  }
826  if (HECMW_map_int_init(_elem, free_io_elem)) {
827  set_err(errno, "");
828  return NULL;
829  }
830  }
831 
832  if (HECMW_map_int_add(_elem, id, new_elem)) {
833  set_err(errno, "");
834  return NULL;
835  }
836 
837  if (id > global_elem_ID_max) {
838  global_elem_ID_max = id;
839  }
840 
841  return new_elem;
842 }
843 
844 struct hecmw_io_egrp *HECMW_io_get_egrp(const char *name) {
845  extern hecmw_hash_p *hash_eg;
846 
847  return (struct hecmw_io_egrp *)hecmw_hash_p_get(hash_eg, name);
848 }
849 
850 struct hecmw_io_id_array *HECMW_io_get_elem_in_egrp(const char *name) {
851  int nval, i, eid;
852  struct hecmw_io_egrp *egrp;
853  struct hecmw_io_id_array *id = NULL;
854 
855  egrp = HECMW_io_get_egrp(name);
856  if (egrp == NULL) goto error;
857 
858  nval = HECMW_set_int_nval(_egrp->elem);
859  HECMW_assert(nval > 0);
860 
861  id = HECMW_malloc(sizeof(*id));
862  if (id == NULL) {
863  set_err(errno, "");
864  goto error;
865  }
866 
867  id->id = HECMW_malloc(sizeof(*id->id) * nval);
868  if (id->id == NULL) {
869  set_err(errno, "");
870  goto error;
871  }
872 
873  id->n = nval;
874 
876  for (i = 0; HECMW_set_int_iter_next(_egrp->elem, &eid); i++) {
877  id->id[i] = eid;
878  }
879 
880  HECMW_assert(i == nval);
881 
882  return id;
883 
884 error:
885  if (id) {
886  if (id->id) HECMW_free(id->id);
887  HECMW_free(id);
888  }
889  return NULL;
890 }
891 
892 int HECMW_io_add_egrp(const char *name, int nelem, int *elem) {
893  int i;
894  static struct hecmw_io_egrp *cp = NULL;
895  struct hecmw_io_egrp *p;
896  extern hecmw_hash_p *hash_eg;
897 
898  if (name == NULL) {
899  set_err(HECMW_ALL_E0101, "HECMW_io_add_egrp(): name");
900  return -1;
901  }
902  if (elem == NULL) {
903  set_err(HECMW_ALL_E0101, "HECMW_io_add_egrp(): elem");
904  return -1;
905  }
906  if (nelem <= 0) {
907  set_err(HECMW_ALL_E0101, "HECMW_io_add_egrp(): nelem");
908  return -1;
909  }
910 
916  p = (struct hecmw_io_egrp *)hecmw_hash_p_get(hash_eg, name);
917  if (p == NULL) {
918  p = HECMW_malloc(sizeof(struct hecmw_io_egrp));
919  if (p == NULL) {
920  set_err(errno, "");
921  return -1;
922  }
923  strcpy(p->name, name);
924  p->elem =
925  (struct hecmw_set_int *)HECMW_malloc(sizeof(struct hecmw_set_int));
926  if (p->elem == NULL) {
927  set_err(errno, "");
928  return -1;
929  }
930  if (HECMW_set_int_init(p->elem)) {
931  set_err(errno, "");
932  return -1;
933  }
934  p->next = NULL;
935 
936  if (cp != NULL) {
937  cp->next = p;
938  } else {
939  _egrp = p;
940  }
941  cp = p;
942  }
943 
944  for (i = 0; i < nelem; i++) {
945  if (HECMW_set_int_add(p->elem, elem[i])) {
946  set_err(errno, "");
947  return -1;
948  }
949  }
950 
951  if (HECMW_set_int_is_empty(p->elem)) {
952  /* new group && ignored all */
953  HECMW_assert(nelem == 0);
955  HECMW_free(p->elem);
956  HECMW_free(p);
957  return 0;
958  }
959 
960  if (hecmw_hash_p_put(hash_eg, name, (void *)p) == 0) {
961  printf("HECMW HASH TABLE PUT ERROR\n");
962  return -1;
963  }
964 
965  /* if(cp != NULL) { */
966  /* cp->next = p; */
967  /* } else if (strcmp(cp->name, name) != 0) { */
968  /* _egrp = p; */
969  /* } */
970  /* cp = p; */
971 
972  return nelem;
973 }
974 
976  HECMW_assert(_node);
977 
978  return (struct hecmw_io_node *)HECMW_map_int_get(_node, id);
979 }
980 
982  HECMW_assert(_node);
983 
984  return HECMW_map_int_nval(_node);
985 }
986 
987 static void free_io_node(void *io_node) {
988  struct hecmw_io_node *p;
989  p = (struct hecmw_io_node *)io_node;
990  /* nothing to do on members */
991  HECMW_free(p);
992 }
993 
994 struct hecmw_io_node *HECMW_io_add_node(int id, double x, double y, double z) {
995  struct hecmw_io_node *new_node;
996 
997  new_node = HECMW_malloc(sizeof(*new_node));
998  if (new_node == NULL) {
999  set_err(errno, "");
1000  return NULL;
1001  }
1002  new_node->x = x;
1003  new_node->y = y;
1004  new_node->z = z;
1005 
1006  if (_node == NULL) {
1007  _node = (struct hecmw_map_int *)HECMW_malloc(sizeof(struct hecmw_map_int));
1008  if (_node == NULL) {
1009  set_err(errno, "");
1010  return NULL;
1011  }
1012  if (HECMW_map_int_init(_node, free_io_node)) {
1013  set_err(errno, "");
1014  return NULL;
1015  }
1016  }
1017 
1018  if (HECMW_map_int_add(_node, id, new_node)) {
1019  set_err(errno, "");
1020  return NULL;
1021  }
1022 
1023  if (id > global_node_ID_max) {
1024  global_node_ID_max = id;
1025  }
1026 
1027  return new_node;
1028 }
1029 
1030 int HECMW_io_get_nnode_in_ngrp(const char *name) {
1031  struct hecmw_io_ngrp *p;
1032 
1033  if (name == NULL) {
1034  set_err(HECMW_ALL_E0101, "HECMW_io_get_nnode_in_ngrp(): name");
1035  return -1;
1036  }
1037 
1038  for (p = _ngrp; p; p = p->next) {
1039  if (strcmp(p->name, name) == 0) break;
1040  }
1041  if (p == NULL) return 0;
1042 
1043  return HECMW_set_int_nval(p->node);
1044 }
1045 
1046 /*
1047 int
1048 HECMW_io_remove_node(int id)
1049 {
1050  return HECMW_map_int_del(_node, id);
1051 }
1052 */
1053 
1054 struct hecmw_io_ngrp *HECMW_io_get_ngrp(const char *name) {
1055  /* struct hecmw_io_ngrp *p; */
1056  extern hecmw_hash_p *hash_ng;
1057 
1058  if (name == NULL) {
1059  set_err(HECMW_ALL_E0101, "HECMW_io_get_ngrp(): name");
1060  return NULL;
1061  }
1062 
1063  /* for(p=_ngrp; p; p=p->next) { */
1064  /* if(strcmp(p->name, name) == 0) break; */
1065  /* } */
1066  /* return p; */
1067 
1068  return (struct hecmw_io_ngrp *)hecmw_hash_p_get(hash_ng, name);
1069 }
1070 
1072  int n, i, nid;
1073  struct hecmw_io_ngrp *ngrp;
1074  struct hecmw_io_id_array *id;
1075 
1076  if (name == NULL) {
1077  set_err(HECMW_ALL_E0101, "HECMW_io_get_node_in_ngrp(): name");
1078  return NULL;
1079  }
1080 
1081  ngrp = HECMW_io_get_ngrp(name);
1082  if (ngrp == NULL) return NULL;
1083 
1084  id = HECMW_malloc(sizeof(*id));
1085  if (id == NULL) {
1086  set_err(errno, "");
1087  return NULL;
1088  }
1089 
1090  n = HECMW_set_int_nval(ngrp->node);
1091  HECMW_assert(n > 0);
1092 
1093  id->id = HECMW_malloc(sizeof(*id->id) * n);
1094  if (id->id == NULL) {
1095  set_err(errno, "");
1096  return NULL;
1097  }
1098 
1099  id->n = n;
1101  for (i = 0; HECMW_set_int_iter_next(ngrp->node, &nid); i++) {
1102  id->id[i] = nid;
1103  }
1104 
1105  HECMW_assert(i == n);
1106 
1107  return id;
1108 }
1109 
1110 int HECMW_io_add_ngrp(const char *name, int nnode, int *node) {
1111  int i;
1112  static struct hecmw_io_ngrp *prev_ngrp = NULL;
1113  struct hecmw_io_ngrp *p;
1114  extern hecmw_hash_p *hash_ng;
1115 
1116  if (name == NULL) {
1117  set_err(HECMW_ALL_E0101, "HECMW_io_add_ngrp(): name");
1118  return -1;
1119  }
1120  if (node == NULL) {
1121  set_err(HECMW_ALL_E0101, "HECMW_io_add_ngrp(): node");
1122  return -1;
1123  }
1124  if (nnode <= 0) {
1125  set_err(HECMW_ALL_E0101, "HECMW_io_add_ngrp(): nnode");
1126  return -1;
1127  }
1128 
1129  p = (struct hecmw_io_ngrp *)hecmw_hash_p_get(hash_ng, name);
1130 
1131  /* if(prev_ngrp != NULL && strcmp(prev_ngrp->name, name) == 0) { */
1132  /* p = prev_ngrp; */
1133  /* } else { */
1134  if (p == NULL) {
1135  p = HECMW_malloc(sizeof(*p));
1136  if (p == NULL) {
1137  set_err(errno, "");
1138  return -1;
1139  }
1140  strcpy(p->name, name);
1141  p->node =
1142  (struct hecmw_set_int *)HECMW_malloc(sizeof(struct hecmw_set_int));
1143  if (p->node == NULL) {
1144  set_err(errno, "");
1145  return -1;
1146  }
1147  if (HECMW_set_int_init(p->node)) {
1148  set_err(errno, "");
1149  return -1;
1150  }
1151  p->next = NULL;
1152 
1153  if (prev_ngrp == NULL) {
1154  _ngrp = p;
1155  } else {
1156  prev_ngrp->next = p;
1157  }
1158  prev_ngrp = p;
1159  }
1160 
1161  for (i = 0; i < nnode; i++) {
1162  if (HECMW_set_int_add(p->node, node[i])) {
1163  set_err(errno, "");
1164  return -1;
1165  }
1166  }
1167 
1168  if (HECMW_set_int_is_empty(p->node)) {
1169  /* new group && ignored all */
1171  HECMW_free(p->node);
1172  HECMW_free(p);
1173  return 0;
1174  }
1175 
1176  if (hecmw_hash_p_put(hash_ng, name, (void *)p) == 0) {
1177  printf("HECMW HASH TABLE PUT ERROR\n");
1178  return -1;
1179  }
1180 
1181  /* if(prev_ngrp == NULL) { */
1182  /* _ngrp = p; */
1183  /* } else if(strcmp(prev_ngrp->name, name) != 0) { */
1184  /* prev_ngrp->next = p; */
1185  /* } */
1186  /* prev_ngrp = p; */
1187 
1188  return nnode;
1189 }
1190 
1191 static int HECMW_io_remove_node_in_ngrp(int node) {
1192  struct hecmw_io_ngrp *p, *q, *next;
1193 
1194  q = NULL;
1195  for (p = _ngrp; p; p = next) {
1197  if (HECMW_set_int_is_empty(p->node)) {
1198  /* no node in this group */
1199  if (q == NULL) {
1200  _ngrp = p->next;
1201  } else {
1202  q->next = p->next;
1203  }
1204  next = p->next;
1206  HECMW_free(p->node);
1207  HECMW_free(p);
1208  } else {
1209  q = p;
1210  next = p->next;
1211  }
1212  }
1213  return 0;
1214 }
1215 
1216 static struct hecmw_io_sgrp *HECMW_io_get_sgrp(const char *name) {
1217  /* struct hecmw_io_sgrp *p; */
1218  extern hecmw_hash_p *hash_sg;
1219 
1220  if (name == NULL) {
1221  set_err(HECMW_ALL_E0101, "HECMW_io_get_sgrp(): name");
1222  return NULL;
1223  }
1224 
1225  /* for(p=_sgrp; p; p=p->next) { */
1226  /* if(strcmp(p->name, name) == 0) break; */
1227  /* } */
1228  /* return p; */
1229 
1230  return (struct hecmw_io_sgrp *)hecmw_hash_p_get(hash_sg, name);
1231 }
1232 
1233 int HECMW_io_add_sgrp(const char *name, int n_item, int *elem, int *surf) {
1234  int i;
1235  static struct hecmw_io_sgrp *prev_sgrp = NULL;
1236  struct hecmw_io_sgrp *p;
1237  extern hecmw_hash_p *hash_sg;
1238 
1239  if (name == NULL) {
1240  set_err(HECMW_ALL_E0101, "HECMW_add_sgrp(): name");
1241  return -1;
1242  }
1243  if (elem == NULL) {
1244  set_err(HECMW_ALL_E0101, "HECMW_add_sgrp(): elem");
1245  return -1;
1246  }
1247  if (surf == NULL) {
1248  set_err(HECMW_ALL_E0101, "HECMW_add_sgrp(): surf");
1249  return -1;
1250  }
1251  if (n_item <= 0) {
1252  set_err(HECMW_ALL_E0101, "HECMW_add_sgrp(): n_item");
1253  return -1;
1254  }
1255 
1256  p = (struct hecmw_io_sgrp *)hecmw_hash_p_get(hash_sg, name);
1257  if (p == NULL) {
1258  /* if(prev_sgrp != NULL && strcmp(prev_sgrp->name, name) == 0) { */
1259  /* p = prev_sgrp; */
1260  /* } else { */
1261  p = HECMW_malloc(sizeof(*p));
1262  if (p == NULL) {
1263  set_err(errno, "");
1264  return -1;
1265  }
1266  strcpy(p->name, name);
1267  p->item =
1268  (struct hecmw_set_int *)HECMW_malloc(sizeof(struct hecmw_set_int));
1269  if (p->item == NULL) {
1270  set_err(errno, "");
1271  return -1;
1272  }
1273  if (HECMW_set_int_init(p->item)) {
1274  set_err(errno, "");
1275  return -1;
1276  }
1277  p->next = NULL;
1278 
1279  if (prev_sgrp == NULL) {
1280  _sgrp = p;
1281  } else {
1282  prev_sgrp->next = p;
1283  }
1284  prev_sgrp = p;
1285  }
1286 
1287  for (i = 0; i < n_item; i++) {
1288  if (HECMW_set_int_add(p->item, make_surf_key(elem[i], surf[i]))) {
1289  set_err(errno, "");
1290  return -1;
1291  }
1292  }
1293 
1294  if (HECMW_set_int_is_empty(p->item)) {
1295  /* new group && ignored all */
1297  HECMW_free(p->item);
1298  HECMW_free(p);
1299  return 0;
1300  }
1301 
1302  if (hecmw_hash_p_put(hash_sg, name, (void *)p) == 0) {
1303  printf("HECMW HASH TABLE PUT ERROR\n");
1304  return -1;
1305  }
1306 
1307  /* if(prev_sgrp == NULL) { */
1308  /* _sgrp = p; */
1309  /* } else if(strcmp(prev_sgrp->name, name) != 0) { */
1310  /* prev_sgrp->next = p; */
1311  /* } */
1312  /* prev_sgrp = p; */
1313 
1314  return n_item;
1315 }
1316 
1318  const struct hecmw_io_mpcitem *mpcitem,
1319  double cnst) {
1320  int i;
1321  static struct hecmw_io_mpc *prev_mpc = NULL;
1322  struct hecmw_io_mpc *p;
1323  struct hecmw_io_mpcitem *item;
1324 
1325  if (neq <= 0) {
1326  set_err(HECMW_ALL_E0101, "HECMW_add_mpc(): neq");
1327  return NULL;
1328  }
1329  if (mpcitem == NULL) {
1330  set_err(HECMW_ALL_E0101, "HECMW_add_mpc(): mpcitem");
1331  return NULL;
1332  }
1333 
1334  p = HECMW_malloc(sizeof(*p));
1335  if (p == NULL) {
1336  set_err(errno, "");
1337  return NULL;
1338  }
1339 
1340  item = HECMW_malloc(sizeof(*item) * neq);
1341  if (item == NULL) {
1342  set_err(errno, "");
1343  return NULL;
1344  }
1345 
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);
1350  HECMW_assert((src->node != -1) ? (src->node > 0) : 1);
1352  strcpy(dst->ngrp, src->ngrp);
1353  dst->node = src->node;
1354  dst->dof = src->dof;
1355  dst->a = src->a;
1356  }
1357 
1358  p->neq = neq;
1359  p->cnst = cnst;
1360  p->item = item;
1361  p->next = NULL;
1362 
1363  if (prev_mpc == NULL) {
1364  _mpc = p;
1365  } else {
1366  prev_mpc->next = p;
1367  }
1368  prev_mpc = p;
1369 
1370  return p;
1371 }
1372 
1374  static struct hecmw_io_section *prev_sect = NULL;
1375  struct hecmw_io_section *p;
1376 
1377  if (sect == NULL) {
1378  set_err(HECMW_ALL_E0101, "HECMW_io_add_sect(): sect");
1379  return NULL;
1380  }
1381 
1382  p = HECMW_malloc(sizeof(*p));
1383  if (p == NULL) {
1384  set_err(errno, "");
1385  return NULL;
1386  }
1387 
1388  *p = *sect;
1389  p->next = NULL;
1390 
1391  if (prev_sect == NULL) {
1392  _sect = p;
1393  } else {
1394  prev_sect->next = p;
1395  }
1396  prev_sect = p;
1397 
1398  return p;
1399 }
1400 
1402  struct hecmw_io_material *p;
1403  extern hecmw_hash_p *hash_mat;
1404 
1405  if (name == NULL) {
1406  set_err(HECMW_ALL_E0101, "HECMW_io_get_mat(): name");
1407  return NULL;
1408  }
1409 
1411 
1412  /* for(p=_mat; p; p=p->next) {
1413  if(strcmp(p->name, name) == 0) break;
1414  }*/
1415 
1416  return p;
1417 }
1418 
1420  struct hecmw_io_material *mat) {
1421  static struct hecmw_io_material *prev_mat = NULL;
1422  struct hecmw_io_material *p;
1423  extern hecmw_hash_p *hash_mat;
1424 
1425  if (mat == NULL) {
1426  set_err(HECMW_ALL_E0101, "HECMW_io_add_mat(): mat");
1427  return NULL;
1428  }
1429 
1431  if (p == NULL) {
1432  if (hecmw_hash_p_put(hash_mat, name, (void *)mat) == 0) {
1433  printf("HECMW HASH TABLE PUT ERROR\n");
1434  return NULL;
1435  } else {
1436  if (prev_mat == NULL) {
1437  _mat = mat;
1438  } else {
1439  prev_mat->next = mat;
1440  }
1441  prev_mat = mat;
1442  }
1443  }
1444 
1445  return mat;
1446 }
1447 
1448 void HECMW_io_set_header(struct hecmw_io_header *header) {
1449  if (header == NULL) {
1450  set_err(HECMW_ALL_E0101, "HECMW_io_set_header(): header");
1451  return;
1452  }
1453 
1454  if (_head) {
1455  HECMW_free(_head);
1456  set_warn(HECMW_IO_W1010, "");
1457  }
1458  _head = header;
1459 }
1460 
1462  return _system;
1463 }
1464 
1466  HECMW_free(_system);
1467  _system = system; /* allow NULL */
1468 }
1469 
1470 void HECMW_io_set_zero(struct hecmw_io_zero *zero) {
1471  if (_zero) {
1472  HECMW_free(_zero);
1473  set_warn(HECMW_IO_W1011, "");
1474  }
1475  _zero = zero;
1476 }
1477 
1479  const char *slave_grp,
1480  const char *master_grp) {
1481  static struct hecmw_io_contact *prev_contact = NULL;
1482  struct hecmw_io_contact *p;
1483 
1484  if (slave_grp == NULL) {
1485  set_err(HECMW_ALL_E0101, "HECMW_io_add_contact(): slave_grp");
1486  return NULL;
1487  }
1488  if (master_grp == NULL) {
1489  set_err(HECMW_ALL_E0101, "HECMW_io_add_contact(): master_grp");
1490  return NULL;
1491  }
1492 
1493  p = (struct hecmw_io_contact *)HECMW_malloc(sizeof(*p));
1494  if (p == NULL) {
1495  set_err(HECMW_ALL_E0101, "HECMW_io_add_contact(): contact");
1496  return NULL;
1497  }
1498 
1499  strcpy(p->name, name);
1500  p->type = type;
1501  strcpy(p->slave_grp, slave_grp);
1502  strcpy(p->slave_orisgrp, slave_grp);
1503  strcpy(p->master_grp, master_grp);
1504  p->next = NULL;
1505 
1506  if (prev_contact == NULL) {
1507  _contact = p;
1508  } else {
1509  prev_contact->next = p;
1510  }
1511  prev_contact = p;
1512 
1513  return p;
1514 }
1515 
1516 /*------------------------------------------------------------------------------
1517  convert to hecmwST_local_mesh
1518 */
1519 
1520 static int setup_flags(struct hecmwST_local_mesh *mesh) {
1521  HECMW_assert(mesh);
1522 
1523  mesh->hecmw_flag_adapt = 0;
1524  mesh->hecmw_flag_initcon = 0;
1529 
1530  return 0;
1531 }
1532 
1533 static int setup_gridfile(struct hecmwST_local_mesh *mesh) {
1534  HECMW_assert(mesh);
1535 
1536  strcpy(mesh->gridfile, grid_filename);
1537 
1538  return 0;
1539 }
1540 
1541 static int setup_files(struct hecmwST_local_mesh *mesh) {
1542  HECMW_assert(mesh);
1543 
1544  mesh->hecmw_n_file = 0;
1545  mesh->files = NULL;
1546 
1547  return 0;
1548 }
1549 
1550 static int setup_header(struct hecmwST_local_mesh *mesh) {
1551  char *p;
1552 
1553  HECMW_assert(mesh);
1554 
1555  p = _head ? _head->header : "";
1556  strcpy(mesh->header, p);
1557 
1558  return 0;
1559 }
1560 
1561 static int setup_zero(struct hecmwST_local_mesh *mesh) {
1562  HECMW_assert(mesh);
1563 
1564  mesh->zero_temp = 0.0; /* default value */
1565  if (_zero) {
1566  mesh->zero_temp = _zero->zero;
1567  }
1568 
1569  return 0;
1570 }
1571 
1572 static int setup_init(struct hecmwST_local_mesh *mesh) {
1573  int i, n;
1574  size_t size;
1575  struct hecmw_io_initial *p;
1576 
1577  HECMW_assert(mesh);
1578  HECMW_assert(mesh->n_node > 0);
1579 
1580  /* initialize */
1583 
1584  n = 0;
1585  for (p = _init; p; p = p->next) {
1586  n++;
1587  }
1588  HECMW_log(HECMW_LOG_DEBUG, "setup_init: n = %d", n);
1589 
1590  if (n == 0) {
1591  mesh->hecmw_flag_initcon = 0;
1592  return 0;
1593  }
1594  mesh->hecmw_flag_initcon = 1;
1595 
1596  /* allocate index initialized with 0 */
1598  HECMW_calloc(mesh->n_node + 1, sizeof(*mesh->node_init_val_index));
1599  if (mesh->node_init_val_index == NULL) {
1600  set_err(errno, "");
1601  return -1;
1602  }
1603 
1604  /* set index to 1 where initial condition is specified */
1605  for (p = _init; p; p = p->next) {
1606  int lid = get_gid2lid_node(p->node);
1607  mesh->node_init_val_index[lid] = 1;
1608  }
1609 
1610  /* integrate index */
1611  for (i = 0; i < mesh->n_node; i++) {
1613  }
1614 
1615  /* allocate item */
1616  size = sizeof(*mesh->node_init_val_item) * n;
1618  if (mesh->node_init_val_item == NULL) {
1619  set_err(errno, "");
1620  return -1;
1621  }
1622 
1623  /* put values into correct places */
1624  for (p = _init; p; p = p->next) {
1625  int lid = get_gid2lid_node(p->node);
1626  int index = mesh->node_init_val_index[lid] - 1;
1627  mesh->node_init_val_item[index] = p->val;
1628  }
1629 
1630  return 0;
1631 }
1632 
1633 static int setup_node(struct hecmwST_local_mesh *mesh) {
1634  int i, id;
1635  size_t size;
1636  struct hecmw_io_node *p;
1637 
1638  HECMW_assert(mesh);
1639 
1640  /* initiallize */
1641  mesh->n_node = 0;
1642  mesh->nn_internal = 0;
1644  mesh->node_ID = NULL;
1646  mesh->node = NULL;
1647  mesh->n_dof = 0;
1648  mesh->n_dof_grp = 0;
1649  mesh->n_dof_tot = 0;
1651  mesh->node_dof_item = NULL;
1653  mesh->node_val_item = NULL;
1654 
1655  /* n_node */
1657  if (mesh->n_node == 0) {
1658  return 0;
1659  }
1660 
1661  /* n_node_gross */
1663 
1664  /* nn_middle */
1665  mesh->nn_middle = mesh->n_node;
1666 
1667  /* nn_internal */
1669 
1670  /* node_internal_list */
1671  size = sizeof(*mesh->node_internal_list) * mesh->nn_internal;
1673  if (mesh->node_internal_list == NULL) {
1674  set_err(errno, "");
1675  return -1;
1676  }
1677  /* node_ID */
1678  size = sizeof(*mesh->node_ID) * mesh->n_node * 2;
1679  mesh->node_ID = HECMW_malloc(size);
1680  if (mesh->node_ID == NULL) {
1681  set_err(errno, "");
1682  return -1;
1683  }
1684 
1685  /* global_node_ID */
1686  size = sizeof(*mesh->global_node_ID) * mesh->n_node;
1687  mesh->global_node_ID = HECMW_malloc(size);
1688  if (mesh->global_node_ID == NULL) {
1689  set_err(errno, "");
1690  return -1;
1691  }
1692 
1693  /* node */
1694  size = sizeof(*mesh->node) * mesh->n_node * 3;
1695  mesh->node = HECMW_malloc(size);
1696  if (mesh->node == NULL) {
1697  set_err(errno, "");
1698  return -1;
1699  }
1700 
1701  /* set node_internal_list, node_ID, global_node_ID, node */
1702  HECMW_map_int_iter_init(_node);
1703  for (i = 0; HECMW_map_int_iter_next(_node, &id, (void **)&p); i++) {
1704  mesh->node_internal_list[i] = i + 1;
1705  mesh->node_ID[2 * i] = i + 1;
1706  mesh->node_ID[2 * i + 1] = 0;
1707  mesh->global_node_ID[i] = id;
1708  mesh->node[3 * i] = p->x;
1709  mesh->node[3 * i + 1] = p->y;
1710  mesh->node[3 * i + 2] = p->z;
1711  }
1712 
1713  HECMW_assert(i == mesh->n_node);
1714 
1715  return 0;
1716 }
1717 
1718 static int setup_elem(struct hecmwST_local_mesh *mesh) {
1719  int i, j, n, id;
1720  size_t size, ncon;
1721  struct hecmw_io_element *p;
1722 
1723  HECMW_assert(mesh);
1724 
1725  /* initialize */
1726  mesh->n_elem = 0;
1727  mesh->ne_internal = 0;
1729  mesh->elem_ID = NULL;
1733  mesh->elem_type = NULL;
1734  mesh->n_elem_type = 0;
1737  mesh->section_ID = NULL;
1738  mesh->n_elem_mat_ID = 0;
1744  mesh->elem_val_item = NULL;
1745 
1746  /* n_elem */
1748  HECMW_assert(mesh->n_elem > 0);
1749 
1750  /* n_elem_gross */
1752 
1753  /* ne_internal */
1755 
1756  /* elem_internal_list */
1757  size = sizeof(*mesh->elem_internal_list) * mesh->ne_internal;
1759  if (mesh->elem_internal_list == NULL) {
1760  set_err(errno, "");
1761  return -1;
1762  }
1763 
1764  /* elem_ID */
1765  size = sizeof(*mesh->elem_ID) * mesh->n_elem * 2;
1766  mesh->elem_ID = HECMW_malloc(size);
1767  if (mesh->elem_ID == NULL) {
1768  set_err(errno, "");
1769  return -1;
1770  }
1771 
1772  /* global_elem_ID */
1773  size = sizeof(*mesh->global_elem_ID) * mesh->n_elem;
1774  mesh->global_elem_ID = HECMW_malloc(size);
1775  if (mesh->global_elem_ID == NULL) {
1776  set_err(errno, "");
1777  return -1;
1778  }
1779 
1780  /* elem_type */
1781  size = sizeof(*mesh->elem_type) * mesh->n_elem;
1782  mesh->elem_type = HECMW_malloc(size);
1783  if (mesh->elem_type == NULL) {
1784  set_err(errno, "");
1785  return -1;
1786  }
1787 
1788  /* elem_node_index */
1789  size = sizeof(*mesh->elem_node_index) * (mesh->n_elem + 1);
1791  if (mesh->elem_node_index == NULL) {
1792  set_err(errno, "");
1793  return -1;
1794  }
1795 
1796  /* count total # of connectivity and set elem_node_index */
1797  ncon = 0;
1798  mesh->elem_node_index[0] = 0;
1799 
1800  HECMW_map_int_iter_init(_elem);
1801  for (i = 0; HECMW_map_int_iter_next(_elem, &id, (void **)&p); i++) {
1802  n = HECMW_get_max_node(p->type);
1803 
1804  HECMW_assert(n > 0);
1805  ncon += n;
1806  HECMW_assert(i + 1 <= mesh->n_elem);
1807  mesh->elem_node_index[i + 1] = mesh->elem_node_index[i] + n;
1808  HECMW_assert(mesh->elem_node_index[i + 1] <= ncon);
1809  }
1810 
1811  HECMW_assert(i == mesh->n_elem);
1813 
1814  /* elem_node_item */
1815  size = sizeof(*mesh->elem_node_item) * ncon;
1816  mesh->elem_node_item = HECMW_malloc(size);
1817  if (mesh->elem_node_item == NULL) {
1818  set_err(errno, "");
1819  return -1;
1820  }
1821 
1822  /* set elem_ID, global_elem_ID, elem_internal_list, elem_type */
1823  HECMW_map_int_iter_init(_elem);
1824  for (i = 0; HECMW_map_int_iter_next(_elem, &id, (void **)&p); i++) {
1825  int start;
1826 
1827  /* connectivity */
1828  n = mesh->elem_node_index[i + 1] - mesh->elem_node_index[i];
1829  start = mesh->elem_node_index[i];
1830  for (j = 0; j < n; j++) {
1831  HECMW_assert(start + j <= mesh->elem_node_index[mesh->n_elem]);
1832  mesh->elem_node_item[start + j] = get_gid2lid_node(p->node[j]);
1833  }
1834 
1835  mesh->elem_ID[2 * i] = i + 1;
1836  mesh->elem_ID[2 * i + 1] = 0;
1837  mesh->global_elem_ID[i] = id;
1838  mesh->elem_internal_list[i] = i + 1;
1839  mesh->elem_type[i] = p->type;
1840  }
1841 
1842  HECMW_assert(i == mesh->n_elem);
1843 
1844  return 0;
1845 }
1846 
1847 static int setup_ngrp(struct hecmwST_local_mesh *mesh) {
1848  int i, j, nngrp, nnode;
1849  size_t size;
1850  struct hecmwST_node_grp *ngrp;
1851  struct hecmw_io_ngrp *p;
1852 
1853  HECMW_assert(mesh);
1854 
1855  ngrp = HECMW_malloc(sizeof(*ngrp));
1856  if (ngrp == NULL) {
1857  set_err(errno, "");
1858  return -1;
1859  }
1860 
1861  /* initialize */
1862  ngrp->n_grp = 0;
1863  ngrp->n_bc = 0;
1864  ngrp->grp_name = NULL;
1865  ngrp->grp_index = NULL;
1866  ngrp->grp_item = NULL;
1867  ngrp->bc_grp_ID = NULL;
1868  ngrp->bc_grp_type = NULL;
1869  ngrp->bc_grp_index = NULL;
1870  ngrp->bc_grp_dof = NULL;
1871  ngrp->bc_grp_val = NULL;
1872 
1873  nngrp = nnode = 0;
1874  for (p = _ngrp; p; p = p->next) {
1875  nnode += HECMW_set_int_nval(p->node);
1876  nngrp++;
1877  }
1878  ngrp->n_grp = nngrp;
1879 
1880  if (ngrp->n_grp <= 0) {
1881  mesh->node_group = ngrp;
1882  return 0;
1883  }
1884 
1885  /* grp_name */
1886  size = sizeof(*ngrp->grp_name) * ngrp->n_grp;
1887  ngrp->grp_name = HECMW_malloc(size);
1888  if (ngrp->grp_name == NULL) {
1889  set_err(errno, "");
1890  return -1;
1891  }
1892 
1893  /* grp_index */
1894  size = sizeof(*ngrp->grp_index) * (ngrp->n_grp + 1);
1895  ngrp->grp_index = HECMW_malloc(size);
1896  if (ngrp->grp_index == NULL) {
1897  set_err(errno, "");
1898  return -1;
1899  }
1900 
1901  /* grp_item */
1902  size = sizeof(*ngrp->grp_item) * nnode;
1903  ngrp->grp_item = HECMW_malloc(size);
1904  if (ngrp->grp_item == NULL) {
1905  set_err(errno, "");
1906  return -1;
1907  }
1908 
1909  /* set */
1910  ngrp->grp_index[0] = 0;
1911  for (i = 0, p = _ngrp; p; p = p->next, i++) {
1912  int start = ngrp->grp_index[i], nid;
1913 
1915  for (j = 0; HECMW_set_int_iter_next(p->node, &nid); j++) {
1916  HECMW_assert(start + j < nnode);
1917 
1918  ngrp->grp_item[start + j] = get_gid2lid_node(nid);
1919 
1920  HECMW_assert(ngrp->grp_item[start + j] > 0);
1921  }
1922 
1923  ngrp->grp_index[i + 1] = ngrp->grp_index[i] + j;
1924  ngrp->grp_name[i] = HECMW_strdup(p->name);
1925  if (ngrp->grp_name[i] == NULL) {
1926  set_err(errno, "");
1927  return -1;
1928  }
1929  }
1930 
1931  HECMW_assert(ngrp->grp_index[ngrp->n_grp] == nnode);
1932 
1933  mesh->node_group = ngrp;
1934 
1935  return 0;
1936 }
1937 
1938 static int setup_egrp(struct hecmwST_local_mesh *mesh) {
1939  int i, j, negrp, nelem;
1940  size_t size;
1941  struct hecmwST_elem_grp *egrp;
1942  struct hecmw_io_egrp *p;
1943 
1944  HECMW_assert(mesh);
1945 
1946  egrp = HECMW_malloc(sizeof(*egrp));
1947  if (egrp == NULL) {
1948  set_err(errno, "");
1949  return -1;
1950  }
1951 
1952  /* initialize */
1953  egrp->n_grp = 0;
1954  egrp->n_bc = 0;
1955  egrp->grp_name = NULL;
1956  egrp->grp_index = NULL;
1957  egrp->grp_item = NULL;
1958  egrp->bc_grp_ID = NULL;
1959  egrp->bc_grp_type = NULL;
1960  egrp->bc_grp_index = NULL;
1961  egrp->bc_grp_val = NULL;
1962 
1963  negrp = nelem = 0;
1964  for (p = _egrp; p; p = p->next) {
1965  nelem += HECMW_set_int_nval(p->elem);
1966  negrp++;
1967  }
1968  egrp->n_grp = negrp;
1969 
1970  if (egrp->n_grp <= 0) {
1971  mesh->elem_group = egrp;
1972  return 0;
1973  }
1974 
1975  /* grp_name */
1976  size = sizeof(*egrp->grp_name) * egrp->n_grp;
1977  egrp->grp_name = HECMW_malloc(size);
1978  if (egrp->grp_name == NULL) {
1979  set_err(errno, "");
1980  return -1;
1981  }
1982 
1983  /* grp_index */
1984  size = sizeof(*egrp->grp_index) * (egrp->n_grp + 1);
1985  egrp->grp_index = HECMW_malloc(size);
1986  if (egrp->grp_index == NULL) {
1987  set_err(errno, "");
1988  return -1;
1989  }
1990 
1991  /* grp_item */
1992  size = sizeof(*egrp->grp_item) * nelem;
1993  egrp->grp_item = HECMW_malloc(size);
1994  if (egrp->grp_item == NULL) {
1995  set_err(errno, "");
1996  return -1;
1997  }
1998 
1999  /* set */
2000  egrp->grp_index[0] = 0;
2001  for (i = 0, p = _egrp; p; p = p->next, i++) {
2002  int eid;
2003 
2005  for (j = 0; HECMW_set_int_iter_next(p->elem, &eid); j++) {
2006  int start = egrp->grp_index[i];
2007 
2008  HECMW_assert(start + j < nelem);
2009 
2010  egrp->grp_item[start + j] = get_gid2lid_elem(eid);
2011 
2012  HECMW_assert(egrp->grp_item[start + j] > 0);
2013  }
2014 
2015  egrp->grp_index[i + 1] = egrp->grp_index[i] + j;
2016  egrp->grp_name[i] = HECMW_strdup(p->name);
2017 
2018  if (egrp->grp_name[i] == NULL) {
2019  set_err(errno, "");
2020  return -1;
2021  }
2022  }
2023 
2024  HECMW_assert(egrp->grp_index[egrp->n_grp] == nelem);
2025 
2026  mesh->elem_group = egrp;
2027 
2028  return 0;
2029 }
2030 
2031 static int setup_sgrp(struct hecmwST_local_mesh *mesh) {
2032  int i, j, nsgrp, nelem;
2033  size_t size;
2034  struct hecmwST_surf_grp *sgrp;
2035  struct hecmw_io_sgrp *p;
2036 
2037  HECMW_assert(mesh);
2038 
2039  sgrp = HECMW_malloc(sizeof(*sgrp));
2040  if (sgrp == NULL) {
2041  set_err(errno, "");
2042  return -1;
2043  }
2044 
2045  /* initialize */
2046  sgrp->n_grp = 0;
2047  sgrp->n_bc = 0;
2048  sgrp->grp_name = NULL;
2049  sgrp->grp_index = NULL;
2050  sgrp->grp_item = NULL;
2051  sgrp->bc_grp_ID = NULL;
2052  sgrp->bc_grp_type = NULL;
2053  sgrp->bc_grp_index = NULL;
2054  sgrp->bc_grp_val = NULL;
2055 
2056  nsgrp = nelem = 0;
2057  for (p = _sgrp; p; p = p->next) {
2058  nelem += HECMW_set_int_nval(p->item);
2059  nsgrp++;
2060  }
2061  sgrp->n_grp = nsgrp;
2062 
2063  if (sgrp->n_grp <= 0) {
2064  mesh->surf_group = sgrp;
2065  return 0;
2066  }
2067 
2068  /* grp_name */
2069  size = sizeof(*sgrp->grp_name) * sgrp->n_grp;
2070  sgrp->grp_name = HECMW_malloc(size);
2071  if (sgrp->grp_name == NULL) {
2072  set_err(errno, "");
2073  return -1;
2074  }
2075 
2076  /* grp_index */
2077  size = sizeof(*sgrp->grp_index) * (sgrp->n_grp + 1);
2078  sgrp->grp_index = HECMW_malloc(size);
2079  if (sgrp->grp_index == NULL) {
2080  set_err(errno, "");
2081  return -1;
2082  }
2083 
2084  /* grp_item */
2085  size = sizeof(*sgrp->grp_item) * nelem * 2;
2086  sgrp->grp_item = HECMW_malloc(size);
2087  if (sgrp->grp_item == NULL) {
2088  set_err(errno, "");
2089  return -1;
2090  }
2091 
2092  /* set */
2093  sgrp->grp_index[0] = 0;
2094  for (i = 0, p = _sgrp; p; p = p->next, i++) {
2095  int start = sgrp->grp_index[i] * 2, id;
2096 
2098  for (j = 0; HECMW_set_int_iter_next(p->item, &id); j++) {
2099  int eid, sid;
2100 
2101  decode_surf_key(id, &eid, &sid);
2102 
2103  sgrp->grp_item[start + j * 2] = get_gid2lid_elem(eid);
2104  sgrp->grp_item[start + j * 2 + 1] = sid;
2105  }
2106 
2107  sgrp->grp_index[i + 1] = sgrp->grp_index[i] + j;
2108  sgrp->grp_name[i] = HECMW_strdup(p->name);
2109 
2110  if (sgrp->grp_name[i] == NULL) {
2111  set_err(errno, "");
2112  return -1;
2113  }
2114  }
2115 
2116  HECMW_assert(sgrp->grp_index[sgrp->n_grp] == nelem);
2117 
2118  mesh->surf_group = sgrp;
2119 
2120  return 0;
2121 }
2122 
2123 static int setup_mpc(struct hecmwST_local_mesh *mesh) {
2124  int i, j, nmpc, nneq, start;
2125  size_t size;
2126  struct hecmwST_mpc *mpc;
2127  struct hecmw_io_mpc *p;
2128 
2129  HECMW_assert(mesh);
2130 
2131  mpc = HECMW_malloc(sizeof(*mpc));
2132  if (mpc == NULL) {
2133  set_err(errno, "");
2134  goto error;
2135  }
2136 
2137  mpc->n_mpc = 0;
2138  mpc->mpc_index = NULL;
2139  mpc->mpc_item = NULL;
2140  mpc->mpc_dof = NULL;
2141  mpc->mpc_val = NULL;
2142  mpc->mpc_const = NULL;
2143 
2144  if (_mpc == NULL) {
2145  mesh->mpc = mpc;
2146  return 0;
2147  }
2148 
2149  /* count total # of mpc, neq */
2150  nmpc = 0;
2151  nneq = 0;
2152  for (p = _mpc; p; p = p->next) {
2153  nmpc++;
2154  nneq += p->neq;
2155  }
2156  HECMW_assert(nmpc > 0);
2157  HECMW_assert(nneq > 0);
2158  mpc->n_mpc = nmpc;
2159 
2160  /* mpc_index */
2161  size = sizeof(*mpc->mpc_index) * (mpc->n_mpc + 1);
2162  mpc->mpc_index = HECMW_malloc(size);
2163  if (mpc->mpc_index == NULL) {
2164  set_err(errno, "");
2165  goto error;
2166  }
2167 
2168  /* mpc_item */
2169  size = sizeof(*mpc->mpc_item) * nneq;
2170  mpc->mpc_item = HECMW_malloc(size);
2171  if (mpc->mpc_item == NULL) {
2172  set_err(errno, "");
2173  goto error;
2174  }
2175 
2176  /* mpc_dof */
2177  size = sizeof(*mpc->mpc_dof) * nneq;
2178  mpc->mpc_dof = HECMW_malloc(size);
2179  if (mpc->mpc_dof == NULL) {
2180  set_err(errno, "");
2181  goto error;
2182  }
2183 
2184  /* mpc_val */
2185  size = sizeof(*mpc->mpc_val) * nneq;
2186  mpc->mpc_val = HECMW_malloc(size);
2187  if (mpc->mpc_val == NULL) {
2188  set_err(errno, "");
2189  goto error;
2190  }
2191 
2192  /* mpc_const */
2193  size = sizeof(*mpc->mpc_const) * nmpc;
2194  mpc->mpc_const = HECMW_malloc(size);
2195  if (mpc->mpc_const == NULL) {
2196  set_err(errno, "");
2197  goto error;
2198  }
2199 
2200  /* set */
2201  i = 0;
2202  mpc->mpc_index[0] = 0;
2203  for (p = _mpc; p; p = p->next) {
2204  HECMW_assert(i + 1 <= mpc->n_mpc);
2205  mpc->mpc_index[i + 1] = mpc->mpc_index[i] + p->neq;
2206  HECMW_assert(mpc->mpc_index[i + 1] <= nneq);
2207  start = mpc->mpc_index[i];
2208  for (j = 0; j < p->neq; j++) {
2209  HECMW_assert(start + j < nneq);
2210  mpc->mpc_item[start + j] = get_gid2lid_node(p->item[j].node);
2211  HECMW_assert(mpc->mpc_item[start + j]);
2212  mpc->mpc_dof[start + j] = p->item[j].dof;
2213  mpc->mpc_val[start + j] = p->item[j].a;
2214  }
2215  mpc->mpc_const[i] = p->cnst;
2216  i++;
2217  }
2218  HECMW_assert(i == mpc->n_mpc);
2219  HECMW_assert(mpc->mpc_index[mpc->n_mpc] == nneq);
2220 
2221  mesh->mpc = mpc;
2222 
2223  return 0;
2224 error:
2225  if (mpc) {
2226  HECMW_free(mpc->mpc_index);
2227  HECMW_free(mpc->mpc_item);
2228  HECMW_free(mpc->mpc_dof);
2229  HECMW_free(mpc->mpc_val);
2230  HECMW_free(mpc->mpc_const);
2231  HECMW_free(mpc);
2232  }
2233  return -1;
2234 }
2235 
2236 static int setup_amp(struct hecmwST_local_mesh *mesh) {
2237  int i, j, namp, nitem, start;
2238  size_t size;
2239  struct hecmwST_amplitude *amp;
2240  struct hecmw_io_amplitude *p;
2241 
2242  HECMW_assert(mesh);
2243 
2244  amp = HECMW_malloc(sizeof(*amp));
2245  if (amp == NULL) {
2246  set_err(errno, "");
2247  return -1;
2248  }
2249 
2250  amp->n_amp = 0;
2251  amp->amp_name = NULL;
2252  amp->amp_type_definition = NULL;
2253  amp->amp_type_time = NULL;
2254  amp->amp_type_value = NULL;
2255  amp->amp_index = NULL;
2256  amp->amp_val = NULL;
2257  amp->amp_table = NULL;
2258 
2259  if (_amp == NULL) {
2260  mesh->amp = amp;
2261  return 0;
2262  }
2263 
2264  /* count total # of amplitude,item */
2265  namp = 0;
2266  nitem = 0;
2267  for (p = _amp; p; p = p->next) {
2268  struct hecmw_io_amplitude_item *item;
2269  for (item = p->item; item; item = item->next) {
2270  nitem++;
2271  }
2272  namp++;
2273  }
2274  HECMW_assert(namp > 0);
2275  HECMW_assert(nitem > 0);
2276  amp->n_amp = namp;
2277 
2278  /* amp_name */
2279  size = sizeof(*amp->amp_name) * amp->n_amp;
2280  amp->amp_name = HECMW_malloc(size);
2281  if (amp->amp_name == NULL) {
2282  set_err(errno, "");
2283  return -1;
2284  }
2285 
2286  /* amp_type_definition */
2287  size = sizeof(*amp->amp_type_definition) * amp->n_amp;
2288  amp->amp_type_definition = HECMW_malloc(size);
2289  if (amp->amp_type_definition == NULL) {
2290  set_err(errno, "");
2291  return -1;
2292  }
2293 
2294  /* amp_type_time */
2295  size = sizeof(*amp->amp_type_time) * amp->n_amp;
2296  amp->amp_type_time = HECMW_malloc(size);
2297  if (amp->amp_type_time == NULL) {
2298  set_err(errno, "");
2299  return -1;
2300  }
2301 
2302  /* amp_type_val */
2303  size = sizeof(*amp->amp_type_value) * amp->n_amp;
2304  amp->amp_type_value = HECMW_malloc(size);
2305  if (amp->amp_type_value == NULL) {
2306  set_err(errno, "");
2307  return -1;
2308  }
2309 
2310  /* amp_index */
2311  size = sizeof(*amp->amp_index) * (amp->n_amp + 1);
2312  amp->amp_index = HECMW_malloc(size);
2313  if (amp->amp_index == NULL) {
2314  set_err(errno, "");
2315  return -1;
2316  }
2317 
2318  /* amp_val */
2319  size = sizeof(*amp->amp_val) * nitem;
2320  amp->amp_val = HECMW_malloc(size);
2321  if (amp->amp_val == NULL) {
2322  set_err(errno, "");
2323  return -1;
2324  }
2325 
2326  /* amp_table */
2327  size = sizeof(*amp->amp_table) * nitem;
2328  amp->amp_table = HECMW_malloc(size);
2329  if (amp->amp_table == NULL) {
2330  set_err(errno, "");
2331  return -1;
2332  }
2333 
2334  /* set */
2335  i = 0;
2336  amp->amp_index[0] = 0;
2337  for (p = _amp; p; p = p->next) {
2338  struct hecmw_io_amplitude_item *item;
2339  int n = 0;
2340  for (item = p->item; item; item = item->next) {
2341  n++;
2342  }
2343  HECMW_assert(i + 1 <= namp);
2344  amp->amp_index[i + 1] = amp->amp_index[i] + n;
2345  HECMW_assert(amp->amp_index[i + 1] <= nitem);
2346  start = amp->amp_index[i];
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;
2350  }
2351  HECMW_assert(strlen(p->name) < HECMW_NAME_LEN);
2352  amp->amp_name[i] = HECMW_strdup(p->name);
2353  if (amp->amp_name[i] == NULL) {
2354  set_err(errno, "");
2355  return -1;
2356  }
2357  amp->amp_type_definition[i] = p->type_def;
2358  amp->amp_type_time[i] = p->type_time;
2359  amp->amp_type_value[i] = p->type_val;
2360  i++;
2361  }
2362  HECMW_assert(i == amp->n_amp);
2363  HECMW_assert(amp->amp_index[amp->n_amp] == nitem);
2364 
2365  mesh->amp = amp;
2366 
2367  return 0;
2368 }
2369 
2370 static int setup_adapt(struct hecmwST_local_mesh *mesh) {
2371  HECMW_assert(mesh);
2372 
2373  /* clear */
2374  mesh->coarse_grid_level = 0;
2375  mesh->n_adapt = 0;
2379  mesh->adapt_type = NULL;
2380  mesh->adapt_level = NULL;
2381  mesh->adapt_parent = NULL;
2384 
2385  return 0;
2386 }
2387 
2388 static int setup_refine(struct hecmwST_local_mesh *mesh) {
2389  HECMW_assert(mesh);
2390 
2391  /* clear */
2392  mesh->n_refine = 0;
2393  mesh->node_old2new = NULL;
2394  mesh->node_new2old = NULL;
2395  mesh->elem_old2new = NULL;
2396  mesh->elem_new2old = NULL;
2398 
2399  return 0;
2400 }
2401 
2402 static int setup_pe(struct hecmwST_local_mesh *mesh) {
2403  HECMW_assert(mesh);
2404 
2408  mesh->PEsmpTOT = 1;
2409  mesh->n_subdomain = 1;
2410  mesh->errnof = 0;
2411  mesh->n_neighbor_pe = 0;
2412  mesh->neighbor_pe = NULL;
2413  mesh->import_index = NULL;
2414  mesh->import_item = NULL;
2415  mesh->export_index = NULL;
2416  mesh->export_item = NULL;
2417  mesh->shared_index = NULL;
2418  mesh->shared_item = NULL;
2419 
2420  if (mesh->my_rank == 0) {
2421  mesh->zero = 1;
2422  } else {
2423  mesh->zero = 0;
2424  }
2425 
2426  return 0;
2427 }
2428 
2429 static int setup_elem_check_sectid(struct hecmwST_local_mesh *mesh) {
2430  int i;
2431 
2432  HECMW_assert(mesh);
2433 
2434  for (i = 0; i < mesh->n_elem; i++) {
2435  if (mesh->section_ID[i] == -1) {
2436  set_err(HECMW_IO_E1012, "Element %d", mesh->global_elem_ID[i]);
2437  return -1;
2438  }
2439  }
2440  return 0;
2441 }
2442 
2443 static int setup_sect_set_sectid(struct hecmwST_local_mesh *mesh,
2444  const char *egrp_name, int sectid) {
2445  int i, eid, egid, start, end;
2446  struct hecmwST_elem_grp *egrp;
2447 
2448  HECMW_assert(mesh);
2450  HECMW_assert(egrp_name);
2451 
2452  egid = HECMW_dist_get_egrp_id(mesh->elem_group, egrp_name);
2453  HECMW_assert(egid > 0);
2454 
2455  egrp = mesh->elem_group;
2456 
2457  start = egrp->grp_index[egid - 1];
2458  end = egrp->grp_index[egid] - 1;
2459 
2461  for (i = start; i <= end; i++) {
2462  eid = egrp->grp_item[i];
2463  if (mesh->section_ID[eid - 1] != -1) {
2464  set_err(HECMW_IO_E1012, "Element %d has already had section %d",
2465  mesh->global_elem_ID[eid - 1], mesh->section_ID[eid - 1]);
2466  return -1;
2467  }
2468  mesh->section_ID[eid - 1] = sectid;
2469  }
2470  return 0;
2471 }
2472 
2473 static int setup_sect(struct hecmwST_local_mesh *mesh) {
2474  int i, nsect, nint, nreal, nmat;
2475  size_t size;
2476  struct hecmwST_section *sect;
2477  struct hecmw_io_section *p;
2478 
2479  HECMW_assert(mesh);
2480 
2481  /* mesh->section */
2482  size = sizeof(*sect);
2483  sect = HECMW_malloc(size);
2484  if (sect == NULL) {
2485  set_err(errno, "");
2486  return -1;
2487  }
2488 
2489  /* section_ID */
2490  size = sizeof(*mesh->section_ID) * mesh->n_elem;
2491  mesh->section_ID = HECMW_malloc(size);
2492  if (mesh->section_ID == NULL) {
2493  set_err(errno, "");
2494  return -1;
2495  }
2496  memset(mesh->section_ID, -1, size); /* initialize */
2497 
2498  nsect = nint = nreal = nmat = 0;
2499  for (p = _sect; p; p = p->next) {
2500  nsect++;
2501  if (p->type == HECMW_SECT_TYPE_SOLID) {
2502  nreal++; /* thickness */
2503  } else if (p->type == HECMW_SECT_TYPE_SHELL) {
2504  nreal++; /* thickness */
2505  nint++; /* integpoints */
2506  } else if (p->type == HECMW_SECT_TYPE_BEAM) {
2507  nreal += 7; /* vxyz3, Iyy, Izz, Jx */
2508  } else if (p->type == HECMW_SECT_TYPE_INTERFACE) {
2509  nreal += 4; /* thickness, gapcon, gaprad1, gaprad2 */
2510  } else {
2511  return -1;
2512  }
2513  /*
2514  if(p->composite > 0) {
2515  nmat += composite;
2516  } else {
2517  nmat++;
2518  }
2519  */
2520  nmat++;
2521  }
2522  sect->n_sect = nsect;
2523 
2524  sect->sect_type = NULL;
2525  sect->sect_opt = NULL;
2526  sect->sect_mat_ID_index = NULL;
2527  sect->sect_mat_ID_item = NULL;
2528  sect->sect_I_index = NULL;
2529  sect->sect_I_item = NULL;
2530  sect->sect_R_index = NULL;
2531  sect->sect_R_item = NULL;
2532 
2533  if (sect->n_sect <= 0) {
2534  mesh->section = sect;
2535  return 0;
2536  }
2537 
2538  /* sect_type */
2539  size = sizeof(*sect->sect_type) * sect->n_sect;
2540  sect->sect_type = HECMW_malloc(size);
2541  if (sect->sect_type == NULL) {
2542  set_err(errno, "");
2543  return -1;
2544  }
2545 
2546  /* sect_opt */
2547  size = sizeof(*sect->sect_opt) * sect->n_sect;
2548  sect->sect_opt = HECMW_malloc(size);
2549  if (sect->sect_opt == NULL) {
2550  set_err(errno, "");
2551  return -1;
2552  }
2553 
2554  /* sect_mat_ID_index */
2555  size = sizeof(*sect->sect_mat_ID_index) * (sect->n_sect + 1);
2556  sect->sect_mat_ID_index = HECMW_malloc(size);
2557  if (sect->sect_mat_ID_index == NULL) {
2558  set_err(errno, "");
2559  return -1;
2560  }
2561 
2562  /* sect_mat_ID_item */
2563  HECMW_assert(nmat > 0);
2564  size = sizeof(*sect->sect_mat_ID_item) * nmat;
2565  sect->sect_mat_ID_item = HECMW_malloc(size);
2566  if (sect->sect_mat_ID_item == NULL) {
2567  set_err(errno, "");
2568  return -1;
2569  }
2570 
2571  /* sect_I_index */
2572  size = sizeof(*sect->sect_I_index) * (sect->n_sect + 1);
2573  sect->sect_I_index = HECMW_malloc(size);
2574  if (sect->sect_I_index == NULL) {
2575  set_err(errno, "");
2576  return -1;
2577  }
2578 
2579  /* sect_I_item */
2580  sect->sect_I_item = NULL;
2581  if (nint > 0) {
2582  size = sizeof(*sect->sect_I_item) * nint;
2583  sect->sect_I_item = HECMW_malloc(size);
2584  if (sect->sect_I_item == NULL) {
2585  set_err(errno, "");
2586  return -1;
2587  }
2588  }
2589 
2590  /* sect_R_index */
2591  size = sizeof(*sect->sect_R_index) * (sect->n_sect + 1);
2592  sect->sect_R_index = HECMW_malloc(size);
2593  if (sect->sect_R_index == NULL) {
2594  set_err(errno, "");
2595  return -1;
2596  }
2597 
2598  /* sect_R_item */
2599  sect->sect_R_item = NULL;
2600  if (nreal > 0) {
2601  size = sizeof(*sect->sect_R_item) * nreal;
2602  sect->sect_R_item = HECMW_malloc(size);
2603  if (sect->sect_R_item == NULL) {
2604  set_err(errno, "");
2605  return -1;
2606  }
2607  }
2608 
2609  /* set */
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];
2616  int midx;
2617  if (p->type == HECMW_SECT_TYPE_SOLID) {
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;
2620  HECMW_assert(ridx <= nreal);
2621  sect->sect_R_item[ridx] = p->sect.solid.thickness;
2622  } else if (p->type == HECMW_SECT_TYPE_SHELL) {
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;
2625  HECMW_assert(iidx <= nint);
2626  HECMW_assert(ridx <= nreal);
2627  sect->sect_I_item[iidx] = p->sect.shell.integpoints;
2628  sect->sect_R_item[ridx] = p->sect.shell.thickness;
2629  } else if (p->type == HECMW_SECT_TYPE_BEAM) {
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;
2632  HECMW_assert(ridx + 6 <= nreal);
2633  sect->sect_R_item[ridx] = p->sect.beam.vxyz[0];
2634  sect->sect_R_item[ridx + 1] = p->sect.beam.vxyz[1];
2635  sect->sect_R_item[ridx + 2] = p->sect.beam.vxyz[2];
2636  sect->sect_R_item[ridx + 3] = p->sect.beam.area;
2637  sect->sect_R_item[ridx + 4] = p->sect.beam.Iyy;
2638  sect->sect_R_item[ridx + 5] = p->sect.beam.Izz;
2639  sect->sect_R_item[ridx + 6] = p->sect.beam.Jx;
2640  } else if (p->type == HECMW_SECT_TYPE_INTERFACE) {
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;
2643  HECMW_assert(ridx + 3 <= nreal);
2644  sect->sect_R_item[ridx] = p->sect.interface.thickness;
2645  sect->sect_R_item[ridx + 1] = p->sect.interface.gapcon;
2646  sect->sect_R_item[ridx + 2] = p->sect.interface.gaprad1;
2647  sect->sect_R_item[ridx + 3] = p->sect.interface.gaprad2;
2648  } else {
2649  return -1;
2650  }
2651  sect->sect_type[i] = p->type;
2652  sect->sect_opt[i] = p->secopt;
2653  sect->sect_mat_ID_index[i + 1] = sect->sect_mat_ID_index[i] + 1;
2654  midx = sect->sect_mat_ID_index[i];
2655  /* must be called setup_mat() before */
2657  sect->sect_mat_ID_item[midx] =
2659  HECMW_assert(sect->sect_mat_ID_item[midx] > 0);
2660 
2661  /* set mesh->section_id */
2662  /* depends on setup_egrp() */
2663  if (setup_sect_set_sectid(mesh, p->egrp, i + 1)) return -1;
2664  }
2665 
2666  mesh->section = sect;
2667 
2668  return 0;
2669 }
2670 
2671 static int setup_mpc_sectid(struct hecmwST_local_mesh *mesh) {
2672  int i;
2673  struct hecmw_io_element *elem;
2674 
2675  HECMW_assert(mesh);
2676 
2677  for (i = 0; i < mesh->n_elem; i++) {
2678  /* depends on setup_elem() */
2679  if (mesh->elem_type[i] < 900) continue;
2680  if (mesh->elem_type[i] >= 1000) continue;
2682  HECMW_assert(elem);
2683  HECMW_assert(elem->mpc_sectid != -1);
2684  mesh->section_ID[i] = elem->mpc_sectid;
2685  }
2686  return 0;
2687 }
2688 
2689 static int setup_mpc_reorder(struct hecmwST_local_mesh *mesh) {
2690  if (HECMW_reorder(mesh)) {
2691  return -1;
2692  }
2693  return 0;
2694 }
2695 
2696 static int setup_mat(struct hecmwST_local_mesh *mesh) {
2697  int i, j, k, l, nmat, nmatitem, nmatsubitem, nmattable;
2698  size_t size;
2699  struct hecmwST_material *mat;
2700  struct hecmw_io_material *p;
2701 
2702  HECMW_assert(mesh);
2703 
2704  /* mesh->material */
2705  size = sizeof(*mat);
2706  mat = HECMW_malloc(size);
2707  if (mat == NULL) {
2708  set_err(errno, "");
2709  return -1;
2710  }
2711 
2712  /* n_mat, n_mat_item, n_mat_subitem, n_mat_table */
2713  nmat = nmatitem = nmatsubitem = nmattable = 0;
2714  for (p = _mat; p; p = p->next) {
2715  nmat++;
2716  nmatitem += p->nitem;
2717  for (i = 0; i < p->nitem; i++) {
2718  struct hecmw_io_matsubitem *msi = p->item[i].subitem;
2719  nmatsubitem += p->item[i].nval;
2720  for (msi = p->item[i].subitem; msi; msi = msi->next) {
2721  nmattable += p->item[i].nval;
2722  }
2723  }
2724  }
2725  mat->n_mat = nmat;
2726  mat->n_mat_item = nmatitem;
2727  mat->n_mat_subitem = nmatsubitem;
2728  mat->n_mat_table = nmattable;
2729 
2730  mat->mat_name = NULL;
2731  mat->mat_item_index = NULL;
2732  mat->mat_subitem_index = NULL;
2733  mat->mat_table_index = NULL;
2734  mat->mat_val = NULL;
2735  mat->mat_temp = NULL;
2736 
2737  if (mat->n_mat <= 0) {
2738  mesh->material = mat;
2739  return 0;
2740  }
2741 
2742  /* mat_name */
2743  size = sizeof(*mat->mat_name) * mat->n_mat;
2744  mat->mat_name = HECMW_malloc(size);
2745  if (mat->mat_name == NULL) {
2746  set_err(errno, "");
2747  return -1;
2748  }
2749 
2750  /* mat_item_index */
2751  size = sizeof(*mat->mat_item_index) * (mat->n_mat + 1);
2752  mat->mat_item_index = HECMW_malloc(size);
2753  if (mat->mat_item_index == NULL) {
2754  set_err(errno, "");
2755  return -1;
2756  }
2757 
2758  /* mat_subitem_index */
2759  size = sizeof(*mat->mat_subitem_index) * (mat->n_mat_item + 1);
2760  mat->mat_subitem_index = HECMW_malloc(size);
2761  if (mat->mat_subitem_index == NULL) {
2762  set_err(errno, "");
2763  return -1;
2764  }
2765 
2766  /* mat_table_index */
2767  size = sizeof(*mat->mat_table_index) * (mat->n_mat_subitem + 1);
2768  mat->mat_table_index = HECMW_malloc(size);
2769  if (mat->mat_table_index == NULL) {
2770  set_err(errno, "");
2771  return -1;
2772  }
2773 
2774  /* mat_val */
2775  size = sizeof(*mat->mat_val) * nmattable;
2776  mat->mat_val = HECMW_malloc(size);
2777  if (mat->mat_val == NULL) {
2778  set_err(errno, "");
2779  return -1;
2780  }
2781 
2782  /* mat_temp */
2783  size = sizeof(*mat->mat_temp) * nmattable;
2784  mat->mat_temp = HECMW_malloc(size);
2785  if (mat->mat_temp == NULL) {
2786  set_err(errno, "");
2787  return -1;
2788  }
2789 
2790  /* set */
2791  mat->mat_item_index[0] = 0;
2792  mat->mat_subitem_index[0] = 0;
2793  mat->mat_table_index[0] = 0;
2794  for (i = 0, p = _mat; p; p = p->next, i++) {
2795  HECMW_assert(i + 1 <= mat->n_mat);
2796  mat->mat_item_index[i + 1] = mat->mat_item_index[i] + p->nitem;
2797  mat->mat_name[i] = HECMW_strdup(p->name);
2798  if (mat->mat_name[i] == NULL) {
2799  set_err(errno, "");
2800  return -1;
2801  }
2802  for (j = 0; j < p->nitem; j++) {
2803  int ntable = 0;
2804  struct hecmw_io_matitem *item = &p->item[j];
2805  struct hecmw_io_matsubitem *subitem = item->subitem;
2806  int idx = mat->mat_item_index[i] + j;
2807  HECMW_assert(idx + 1 <= mat->n_mat_item);
2808  mat->mat_subitem_index[idx + 1] =
2809  mat->mat_subitem_index[idx] + item->nval;
2810  for (subitem = item->subitem; subitem; subitem = subitem->next) {
2811  ntable++;
2812  }
2813  for (k = 0; k < item->nval; k++) {
2814  HECMW_assert(mat->mat_item_index[i] + j <= mat->n_mat_item);
2815  idx = mat->mat_subitem_index[mat->mat_item_index[i] + j] + k;
2816  HECMW_assert(idx + 1 <= mat->n_mat_subitem);
2817  mat->mat_table_index[idx + 1] = mat->mat_table_index[idx] + ntable;
2818  }
2819  for (k = 0, subitem = item->subitem; subitem;
2820  subitem = subitem->next, k++) {
2821  for (l = 0; l < item->nval; l++) {
2822  int imat = mat->mat_item_index[i];
2823  int ismat = mat->mat_subitem_index[imat + j];
2824  int itable = mat->mat_table_index[ismat + l];
2825  idx = itable + k;
2826  HECMW_assert(idx < mat->n_mat_table);
2827  mat->mat_val[idx] = subitem->val[l];
2828  mat->mat_temp[idx] = subitem->temp;
2829  }
2830  }
2831  }
2832  }
2833 
2834  HECMW_assert(mat->mat_item_index[mat->n_mat] == mat->n_mat_item);
2837 
2838  mesh->material = mat;
2839 
2840  return 0;
2841 }
2842 
2843 static int setup_elem_mat(struct hecmwST_local_mesh *mesh) {
2844  int i, j, n, id, idx, *start, sectid, nmat, *matid;
2845  struct mat_table {
2846  int n;
2847  int *matid;
2848  } * mat;
2849 
2850  HECMW_assert(mesh);
2851 
2852  mat = HECMW_malloc(sizeof(*mat) * mesh->n_elem);
2853  if (mat == NULL) {
2854  set_err(errno, "");
2855  return -1;
2856  }
2857 
2858  for (i = 0; i < mesh->n_elem; i++) {
2859  mat[i].n = 0;
2860  }
2861 
2862  nmat = 0;
2863  for (i = 0; i < mesh->n_elem; i++) {
2865  HECMW_assert(elem);
2866  if (mesh->elem_type[i] >= 900 && mesh->elem_type[i] < 1000) {
2867  n = 1;
2868  HECMW_assert(elem->mpc_matid != -1);
2869  start = &elem->mpc_matid;
2870  } else if (mesh->elem_type[i] >= 1000 && mesh->elem_type[i] < 1100) {
2871  n = 1;
2872  HECMW_assert(elem->mpc_matid != -1);
2873  start = &elem->mpc_matid;
2874  } else {
2875  if (elem->nmatitem > 0) {
2877  n = 1;
2879  HECMW_assert(id > 0);
2880  start = &id;
2881  } else {
2883  sectid = mesh->section_ID[i];
2884  HECMW_assert(sectid > 0);
2885  idx = mesh->section->sect_mat_ID_index[sectid - 1];
2886  n = mesh->section->sect_mat_ID_index[sectid] - idx;
2887  HECMW_assert(n > 0);
2888  start = &mesh->section->sect_mat_ID_item[idx];
2889  }
2890  }
2891  matid = HECMW_malloc(sizeof(matid) * n);
2892  if (matid == NULL) {
2893  set_err(errno, "");
2894  return -1;
2895  }
2896  for (j = 0; j < n; j++) {
2897  matid[j] = start[j];
2898  }
2899  mat[i].matid = matid;
2900  mat[i].n = n;
2901  nmat += n;
2902  }
2903 
2904  mesh->n_elem_mat_ID = nmat;
2905  if (mesh->n_elem_mat_ID > 0) {
2906  size_t size;
2907  size = sizeof(*mesh->elem_mat_ID_index) * (mesh->n_elem + 1);
2909  if (mesh->elem_mat_ID_index == NULL) {
2910  set_err(errno, "");
2911  return -1;
2912  }
2913 
2914  size = sizeof(*mesh->elem_mat_ID_item) * nmat;
2916  if (mesh->elem_mat_ID_item == NULL) {
2917  set_err(errno, "");
2918  return -1;
2919  }
2920 
2921  mesh->elem_mat_ID_index[0] = 0;
2922  for (i = 0; i < mesh->n_elem; i++) {
2923  mesh->elem_mat_ID_index[i + 1] = mesh->elem_mat_ID_index[i] + mat[i].n;
2924  for (j = 0; j < mat[i].n; j++) {
2925  int sidx = mesh->elem_mat_ID_index[i];
2926  mesh->elem_mat_ID_item[sidx + j] = mat[i].matid[j];
2927  }
2928  }
2929  }
2930 
2931  for (i = 0; i < mesh->n_elem; i++) {
2932  HECMW_free(mat[i].matid);
2933  }
2934  HECMW_free(mat);
2935 
2936  return 0;
2937 }
2938 
2939 static int setup_contact(struct hecmwST_local_mesh *mesh) {
2940  int i, npair, slave_gid, master_gid, orislave_sgid;
2941  size_t size;
2942  struct hecmwST_contact_pair *cpair;
2943  struct hecmw_io_contact *p;
2944  orislave_sgid = 0;
2945  slave_gid = 0;
2946 
2947  HECMW_assert(mesh);
2948 
2949  cpair = HECMW_malloc(sizeof(*cpair));
2950  if (cpair == NULL) {
2951  set_err(errno, "");
2952  goto error;
2953  }
2954 
2955  cpair->n_pair = 0;
2956  cpair->type = NULL;
2957  cpair->name = NULL;
2958  cpair->slave_grp_id = NULL;
2959  cpair->slave_orisgrp_id = NULL;
2960  cpair->master_grp_id = NULL;
2961 
2962  if (_contact == NULL) {
2963  mesh->contact_pair = cpair;
2964  return 0;
2965  }
2966 
2967  /* count total # of contact pairs */
2968  npair = 0;
2969  for (p = _contact; p; p = p->next) {
2970  npair++;
2971  }
2972  HECMW_assert(npair > 0);
2973  cpair->n_pair = npair;
2974 
2975  /* name */
2976  size = sizeof(*cpair->name) * (cpair->n_pair);
2977  cpair->name = HECMW_malloc(size);
2978  if (cpair->name == NULL) {
2979  set_err(errno, "");
2980  return -1;
2981  }
2982 
2983  /* type */
2984  size = sizeof(*cpair->type) * (cpair->n_pair);
2985  cpair->type = HECMW_malloc(size);
2986  if (cpair->type == NULL) {
2987  set_err(errno, "");
2988  goto error;
2989  }
2990 
2991  /* slave_grp_id */
2992  size = sizeof(*cpair->slave_grp_id) * (cpair->n_pair);
2993  cpair->slave_grp_id = HECMW_malloc(size);
2994  if (cpair->slave_grp_id == NULL) {
2995  set_err(errno, "");
2996  goto error;
2997  }
2998 
2999  /* slave_orisgrp_id */
3000  size = sizeof(*cpair->slave_orisgrp_id) * (cpair->n_pair);
3001  cpair->slave_orisgrp_id = HECMW_malloc(size);
3002  if (cpair->slave_orisgrp_id == NULL) {
3003  set_err(errno, "");
3004  goto error;
3005  }
3006 
3007  /* master_grp_id */
3008  size = sizeof(*cpair->master_grp_id) * (cpair->n_pair);
3009  cpair->master_grp_id = HECMW_malloc(size);
3010  if (cpair->master_grp_id == NULL) {
3011  set_err(errno, "");
3012  goto error;
3013  }
3014 
3015  /* set */
3016  for (p = _contact, i = 0; p; p = p->next, i++) {
3017  HECMW_assert(i + 1 <= cpair->n_pair);
3018 
3019  HECMW_assert(strlen(p->name) < HECMW_NAME_LEN);
3020  cpair->name[i] = HECMW_strdup(p->name);
3021  if (cpair->name[i] == NULL) {
3022  set_err(errno, "");
3023  return -1;
3024  }
3025 
3026  cpair->type[i] = p->type;
3027 
3028  if (p->type == HECMW_CONTACT_TYPE_NODE_SURF) {
3029  slave_gid = HECMW_dist_get_ngrp_id(mesh->node_group, p->slave_grp);
3030  orislave_sgid = -1;
3031  } else if (p->type == HECMW_CONTACT_TYPE_SURF_SURF) {
3032  slave_gid = HECMW_dist_get_sgrp_id(mesh->surf_group, p->slave_grp);
3033  orislave_sgid = HECMW_dist_get_sgrp_id(mesh->surf_group, p->slave_orisgrp);
3034  } else if (p->type == HECMW_CONTACT_TYPE_NODE_ELEM) {
3035  slave_gid = HECMW_dist_get_ngrp_id(mesh->node_group, p->slave_grp);
3036  orislave_sgid = -1;
3037  } else {
3038  HECMW_assert(0);
3039  }
3040  HECMW_assert(slave_gid > 0);
3041 
3042  cpair->slave_grp_id[i] = slave_gid;
3043  cpair->slave_orisgrp_id[i] = orislave_sgid;
3044 
3045  if (p->type == HECMW_CONTACT_TYPE_NODE_ELEM) {
3046  master_gid = HECMW_dist_get_egrp_id(mesh->elem_group, p->master_grp);
3047  } else {
3048  master_gid = HECMW_dist_get_sgrp_id(mesh->surf_group, p->master_grp);
3049  }
3050 
3051  HECMW_assert(master_gid > 0);
3052 
3053  cpair->master_grp_id[i] = master_gid;
3054  }
3055  HECMW_assert(i == cpair->n_pair);
3056 
3057  mesh->contact_pair = cpair;
3058 
3059  return 0;
3060 
3061 error:
3062  return -1;
3063 }
3064 
3065 static int setup_contact_sectid(struct hecmwST_local_mesh *mesh) {
3066  int i;
3067  struct hecmw_io_element *elem;
3068 
3069  HECMW_assert(mesh);
3070 
3071  for (i = 0; i < mesh->n_elem; i++) {
3072  /* depends on setup_elem() */
3073  if (mesh->elem_type[i] < 1000) continue;
3074  if (mesh->elem_type[i] >= 1100) continue;
3076  HECMW_assert(elem);
3077  HECMW_assert(elem->mpc_sectid != -1);
3078  mesh->section_ID[i] = elem->mpc_sectid;
3079  }
3080  return 0;
3081 }
3082 
3083 /*----------------------------------------------------------------------------*/
3084 
3085 static int post_remove_unused_node(void) {
3086  int id;
3087 
3088  HECMW_assert(_node);
3089 
3090  /* used nodes have been marked in post_elem_check_node_existence() */
3091 
3092  HECMW_map_int_iter_init(_node);
3093  while (HECMW_map_int_iter_next_unmarked(_node, &id, NULL)) {
3094  /* remove from NODE GROUP */
3095  if (HECMW_io_remove_node_in_ngrp(id) < 0) {
3096  return -1;
3097  }
3098  }
3099 
3101 
3102  return 0;
3103 }
3104 
3105 static int post_node(void) {
3106  int n_dup;
3107 
3108  if (_node == NULL || HECMW_map_int_nval(_node) == 0) {
3109  set_err(HECMW_IO_E1014, "");
3110  return -1;
3111  }
3112 
3113  n_dup = HECMW_map_int_check_dup(_node);
3114  if (n_dup > 0) {
3115  set_warn(HECMW_IO_W1004, "%d node(s) updated", n_dup);
3116  }
3117 
3118  return 0;
3119 }
3120 
3121 static int post_elem_check_node_existence(void) {
3122  int i, j, ncon, id;
3123  struct hecmw_io_element *p;
3124 
3125  HECMW_assert(global_node_ID_max > 0);
3126 
3127  if (HECMW_map_int_mark_init(_node)) {
3128  return -1;
3129  }
3130 
3131  HECMW_map_int_iter_init(_elem);
3132  for (i = 0; HECMW_map_int_iter_next(_elem, &id, (void **)&p); i++) {
3133  ncon = HECMW_get_max_node(p->type);
3134 
3135  HECMW_assert(ncon > 0);
3136 
3137  for (j = 0; j < ncon; j++) {
3138  HECMW_assert(p->node[j] > 0);
3139  HECMW_assert(p->node[j] <= global_node_ID_max);
3140 
3141  if (HECMW_map_int_mark(_node, p->node[j])) {
3142  set_err(HECMW_IO_E1027, "Node %d does not exist", p->node[j]);
3143  return -1;
3144  }
3145  }
3146  }
3147 
3148  return 0;
3149 }
3150 
3151 static char *post_elem_make_matname(int id, char *buf, int bufsize) {
3152  const char *matname = "HECMW-MAT";
3153 
3154  HECMW_assert(buf);
3155  HECMW_assert(bufsize > 0);
3156 
3157  sprintf(buf, "%s%d", matname, id);
3158 
3159  return buf;
3160 }
3161 
3162 static int post_elem_make_mat(void) {
3163  int i, j, id;
3164  char name[HECMW_NAME_LEN + 1];
3165  struct hecmw_io_element *p;
3166  struct hecmw_io_material *mat;
3167  struct hecmw_io_matitem *matitem;
3168  struct hecmw_io_matsubitem *matsubitem;
3169 
3170  HECMW_map_int_iter_init(_elem);
3171  for (i = 0; HECMW_map_int_iter_next(_elem, &id, (void **)&p); i++) {
3172  if (p->nmatitem <= 0) continue;
3173 
3174  mat = HECMW_malloc(sizeof(*mat));
3175  if (mat == NULL) {
3176  set_err(errno, "");
3177  return -1;
3178  }
3179 
3180  matitem = HECMW_malloc(sizeof(*matitem));
3181  if (matitem == NULL) {
3182  set_err(errno, "");
3183  return -1;
3184  }
3185 
3186  matsubitem = HECMW_malloc(sizeof(*matsubitem));
3187  if (matsubitem == NULL) {
3188  set_err(errno, "");
3189  return -1;
3190  }
3191 
3192  matsubitem->val = HECMW_malloc(sizeof(*matsubitem->val) * p->nmatitem);
3193  if (matsubitem->val == NULL) {
3194  set_err(errno, "");
3195  return -1;
3196  }
3197 
3198  for (j = 0; j < p->nmatitem; j++) {
3199  matsubitem->val[j] = p->matitem[j];
3200  }
3201  matsubitem->temp = 0.0;
3202  matsubitem->next = NULL;
3203 
3204  matitem->item = 1;
3205  matitem->nval = p->nmatitem;
3206  matitem->subitem = matsubitem;
3207 
3208  mat->nitem = 1;
3209  mat->item = matitem;
3210  post_elem_make_matname(id, name, sizeof(name));
3211  strcpy(p->matname, name);
3212  strcpy(mat->name, name);
3213  mat->next = NULL;
3214 
3215  if (HECMW_io_add_mat(name, mat) == NULL) return -1;
3216  }
3217  return 0;
3218 }
3219 
3220 static int post_elem(void) {
3221  int n_dup;
3222 
3223  if (_elem == NULL) {
3224  set_err(HECMW_IO_E1015, "");
3225  return -1;
3226  }
3227 
3228  n_dup = HECMW_map_int_check_dup(_elem);
3229  if (n_dup > 0) {
3230  set_warn(HECMW_IO_W1001, "%d element(s) updated", n_dup);
3231  }
3232 
3233  if (post_elem_check_node_existence()) return -1;
3234 
3235  if (post_elem_make_mat()) return -1;
3236 
3237  return 0;
3238 }
3239 
3240 static int post_ngrp(void) {
3241  struct hecmw_io_ngrp *p;
3242 
3243  for (p = _ngrp; p; p = p->next) {
3244  int n_dup, id, i;
3245 
3246  n_dup = HECMW_set_int_check_dup(p->node);
3247  if (n_dup > 0) set_warn(HECMW_IO_W1006, "%d node(s) in %s", n_dup, p->name);
3248 
3250  for (i = 0; HECMW_set_int_iter_next(p->node, &id); i++) {
3251  if (HECMW_io_get_node(id) == NULL) {
3252  set_warn(HECMW_IO_W1005, "Node %d doesn't exist", id);
3253  HECMW_set_int_del(p->node, id);
3254  }
3255  }
3256  }
3257  return 0;
3258 }
3259 
3260 static int post_egrp(void) {
3261  struct hecmw_io_egrp *p;
3262 
3263  for (p = _egrp; p; p = p->next) {
3264  int n_dup, id, i;
3265 
3266  n_dup = HECMW_set_int_check_dup(p->elem);
3267  if (n_dup > 0)
3268  set_warn(HECMW_IO_W1003, "%d element(s) in %s", n_dup, p->name);
3269 
3271  for (i = 0; HECMW_set_int_iter_next(p->elem, &id); i++) {
3272  if (HECMW_io_get_elem(id) == NULL) {
3273  set_warn(HECMW_IO_W1002, "Element %d doesn't exist", id);
3274  HECMW_set_int_del(p->elem, id);
3275  }
3276  }
3277  }
3278  return 0;
3279 }
3280 
3281 static int post_sgrp(void) {
3282  struct hecmw_io_sgrp *p;
3283 
3284  for (p = _sgrp; p; p = p->next) {
3285  int n_dup, id, i;
3286 
3287  n_dup = HECMW_set_int_check_dup(p->item);
3288  if (n_dup > 0)
3289  set_warn(HECMW_IO_W1009, "%d surface(s) in %s", n_dup, p->name);
3290 
3292  for (i = 0; HECMW_set_int_iter_next(p->item, &id); i++) {
3293  int eid, sid;
3294  struct hecmw_io_element *element;
3295 
3296  decode_surf_key(id, &eid, &sid);
3297 
3298  /* check element */
3299  element = HECMW_io_get_elem(eid);
3300  if (element == NULL) {
3301  set_warn(HECMW_IO_W1007, "Element %d doesn't exist", eid);
3302  HECMW_set_int_del(p->item, id);
3303  continue;
3304  }
3305 
3306  /* check surface */
3307  if (HECMW_get_max_surf(element->type) < sid) {
3308  set_warn(HECMW_IO_W1008, "Element %d, surface %d", eid, sid);
3309  HECMW_set_int_del(p->item, id);
3310  }
3311  }
3312  }
3313  return 0;
3314 }
3315 
3316 static int post_initial_check_node_exists(void) {
3317  int ignore;
3318  struct hecmw_io_initial *p, *prev, *next;
3319 
3320  if (_init == NULL) return 0;
3321 
3322  /* check node existence */
3323  prev = NULL;
3324  for (p = _init; p; p = next) {
3325  next = p->next;
3326  if (p->node == -1) {
3327  if (prev) {
3328  prev->next = p;
3329  }
3330  prev = p;
3331  continue;
3332  }
3333 
3334  ignore = 0;
3335  if (HECMW_io_get_node(p->node) == NULL) {
3336  set_warn(HECMW_IO_W1016, "Node %d does not eixist", p->node);
3337  ignore = 1;
3338  }
3339  if (ignore) {
3340  HECMW_free(p);
3341  if (prev == NULL) {
3342  _init = next;
3343  } else {
3344  prev->next = next;
3345  }
3346  } else {
3347  if (prev == NULL) {
3348  _init = p;
3349  } else {
3350  prev->next = p;
3351  }
3352  prev = p;
3353  }
3354  }
3355  return 0;
3356 }
3357 
3358 static int post_initial_ngrp_to_node(void) {
3359  int i, nnode, ignore, *node;
3360  struct hecmw_io_initial *p, *prev, *next, *new_init;
3361  struct hecmw_io_id_array *id;
3362 
3363  if (_init == NULL) return 0;
3364 
3365  /* change ngrp to node */
3366  prev = NULL;
3367  for (p = _init; p; p = next) {
3368  next = p->next;
3369  if (p->node != -1) {
3370  if (prev) {
3371  prev->next = p;
3372  }
3373  prev = p;
3374  continue;
3375  }
3376 
3377  /* check existence */
3378  ignore = 0;
3379  if (HECMW_io_get_ngrp(p->ngrp) == NULL) {
3380  set_warn(HECMW_IO_W1017, "Node group %s does not eixist", p->ngrp);
3381  ignore = 1;
3382  }
3383  if (ignore) {
3384  HECMW_free(p);
3385  if (prev == NULL) {
3386  _init = next;
3387  } else {
3388  prev->next = next;
3389  }
3390  continue;
3391  }
3392 
3393  /* check # of node in node group */
3394  ignore = 0;
3395  nnode = HECMW_io_get_nnode_in_ngrp(p->ngrp);
3396  HECMW_assert(nnode > 0);
3397 
3398  /* replace by node */
3400  HECMW_assert(id);
3401  HECMW_assert(id->n == nnode);
3402  node = id->id;
3403  HECMW_free(id);
3404 
3405  for (i = 0; i < nnode; i++) {
3406  new_init = HECMW_malloc(sizeof(*new_init));
3407  if (new_init == NULL) {
3408  set_err(errno, "");
3409  return -1;
3410  }
3411  memcpy(new_init, p, sizeof(*new_init));
3412  new_init->next = NULL;
3413  new_init->node = node[i];
3414 
3415  if (prev == NULL) {
3416  _init = new_init;
3417  } else {
3418  prev->next = new_init;
3419  }
3420  prev = new_init;
3421  }
3422 
3423  HECMW_free(node);
3424  HECMW_free(p);
3425  }
3426  return 0;
3427 }
3428 
3429 static int post_initial_check_dup(void) {
3430  struct hecmw_io_initial *p;
3431  struct hecmw_set_int set;
3432  int ndup;
3433 
3434  if (_init == NULL) return 0;
3435 
3436  HECMW_set_int_init(&set);
3437 
3438  /* check duplication */
3439  for (p = _init; p; p = p->next) {
3440  HECMW_set_int_add(&set, p->node);
3441  }
3442  ndup = HECMW_set_int_check_dup(&set);
3443 
3444  HECMW_set_int_finalize(&set);
3445 
3446  if (ndup > 0) {
3447  set_err(HECMW_IO_E1018, "Some nodes are initialized more than once");
3448  return -1;
3449  }
3450  return 0;
3451 }
3452 
3453 static int post_initial(void) {
3454  if (_init == NULL) return 0;
3455 
3456  if (post_initial_check_node_exists()) return -1;
3457  HECMW_log(HECMW_LOG_DEBUG, "post_initial_check_node_exists done");
3458  if (post_initial_ngrp_to_node()) return -1;
3459  HECMW_log(HECMW_LOG_DEBUG, "post_initial_ngrp_to_node done");
3460  if (post_initial_check_dup()) return -1;
3461  HECMW_log(HECMW_LOG_DEBUG, "post_initial_check_dup done");
3462 
3463  return 0;
3464 }
3465 
3466 static int post_equation_check_node_exists(void) {
3467  int i, ignore;
3468  struct hecmw_io_mpc *p, *prev, *next;
3469 
3470  if (_mpc == NULL) return 0;
3471 
3472  /* check node existence */
3473  prev = NULL;
3474  for (p = _mpc; p; p = next) {
3475  next = p->next;
3476  if (p->item[0].node == -1) {
3477  if (prev) {
3478  prev->next = p;
3479  }
3480  prev = p;
3481  continue;
3482  }
3483 
3484  ignore = 0;
3485  HECMW_assert(p->neq >= 2);
3486  for (i = 0; i < p->neq; i++) {
3487  struct hecmw_io_mpcitem *item = &p->item[i];
3488  if (HECMW_io_get_node(item->node) == NULL) {
3489  set_warn(HECMW_IO_W1019, "Node %d not found", item->node);
3490  ignore = 1;
3491  break;
3492  }
3493  }
3494  if (ignore) {
3495  HECMW_free(p->item);
3496  HECMW_free(p);
3497  if (prev == NULL) {
3498  _mpc = next;
3499  } else {
3500  prev->next = next;
3501  }
3502  continue;
3503  }
3504  }
3505  return 0;
3506 }
3507 
3508 static int post_equation_ngrp_to_node(void) {
3509  int i, j, ignore, **node;
3510  struct hecmw_io_mpc *p, *prev, *next, *new_mpc;
3511 
3512  if (_mpc == NULL) return 0;
3513 
3514  /* change ngrp to node */
3515  prev = NULL;
3516  for (p = _mpc; p; p = next) {
3517  int nnode;
3518  next = p->next;
3519  if (p->item[0].node != -1) {
3520  if (prev) {
3521  prev->next = p;
3522  }
3523  prev = p;
3524  continue;
3525  }
3526 
3527  /* check existence */
3528  ignore = 0;
3529  HECMW_assert(p->neq >= 2);
3530  for (i = 0; i < p->neq; i++) {
3531  struct hecmw_io_mpcitem *item = &p->item[i];
3532  HECMW_assert(item->node == -1);
3533  if (HECMW_io_get_ngrp(item->ngrp) == NULL) {
3534  set_warn(HECMW_IO_W1020, "Node group %s not found", item->ngrp);
3535  ignore = 1;
3536  break;
3537  }
3538  }
3539  if (ignore) {
3540  HECMW_free(p->item);
3541  HECMW_free(p);
3542  if (prev == NULL) {
3543  _mpc = next;
3544  } else {
3545  prev->next = next;
3546  }
3547  continue;
3548  }
3549 
3550  /* check # of node in node group */
3551  ignore = 0;
3552  nnode = HECMW_io_get_nnode_in_ngrp(p->item[0].ngrp);
3553  HECMW_assert(nnode > 0);
3554  for (i = 1; i < p->neq; i++) {
3555  struct hecmw_io_mpcitem *item = &p->item[i];
3556  int n = HECMW_io_get_nnode_in_ngrp(item->ngrp);
3557  if (n != nnode) {
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);
3561  return -1;
3562  }
3563  }
3564 
3565  /* replace by node */
3566  node = HECMW_malloc(sizeof(node) * p->neq);
3567  if (node == NULL) {
3568  set_err(errno, "");
3569  return -1;
3570  }
3571 
3572  for (i = 0; i < p->neq; i++) {
3574  HECMW_assert(id);
3575  HECMW_assert(id->n == nnode);
3576  node[i] = id->id;
3577  HECMW_free(id);
3578  }
3579 
3580  for (i = 0; i < nnode; i++) {
3581  new_mpc = HECMW_malloc(sizeof(*new_mpc));
3582  if (new_mpc == NULL) {
3583  set_err(errno, "");
3584  return -1;
3585  }
3586  memcpy(new_mpc, p, sizeof(*new_mpc));
3587  new_mpc->next = NULL;
3588  new_mpc->item = NULL;
3589 
3590  new_mpc->item = HECMW_malloc(sizeof(*new_mpc->item) * (p->neq));
3591  if (new_mpc == NULL) {
3592  set_err(errno, "");
3593  return -1;
3594  }
3595 
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];
3599  item->dof = p->item[j].dof;
3600  item->a = p->item[j].a;
3601  }
3602 
3603  if (prev == NULL) {
3604  _mpc = new_mpc;
3605  } else {
3606  prev->next = new_mpc;
3607  }
3608  prev = new_mpc;
3609  }
3610 
3611  for (i = 0; i < p->neq; i++) {
3612  HECMW_free(node[i]);
3613  }
3614  HECMW_free(node);
3615 
3616  HECMW_free(p->item);
3617  HECMW_free(p);
3618  }
3619  return 0;
3620 }
3621 
3622 /*
3623  * must be node(not allow ngrp)
3624  */
3625 static int post_equation_check_dup(void) {
3626  int i;
3627  struct hecmw_io_mpc *p, *q;
3628 
3629  if (_mpc == NULL) return 0;
3630 
3631  /* check duplication */
3632  for (p = _mpc; p; p = p->next) {
3633  int nod = p->item[0].node;
3634  int dof = p->item[0].dof;
3635  for (q = _mpc; q; q = q->next) {
3636  HECMW_assert(q->neq >= 2);
3637  for (i = 1; i < q->neq; i++) {
3638  HECMW_assert(q->item[i].node != -1);
3639  if (q->item[i].node == nod && q->item[i].dof == dof) {
3640  set_err(HECMW_IO_E1022, "Node:%d and DOF:%d", nod, dof);
3641  return -1;
3642  }
3643  }
3644  }
3645  }
3646  return 0;
3647 }
3648 
3649 static int post_equation_add_elem(void) {
3650  int i, j, mpc_id, elem_id, dof1, dof2, type;
3651  int node[2];
3652  struct hecmw_io_mpc *p;
3653  struct hecmw_io_element *elem;
3654 
3655  if (_mpc == NULL) return 0;
3656 
3657  /* max element ID */
3658  elem_id = HECMW_io_get_elem_max_id();
3659  elem_id++;
3660 
3661  /* add element */
3662  for (p = _mpc, mpc_id = 1; p; p = p->next, mpc_id++) {
3663  HECMW_assert(p->neq >= 2);
3664  for (j = 0; j < p->neq - 1; j++) {
3665  dof1 = p->item[j].dof;
3666  for (i = j + 1; i < p->neq; i++) {
3667  dof2 = p->item[i].dof;
3668  /* make element type */
3669  type = 900 + dof1 * 10 + dof2;
3671 
3672  /* set node */
3673  node[0] = p->item[j].node;
3674  node[1] = p->item[i].node;
3675 
3676  /* add */
3677  elem = HECMW_io_add_elem(elem_id, type, node, 0, NULL);
3678  if (elem == NULL) {
3679  return -1;
3680  }
3681 
3682  elem->mpc_matid = (j + 1) * 10 + (i + 1);
3683  elem->mpc_sectid = mpc_id;
3684 
3685  if (HECMW_io_add_egrp("ALL", 1, &elem_id) < 0) {
3686  return -1;
3687  }
3688  elem_id++;
3689  }
3690  }
3691  }
3692  return 0;
3693 }
3694 
3695 static int post_equation(void) {
3696  if (_mpc == NULL) return 0;
3697 
3698  if (post_equation_check_node_exists()) return -1;
3699  if (post_equation_ngrp_to_node()) return -1;
3700  /* Delete because performance grow worse at large number of equations
3701  if(post_equation_check_dup()) return -1;
3702  */
3703  if (post_equation_add_elem()) return -1;
3704 
3705  return 0;
3706 }
3707 
3708 static int post_section_check_exists(void) {
3709  if (_sect == NULL) {
3710  set_err(HECMW_IO_E1023, "");
3711  return -1;
3712  }
3713  return 0;
3714 }
3715 
3716 static int post_section_check_egrp(void) {
3717  int i, eid;
3718  struct hecmw_io_section *p;
3719 
3720  for (p = _sect; p; p = p->next) {
3721  struct hecmw_io_egrp *egrp = HECMW_io_get_egrp(p->egrp);
3722 
3723  if (egrp == NULL) {
3724  set_err(HECMW_IO_E1024, "Element group %s not found", p->egrp);
3725  goto error;
3726  }
3727 
3729  for (i = 0; HECMW_set_int_iter_next(egrp->elem, &eid); i++) {
3730  struct hecmw_io_element *elem = HECMW_io_get_elem(eid);
3731 
3732  HECMW_assert(elem);
3733 
3734  if (HECMW_is_etype_link(elem->type)) continue;
3735 
3736  switch (p->type) {
3737  case HECMW_SECT_TYPE_SHELL:
3738  if (!HECMW_is_etype_shell(elem->type)) {
3739  set_err(HECMW_IO_E1026, "Only shell element allowed in EGRP %s",
3740  p->egrp);
3741  goto error;
3742  }
3743  break;
3744  case HECMW_SECT_TYPE_SOLID:
3745  if (!HECMW_is_etype_solid(elem->type)) {
3746  set_err(HECMW_IO_E1026, "Only solid element allowed in EGRP %s",
3747  p->egrp);
3748  goto error;
3749  }
3750  break;
3751  case HECMW_SECT_TYPE_BEAM:
3752  if (!HECMW_is_etype_beam(elem->type)) {
3753  set_err(HECMW_IO_E1026, "Only beam element allowed in EGRP %s",
3754  p->egrp);
3755  goto error;
3756  }
3757  break;
3759  if (!HECMW_is_etype_interface(elem->type)) {
3760  set_err(HECMW_IO_E1026, "Only interface element allowed in EGRP %s",
3761  p->egrp);
3762  goto error;
3763  }
3764  break;
3765  default:
3766  HECMW_assert(0);
3767  }
3768  }
3769  }
3770  return 0;
3771 error:
3772  return -1;
3773 }
3774 
3775 static int post_section_check_mat_exists(void) {
3776  int found;
3777  struct hecmw_io_section *p;
3778  struct hecmw_io_material *mat;
3779  extern hecmw_hash_p *hash_mat;
3780 
3781  for (p = _sect; p; p = p->next) {
3782  found = 0;
3783  /* for(mat=_mat; mat; mat=mat->next) {
3784  if(strcmp(p->material, mat->name) == 0) {
3785  found = 1;
3786  break;
3787  }
3788  }*/
3789  if ((struct hecmw_io_material *)hecmw_hash_p_get(hash_mat, p->material) !=
3790  NULL) {
3791  found = 1;
3792  }
3793  if (p->type != HECMW_SECT_TYPE_INTERFACE && !found) {
3794  set_err(HECMW_IO_E1025, "MATERIAL %s not found", p->material);
3795  return -1;
3796  }
3797  }
3798  return 0;
3799 }
3800 
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;
3805 
3806  return 0;
3807 }
3808 
3809 static int post_contact_check_grp(void) {
3810  int i;
3811  struct hecmw_io_contact *p;
3812 
3813  for (p = _contact; p; p = p->next) {
3814  struct hecmw_io_ngrp *ngrp;
3815  struct hecmw_io_sgrp *sgrp;
3816  struct hecmw_io_egrp *egrp;
3817 
3818  if (p->type == HECMW_CONTACT_TYPE_NODE_SURF) {
3819  ngrp = HECMW_io_get_ngrp(p->slave_grp);
3820  if (ngrp == NULL) {
3821  set_err(HECMW_IO_E1029, "Node group %s not found", p->slave_grp);
3822  goto error;
3823  }
3824  sgrp = HECMW_io_get_sgrp(p->master_grp);
3825  if (sgrp == NULL) {
3826  set_err(HECMW_IO_E1028, "Surface group %s not found", p->master_grp);
3827  goto error;
3828  }
3829  } else if (p->type == HECMW_CONTACT_TYPE_SURF_SURF) {
3830  sgrp = HECMW_io_get_sgrp(p->slave_grp);
3831  if (sgrp == NULL) {
3832  set_err(HECMW_IO_E1028, "Surface group %s not found", p->slave_grp);
3833  goto error;
3834  }
3835  sgrp = HECMW_io_get_sgrp(p->master_grp);
3836  if (sgrp == NULL) {
3837  set_err(HECMW_IO_E1028, "Surface group %s not found", p->master_grp);
3838  goto error;
3839  }
3840  } else if (p->type == HECMW_CONTACT_TYPE_NODE_ELEM) {
3841  ngrp = HECMW_io_get_ngrp(p->slave_grp);
3842  if (ngrp == NULL) {
3843  set_err(HECMW_IO_E1029, "Node group %s not found", p->slave_grp);
3844  goto error;
3845  }
3846  egrp = HECMW_io_get_egrp(p->master_grp);
3847  if (egrp == NULL) {
3848  set_err(HECMW_IO_E1028, "Element group %s not found", p->master_grp);
3849  goto error;
3850  }
3851  } else {
3852  fprintf(stderr, "ERROR: CONTACT_PAIR: TYPE=%d\n", p->type);
3853  HECMW_assert(0);
3854  }
3855 
3856  }
3857  return 0;
3858 error:
3859  return -1;
3860 }
3861 
3862 static int post_contact_convert_sgroup(void)
3863 {
3864  struct hecmw_io_contact *p;
3865  int elem_id, contact_id;
3866 
3867  elem_id = HECMW_io_get_elem_max_id();
3868  elem_id++;
3869 
3870  for (p = _contact, contact_id = 1; p; p = p->next, contact_id++) {
3871  struct hecmw_io_sgrp *sgrp;
3872  int n_item, i, id, ret;
3873  int *elem, *surf;
3874  char new_sgrp_name[HECMW_NAME_LEN+1];
3875 
3876  if (p->type != HECMW_CONTACT_TYPE_SURF_SURF) continue;
3877 
3878  sgrp = HECMW_io_get_sgrp(p->slave_grp);
3879  HECMW_assert(sgrp);
3880 
3881  n_item = HECMW_set_int_nval(sgrp->item);
3882  if (n_item == 0) continue;
3883 
3884  elem = (int *) malloc(sizeof(int) * n_item);
3885  surf = (int *) malloc(sizeof(int) * n_item);
3886  if (!elem || !surf) {
3887  set_err(errno, "");
3888  return -1;
3889  }
3890 
3892  for (i = 0; HECMW_set_int_iter_next(sgrp->item, &id); i++) {
3893  int eid, sid, etype, surf_etype, surf_nnode, j;
3894  struct hecmw_io_element *element, *ptelem;
3895  const int *surf_nodes;
3896  int nodes[8];
3897 
3898  decode_surf_key(id, &eid, &sid);
3899 
3900  element = HECMW_io_get_elem(eid);
3901  HECMW_assert(element);
3902  etype = element->type;
3903 
3904  /* extract surface */
3905  surf_nodes = HECMW_get_surf_nodes(etype, sid, &surf_etype);
3906  HECMW_assert( HECMW_is_etype_patch(surf_etype) );
3907 
3908  surf_nnode = HECMW_get_max_node(surf_etype);
3909 
3910  for (j = 0; j < surf_nnode; j++) {
3911  nodes[j] = element->node[surf_nodes[j] - 1];
3912  }
3913 
3914  /* add surface patch elem */
3915  ptelem = HECMW_io_add_elem(elem_id, surf_etype, nodes, 0, NULL);
3916  if (ptelem == NULL) {
3917  return -1;
3918  }
3919 
3920  ptelem->mpc_matid = surf_etype % 100;
3921  ptelem->mpc_sectid = contact_id;
3922 
3923  elem[i] = elem_id;
3924  surf[i] = 1;
3925 
3926  elem_id++;
3927  }
3928 
3929  /* add newly added patch elems to egrp "ALL" */
3930  if (HECMW_io_add_egrp("ALL", n_item, elem) < 0)
3931  return -1;
3932 
3933  /* generate name for new sgrp with patch elems */
3934  ret = snprintf(new_sgrp_name, sizeof(new_sgrp_name), "_PT_%s", sgrp->name);
3935  if (ret >= sizeof(new_sgrp_name)) {
3936  set_err(HECMW_IO_E0001, "Surface group name: %s", sgrp->name);
3937  return -1;
3938  } else if (HECMW_io_get_sgrp(new_sgrp_name) != NULL) {
3939  set_err(HECMW_IO_E0003, "Surface group name: %s", new_sgrp_name);
3940  return -1;
3941  }
3942 
3943  /* add sgrp with patch elems */
3944  if (HECMW_io_add_sgrp(new_sgrp_name, n_item, elem, surf) < 0)
3945  return -1;
3946 
3947  free(elem);
3948  free(surf);
3949 
3950  /* replace slave group by newly added sgrp with patch elems */
3951  strcpy(p->slave_grp, new_sgrp_name);
3952  }
3953  return 0;
3954 }
3955 
3956 static int post_contact(void) {
3957  if (post_contact_check_grp()) return -1;
3958  if (post_contact_convert_sgroup()) return -1;
3959 
3960  return 0;
3961 }
3962 
3963 /*----------------------------------------------------------------------------*/
3964 
3966  if (dof < 1 || dof > 6) return -1;
3967  return 0;
3968 }
3969 
3970 int HECMW_io_is_reserved_name(const char *name) {
3971  if (name == NULL) return 0;
3972  if (strncmp("HECMW", name, 5) == 0) return 1;
3973  return 0;
3974 }
3975 
3977 
3978 int HECMW_hash_init(void) {
3979  extern hecmw_hash_p *hash_ng;
3980  extern hecmw_hash_p *hash_eg;
3981  extern hecmw_hash_p *hash_sg;
3982  extern hecmw_hash_p *hash_mat;
3983 
3985  if (hash_ng == NULL) return 1;
3987  if (hash_eg == NULL) return 1;
3989  if (hash_sg == NULL) return 1;
3991  if (hash_mat == NULL) return 1;
3992 
3993  return 0;
3994 }
3995 
3997  extern hecmw_hash_p *hash_ng;
3998  extern hecmw_hash_p *hash_eg;
3999  extern hecmw_hash_p *hash_sg;
4000  extern hecmw_hash_p *hash_mat;
4001 
4006 
4007  return 0;
4008 }
4009 
4010 int HECMW_io_init(void) {
4011  HECMW_log(HECMW_LOG_DEBUG, "Initializing IO process...");
4012 
4013  if (HECMW_hash_init()) {
4014  printf("ERROE:HECMW_HASHTABLE INIT \n");
4015  return -1;
4016  }
4017  if (clear()) {
4018  return -1;
4019  }
4020 
4021  return 0;
4022 }
4023 
4025  HECMW_log(HECMW_LOG_DEBUG, "Finalizing IO process...");
4026 
4027  if (HECMW_hash_finalize()) {
4028  printf("ERROE:HECMW_HASHTABLE FINALIZE \n");
4029  return -1;
4030  }
4031  if (clear()) {
4032  return -1;
4033  }
4034 
4035  return 0;
4036 }
4037 
4038 int HECMW_io_pre_process(void) { return 0; }
4039 
4041  HECMW_log(HECMW_LOG_DEBUG, "Running post process...");
4042 
4043  if (post_node()) goto error;
4044  HECMW_log(HECMW_LOG_DEBUG, "post_node done");
4045  if (post_elem()) goto error;
4046  HECMW_log(HECMW_LOG_DEBUG, "post_elem done");
4047  if (post_ngrp()) goto error;
4048  HECMW_log(HECMW_LOG_DEBUG, "post_ngrp done");
4049  if (post_egrp()) goto error;
4050  HECMW_log(HECMW_LOG_DEBUG, "post_egrp done");
4051  if (post_sgrp()) goto error;
4052  HECMW_log(HECMW_LOG_DEBUG, "post_sgrp done");
4053  if (post_remove_unused_node()) goto error;
4054  HECMW_log(HECMW_LOG_DEBUG, "post_remove_unused_node done");
4055  if (post_initial()) goto error;
4056  HECMW_log(HECMW_LOG_DEBUG, "post_initial done");
4057  if (post_equation()) goto error;
4058  HECMW_log(HECMW_LOG_DEBUG, "post_equation done");
4059  if (post_section()) goto error;
4060  HECMW_log(HECMW_LOG_DEBUG, "post_section done");
4061  if (post_contact()) goto error;
4062  HECMW_log(HECMW_LOG_DEBUG, "post_contact done");
4063  return 0;
4064 error:
4065  return -1;
4066 }
4067 
4069  struct hecmwST_local_mesh *mesh;
4070 
4071  HECMW_log(HECMW_LOG_DEBUG, "Creating hecmwST_local_mesh...");
4072 
4073  mesh = HECMW_calloc(1, sizeof(*mesh));
4074  if (mesh == NULL) {
4075  set_err(errno, "");
4076  goto error;
4077  }
4078 
4079  if (setup_flags(mesh)) goto error;
4080  HECMW_log(HECMW_LOG_DEBUG, "setup_flags done");
4081  if (setup_gridfile(mesh)) goto error;
4082  HECMW_log(HECMW_LOG_DEBUG, "setup_gridfile done");
4083  if (setup_files(mesh)) goto error;
4084  HECMW_log(HECMW_LOG_DEBUG, "setup_files done");
4085  if (setup_header(mesh)) goto error;
4086  HECMW_log(HECMW_LOG_DEBUG, "setup_header done");
4087  if (setup_zero(mesh)) goto error;
4088  HECMW_log(HECMW_LOG_DEBUG, "setup_zero done");
4089  if (setup_node(mesh)) goto error;
4090  HECMW_log(HECMW_LOG_DEBUG, "setup_node done");
4091  if (setup_init(mesh)) goto error;
4092  HECMW_log(HECMW_LOG_DEBUG, "setup_init done");
4093  if (setup_elem(mesh)) goto error;
4094  HECMW_log(HECMW_LOG_DEBUG, "setup_elem done");
4095  if (setup_ngrp(mesh)) goto error;
4096  HECMW_log(HECMW_LOG_DEBUG, "setup_ngrp done");
4097  if (setup_egrp(mesh)) goto error;
4098  HECMW_log(HECMW_LOG_DEBUG, "setup_egrp done");
4099  if (setup_sgrp(mesh)) goto error;
4100  HECMW_log(HECMW_LOG_DEBUG, "setup_sgrp done");
4101  if (setup_pe(mesh)) goto error;
4102  HECMW_log(HECMW_LOG_DEBUG, "setup_pe done");
4103  if (setup_adapt(mesh)) goto error;
4104  HECMW_log(HECMW_LOG_DEBUG, "setup_adapt done");
4105  if (setup_refine(mesh)) goto error;
4106  HECMW_log(HECMW_LOG_DEBUG, "setup_refine done");
4107  if (setup_mpc(mesh)) goto error;
4108  HECMW_log(HECMW_LOG_DEBUG, "setup_mpc done");
4109  if (setup_amp(mesh)) goto error;
4110  HECMW_log(HECMW_LOG_DEBUG, "setup_amp done");
4111  if (setup_mat(mesh)) goto error;
4112  HECMW_log(HECMW_LOG_DEBUG, "setup_mat done");
4113  if (setup_sect(mesh)) goto error;
4114  HECMW_log(HECMW_LOG_DEBUG, "setup_sect done");
4115  if (setup_mpc_sectid(mesh)) goto error;
4116  HECMW_log(HECMW_LOG_DEBUG, "setup_mpc_sectid done");
4117  if (setup_contact_sectid(mesh)) goto error;
4118  HECMW_log(HECMW_LOG_DEBUG, "setup_contact_sectid done");
4119  if (setup_elem_check_sectid(mesh)) goto error;
4120  HECMW_log(HECMW_LOG_DEBUG, "setup_elem_check_sectid done");
4121  if (setup_elem_mat(mesh)) goto error;
4122  HECMW_log(HECMW_LOG_DEBUG, "setup_elem_mat done");
4123  if (setup_mpc_reorder(mesh)) goto error;
4124  HECMW_log(HECMW_LOG_DEBUG, "setup_mpc_reorder done");
4125  if (setup_contact(mesh)) goto error;
4126  HECMW_log(HECMW_LOG_DEBUG, "setup_contact done");
4127  return mesh;
4128 error:
4129  return NULL;
4130 }
HECMW_LOG_WARN
#define HECMW_LOG_WARN
Definition: hecmw_log.h:17
hecmw_io_section::hecmw_io_section_item::shell
struct hecmw_io_section::hecmw_io_section_item::hecmw_io_section_shell shell
hecmwST_local_mesh::my_rank
int my_rank
Definition: hecmw_struct.h:212
hecmwST_local_mesh::mpc
struct hecmwST_mpc * mpc
Definition: hecmw_struct.h:247
hecmw_io_section::hecmw_io_section_item::hecmw_io_section_beam::area
double area
Definition: hecmw_io_struct.h:137
hecmwST_local_mesh::global_node_ID
int * global_node_ID
Definition: hecmw_struct.h:168
HECMW_CONTACT_TYPE_SURF_SURF
#define HECMW_CONTACT_TYPE_SURF_SURF
Definition: hecmw_struct.h:126
hecmwST_local_mesh::section_ID
int * section_ID
Definition: hecmw_struct.h:197
hecmwST_mpc
Definition: hecmw_struct.h:48
HECMW_IO_W1005
#define HECMW_IO_W1005
Definition: hecmw_msgno.h:259
hecmw_io_element::mpc_matid
int mpc_matid
Definition: hecmw_io_struct.h:42
hecmwST_local_mesh::hecmw_flag_partcontact
int hecmw_flag_partcontact
Definition: hecmw_struct.h:148
hecmwST_local_mesh::hecmw_n_file
int hecmw_n_file
Definition: hecmw_struct.h:155
HECMW_set_int_finalize
void HECMW_set_int_finalize(struct hecmw_set_int *set)
Definition: hecmw_set_int.c:36
HECMW_set_int_is_empty
int HECMW_set_int_is_empty(const struct hecmw_set_int *set)
Definition: hecmw_set_int.c:54
hecmwST_local_mesh::shared_index
int * shared_index
Definition: hecmw_struct.h:221
HECMW_IO_E1015
#define HECMW_IO_E1015
Definition: hecmw_msgno.h:147
hecmw_dist_free_f::free_sect
subroutine free_sect(sect)
Definition: hecmw_dist_free_f.f90:107
HECMW_map_int_add
int HECMW_map_int_add(struct hecmw_map_int *map, int key, void *value)
Definition: hecmw_map_int.c:122
hecmwST_local_mesh::errnof
int errnof
Definition: hecmw_struct.h:213
hecmwST_node_grp::bc_grp_dof
int * bc_grp_dof
Definition: hecmw_struct.h:88
HECMW_map_int_iter_next
int HECMW_map_int_iter_next(struct hecmw_map_int *map, int *key, void **value)
Definition: hecmw_map_int.c:262
HECMW_IO_W1017
#define HECMW_IO_W1017
Definition: hecmw_msgno.h:267
hecmwST_amplitude::amp_val
double * amp_val
Definition: hecmw_struct.h:71
HECMW_io_get_initial
struct hecmw_io_initial * HECMW_io_get_initial(int node)
Definition: hecmw_io_mesh.c:691
hecmw_dist_free_f::free_amp
subroutine free_amp(amp)
Definition: hecmw_dist_free_f.f90:144
hecmwST_local_mesh::nn_middle
int nn_middle
Definition: hecmw_struct.h:163
hecmwST_node_grp::n_grp
int n_grp
Definition: hecmw_struct.h:76
hecmw_hash_p_put
int hecmw_hash_p_put(hecmw_hash_p *hash, const char *key, void *value)
Definition: hecmw_hash.c:123
HECMW_SECT_TYPE_SOLID
#define HECMW_SECT_TYPE_SOLID
Definition: hecmw_struct.h:18
hecmwST_amplitude::amp_index
int * amp_index
Definition: hecmw_struct.h:70
HECMW_io_set_header
void HECMW_io_set_header(struct hecmw_io_header *header)
Definition: hecmw_io_mesh.c:1448
hecmwST_local_mesh::node_new2old
int * node_new2old
Definition: hecmw_struct.h:240
hecmw_io_id_array::n
int n
Definition: hecmw_io_struct.h:16
hecmw_io_header::header
char header[HECMW_HEADER_LEN+1]
Definition: hecmw_io_struct.h:23
hecmwST_local_mesh::n_dof_tot
int n_dof_tot
Definition: hecmw_struct.h:173
hecmw_dist_free_f::free_mpc
subroutine free_mpc(mpc)
Definition: hecmw_dist_free_f.f90:134
HECMW_io_add_egrp
int HECMW_io_add_egrp(const char *name, int nelem, int *elem)
Definition: hecmw_io_mesh.c:892
hecmwST_material::n_mat_subitem
int n_mat_subitem
Definition: hecmw_struct.h:38
HECMW_IO_W1011
#define HECMW_IO_W1011
Definition: hecmw_msgno.h:265
hecmw_io_node
Definition: hecmw_io_struct.h:30
HECMW_io_get_n_elem
int HECMW_io_get_n_elem(void)
Definition: hecmw_io_mesh.c:740
hecmwST_surf_grp::bc_grp_ID
int * bc_grp_ID
Definition: hecmw_struct.h:113
hecmwST_local_mesh::hecmw_flag_partdepth
int hecmw_flag_partdepth
Definition: hecmw_struct.h:146
HECMW_io_get_elem_in_egrp
struct hecmw_io_id_array * HECMW_io_get_elem_in_egrp(const char *name)
Definition: hecmw_io_mesh.c:850
hash_sg
hecmw_hash_p * hash_sg
Definition: hecmw_hash.c:36
HECMW_map_int_iter_init
void HECMW_map_int_iter_init(struct hecmw_map_int *map)
Definition: hecmw_map_int.c:253
HECMW_set_int_iter_init
void HECMW_set_int_iter_init(struct hecmw_set_int *set)
Definition: hecmw_set_int.c:116
hecmwST_material::n_mat_table
int n_mat_table
Definition: hecmw_struct.h:39
hecmw_hash_p_new
hecmw_hash_p * hecmw_hash_p_new(unsigned int index)
Definition: hecmw_hash.c:46
hecmwST_elem_grp::bc_grp_index
int * bc_grp_index
Definition: hecmw_struct.h:102
HECMW_set_int_del
int HECMW_set_int_del(struct hecmw_set_int *set, int value)
Definition: hecmw_set_int.c:96
hecmwST_local_mesh::elem_node_item
int * elem_node_item
Definition: hecmw_struct.h:196
HECMW_LOG_DEBUG
#define HECMW_LOG_DEBUG
Definition: hecmw_log.h:21
HECMW_malloc
#define HECMW_malloc(size)
Definition: hecmw_malloc.h:20
hecmwST_local_mesh::elem_old2new
int * elem_old2new
Definition: hecmw_struct.h:241
hecmwST_amplitude::amp_table
double * amp_table
Definition: hecmw_struct.h:72
HECMW_IO_E1026
#define HECMW_IO_E1026
Definition: hecmw_msgno.h:154
HECMW_log
int HECMW_log(int loglv, const char *fmt,...)
Definition: hecmw_log.c:260
hecmw_hash_p_get
void * hecmw_hash_p_get(const hecmw_hash_p *hash, const char *key)
Definition: hecmw_hash.c:94
hecmwST_local_mesh::shared_item
int * shared_item
Definition: hecmw_struct.h:222
hecmwST_local_mesh::gridfile
char gridfile[HECMW_FILENAME_LEN+1]
Definition: hecmw_struct.h:154
hecmwST_local_mesh::elem_mat_int_val
double * elem_mat_int_val
Definition: hecmw_struct.h:203
hecmwST_local_mesh::elem_group
struct hecmwST_elem_grp * elem_group
Definition: hecmw_struct.h:250
hecmw_io_mpc::item
struct hecmw_io_mpc::hecmw_io_mpcitem * item
hecmw_io_element::node
int * node
Definition: hecmw_io_struct.h:38
HECMW_IO_W1016
#define HECMW_IO_W1016
Definition: hecmw_msgno.h:266
hecmwST_local_mesh::elem_new2old
int * elem_new2old
Definition: hecmw_struct.h:242
HECMW_map_int_iter_next_unmarked
int HECMW_map_int_iter_next_unmarked(struct hecmw_map_int *map, int *key, void **value)
Definition: hecmw_map_int.c:314
mesh
struct hecmwST_local_mesh * mesh
Definition: hecmw_repart.h:71
hecmw_io_material::item
struct hecmw_io_material::hecmw_io_matitem * item
hecmwST_local_mesh::adapt_parent
int * adapt_parent
Definition: hecmw_struct.h:233
HECMW_IO_E1029
#define HECMW_IO_E1029
Definition: hecmw_msgno.h:157
hecmw_set_int.h
HECMW_IO_E1012
#define HECMW_IO_E1012
Definition: hecmw_msgno.h:144
hecmw_io_section::hecmw_io_section_item::hecmw_io_section_beam::Iyy
double Iyy
Definition: hecmw_io_struct.h:138
hecmwST_local_mesh::n_node_gross
int n_node_gross
Definition: hecmw_struct.h:162
HECMW_comm_get_size
int HECMW_comm_get_size(void)
Definition: hecmw_comm.c:703
hecmw_heclex.h
HECMW_comm_get_comm
HECMW_Comm HECMW_comm_get_comm(void)
Definition: hecmw_comm.c:699
hecmwST_local_mesh::elem_mat_int_index
int * elem_mat_int_index
Definition: hecmw_struct.h:202
hash_ng
hecmw_hash_p * hash_ng
Definition: hecmw_hash.c:34
hecmwST_local_mesh::adapt_parent_type
int * adapt_parent_type
Definition: hecmw_struct.h:229
hecmw_io_amplitude::hecmw_io_amplitude_item::next
struct hecmw_io_amplitude_item * next
Definition: hecmw_io_struct.h:86
hecmw_io_egrp::name
char name[HECMW_NAME_LEN+1]
Definition: hecmw_io_struct.h:53
HECMW_SECT_TYPE_INTERFACE
#define HECMW_SECT_TYPE_INTERFACE
Definition: hecmw_struct.h:21
hecmw_io_contact::type
int type
Definition: hecmw_io_struct.h:155
HECMW_map_int_nval
size_t HECMW_map_int_nval(const struct hecmw_map_int *map)
Definition: hecmw_map_int.c:65
hecmwST_node_grp::bc_grp_val
double * bc_grp_val
Definition: hecmw_struct.h:89
hecmw_dist.h
hecmw_io_mpc::hecmw_io_mpcitem::ngrp
char ngrp[HECMW_NAME_LEN+1]
Definition: hecmw_io_struct.h:69
HECMW_get_surf_nodes
const int * HECMW_get_surf_nodes(int etype, int sid, int *surf_etype)
Definition: hecmw_etype.c:2068
hecmwST_local_mesh::elem_type_item
int * elem_type_item
Definition: hecmw_struct.h:194
hecmwST_local_mesh::node_ID
int * node_ID
Definition: hecmw_struct.h:167
hecmw_io_section::material
char material[HECMW_NAME_LEN+1]
Definition: hecmw_io_struct.h:120
hecmwST_local_mesh::hecmw_flag_parttype
int hecmw_flag_parttype
Definition: hecmw_struct.h:142
HECMW_io_post_process
int HECMW_io_post_process(void)
Definition: hecmw_io_mesh.c:4040
hecmw_dist_print.h
HECMW_map_int_key2local
int HECMW_map_int_key2local(const struct hecmw_map_int *map, int key, size_t *local)
Definition: hecmw_map_int.c:227
hecmwST_mpc::mpc_item
int * mpc_item
Definition: hecmw_struct.h:51
hecmwST_local_mesh
Definition: hecmw_struct.h:139
hecmw_io_contact::master_grp
char master_grp[HECMW_NAME_LEN+1]
Definition: hecmw_io_struct.h:156
HECMW_reorder
int HECMW_reorder(struct hecmwST_local_mesh *local_mesh)
Definition: hecmw_reorder.c:1771
hecmw_io_material::name
char name[HECMW_NAME_LEN+1]
Definition: hecmw_io_struct.h:102
HECMW_FLAG_VERSION
#define HECMW_FLAG_VERSION
Definition: hecmw_io_mesh.c:26
HECMW_set_int_add
int HECMW_set_int_add(struct hecmw_set_int *set, int value)
Definition: hecmw_set_int.c:60
hecmwST_local_mesh::elem_ID
int * elem_ID
Definition: hecmw_struct.h:189
hecmwST_local_mesh::adapt_type
int * adapt_type
Definition: hecmw_struct.h:230
hecmwST_amplitude::amp_type_time
int * amp_type_time
Definition: hecmw_struct.h:64
hecmwST_surf_grp::bc_grp_val
double * bc_grp_val
Definition: hecmw_struct.h:118
HECMW_io_add_ngrp
int HECMW_io_add_ngrp(const char *name, int nnode, int *node)
Definition: hecmw_io_mesh.c:1110
hecmw_io_section::hecmw_io_section_item::interface
struct hecmw_io_section::hecmw_io_section_item::hecmw_io_section_interface interface
hecmwST_amplitude::amp_type_value
int * amp_type_value
Definition: hecmw_struct.h:67
hecmw_io_material::nitem
int nitem
Definition: hecmw_io_struct.h:103
HECMW_io_init
int HECMW_io_init(void)
Definition: hecmw_io_mesh.c:4010
HECMW_dist_get_ngrp_id
int HECMW_dist_get_ngrp_id(const struct hecmwST_node_grp *ngrp, const char *name)
Definition: hecmw_dist.c:38
hecmwST_local_mesh::elem_type
int * elem_type
Definition: hecmw_struct.h:191
HECMW_set_int_check_dup
size_t HECMW_set_int_check_dup(struct hecmw_set_int *set)
Definition: hecmw_set_int.c:78
HECMW_print_vmsg
void HECMW_print_vmsg(int loglv, int msgno, const char *fmt, va_list ap)
Definition: hecmw_util.c:126
hecmwST_mpc::mpc_val
double * mpc_val
Definition: hecmw_struct.h:53
HECMW_io_get_ngrp
struct hecmw_io_ngrp * HECMW_io_get_ngrp(const char *name)
Definition: hecmw_io_mesh.c:1054
hecmwST_local_mesh::n_elem
int n_elem
Definition: hecmw_struct.h:184
hecmwST_surf_grp::grp_index
int * grp_index
Definition: hecmw_struct.h:109
HECMW_comm_get_rank
int HECMW_comm_get_rank(void)
Definition: hecmw_comm.c:707
HECMW_IO_E1023
#define HECMW_IO_E1023
Definition: hecmw_msgno.h:151
hecmwST_material::mat_subitem_index
int * mat_subitem_index
Definition: hecmw_struct.h:42
hecmw_io_material
Definition: hecmw_io_struct.h:101
hecmwST_local_mesh::neighbor_pe
int * neighbor_pe
Definition: hecmw_struct.h:216
hecmw_io_section::hecmw_io_section_item::hecmw_io_section_beam::Izz
double Izz
Definition: hecmw_io_struct.h:139
HECMW_IO_W1003
#define HECMW_IO_W1003
Definition: hecmw_msgno.h:257
hecmw_hash_p_delete
void hecmw_hash_p_delete(hecmw_hash_p *hash)
Definition: hecmw_hash.c:73
hecmw_reorder.h
hecmw_io_egrp::elem
struct hecmw_set_int * elem
Definition: hecmw_io_struct.h:54
hecmw_io_section::hecmw_io_section_item::hecmw_io_section_interface::gapcon
double gapcon
Definition: hecmw_io_struct.h:145
hecmwST_local_mesh::ne_internal
int ne_internal
Definition: hecmw_struct.h:186
hecmw_io_node::x
double x
Definition: hecmw_io_struct.h:31
hecmwST_mpc::mpc_const
double * mpc_const
Definition: hecmw_struct.h:54
HECMW_map_int_init
int HECMW_map_int_init(struct hecmw_map_int *map, void(*free_fnc)(void *))
Definition: hecmw_map_int.c:18
hecmwST_local_mesh::export_item
int * export_item
Definition: hecmw_struct.h:220
HECMW_io_get_mat
struct hecmw_io_material * HECMW_io_get_mat(const char *name)
Definition: hecmw_io_mesh.c:1401
hecmw_dist_free.h
HECMW_MAX_NODE_MAX
#define HECMW_MAX_NODE_MAX
Definition: hecmw_common_define.h:303
HECMW_io_add_mpc
struct hecmw_io_mpc * HECMW_io_add_mpc(int neq, const struct hecmw_io_mpcitem *mpcitem, double cnst)
Definition: hecmw_io_mesh.c:1317
HECMW_dist_get_sgrp_id
int HECMW_dist_get_sgrp_id(const struct hecmwST_surf_grp *sgrp, const char *name)
Definition: hecmw_dist.c:88
HECMW_io_set_gridfile
int HECMW_io_set_gridfile(char *gridfile)
Definition: hecmw_io_mesh.c:624
hecmw_io_material::hecmw_io_matitem::hecmw_io_matsubitem::next
struct hecmw_io_matsubitem * next
Definition: hecmw_io_struct.h:112
hecmw_io_section::hecmw_io_section_item::beam
struct hecmw_io_section::hecmw_io_section_item::hecmw_io_section_beam beam
hecmwST_local_mesh::node_dof_item
int * node_dof_item
Definition: hecmw_struct.h:175
HECMW_io_add_contact
struct hecmw_io_contact * HECMW_io_add_contact(const char *name, int type, const char *slave_grp, const char *master_grp)
Definition: hecmw_io_mesh.c:1478
hecmwST_mpc::mpc_dof
int * mpc_dof
Definition: hecmw_struct.h:52
hecmw_dist_free_f::free_ngrp
subroutine free_ngrp(grp)
Definition: hecmw_dist_free_f.f90:157
HECMW_io_get_system
struct hecmw_system_param * HECMW_io_get_system(void)
Definition: hecmw_io_mesh.c:1461
hecmw_io_node::y
double y
Definition: hecmw_io_struct.h:32
hecmwST_local_mesh::export_index
int * export_index
Definition: hecmw_struct.h:219
hecmwST_elem_grp::bc_grp_val
double * bc_grp_val
Definition: hecmw_struct.h:103
hecmw_io_ngrp::next
struct hecmw_io_ngrp * next
Definition: hecmw_io_struct.h:49
hecmwST_material::mat_table_index
int * mat_table_index
Definition: hecmw_struct.h:43
hecmwST_local_mesh::import_item
int * import_item
Definition: hecmw_struct.h:218
hecmwST_surf_grp::grp_item
int * grp_item
Definition: hecmw_struct.h:111
hecmwST_local_mesh::node_val_index
int * node_val_index
Definition: hecmw_struct.h:177
hecmw_io_mpc::hecmw_io_mpcitem::a
double a
Definition: hecmw_io_struct.h:72
hecmw_system.h
HECMW_io_add_sect
struct hecmw_io_section * HECMW_io_add_sect(struct hecmw_io_section *sect)
Definition: hecmw_io_mesh.c:1373
hecmwST_local_mesh::node_old2new
int * node_old2new
Definition: hecmw_struct.h:239
HECMW_calloc
#define HECMW_calloc(nmemb, size)
Definition: hecmw_malloc.h:21
hecmw_io_ngrp
Definition: hecmw_io_struct.h:46
hecmwST_local_mesh::coarse_grid_level
int coarse_grid_level
Definition: hecmw_struct.h:225
hecmwST_local_mesh::n_node
int n_node
Definition: hecmw_struct.h:161
hecmw_struct.h
hecmwST_local_mesh::node
double * node
Definition: hecmw_struct.h:170
hecmw_io_section::hecmw_io_section_item::solid
struct hecmw_io_section::hecmw_io_section_item::hecmw_io_section_solid solid
HECMW_io_set_system
void HECMW_io_set_system(struct hecmw_system_param *system)
Definition: hecmw_io_mesh.c:1465
HECMW_io_add_amp
struct hecmw_io_amplitude * HECMW_io_add_amp(const char *name, int definition, int time, int value, double val, double t)
Definition: hecmw_io_mesh.c:631
hecmw_dist_free_f::free_sgrp
subroutine free_sgrp(grp)
Definition: hecmw_dist_free_f.f90:184
hecmwST_amplitude
Definition: hecmw_struct.h:57
hecmw_common.h
HECMW_io_add_mat
struct hecmw_io_material * HECMW_io_add_mat(const char *name, struct hecmw_io_material *mat)
Definition: hecmw_io_mesh.c:1419
hecmwST_elem_grp
Definition: hecmw_struct.h:92
hecmw_io_id_array::id
int * id
Definition: hecmw_io_struct.h:17
HECMW_io_finalize
int HECMW_io_finalize(void)
Definition: hecmw_io_mesh.c:4024
hecmw_io_amplitude::name
char name[HECMW_NAME_LEN+1]
Definition: hecmw_io_struct.h:78
HECMW_IO_E1022
#define HECMW_IO_E1022
Definition: hecmw_msgno.h:150
hecmwST_contact_pair::slave_orisgrp_id
int * slave_orisgrp_id
Definition: hecmw_struct.h:129
hecmw_io_node::z
double z
Definition: hecmw_io_struct.h:33
HECMW_IO_E1025
#define HECMW_IO_E1025
Definition: hecmw_msgno.h:153
hecmw_map_int.h
HECMW_SECT_TYPE_BEAM
#define HECMW_SECT_TYPE_BEAM
Definition: hecmw_struct.h:20
HECMW_set_int_nval
size_t HECMW_set_int_nval(struct hecmw_set_int *set)
Definition: hecmw_set_int.c:45
hecmw_io_contact::slave_orisgrp
char slave_orisgrp[HECMW_NAME_LEN+1]
Definition: hecmw_io_struct.h:158
hecmwST_local_mesh::n_node_refine_hist
int * n_node_refine_hist
Definition: hecmw_struct.h:243
hecmwST_local_mesh::PETOT
int PETOT
Definition: hecmw_struct.h:210
hecmwST_local_mesh::when_i_was_refined_elem
int * when_i_was_refined_elem
Definition: hecmw_struct.h:228
hecmwST_local_mesh::node_dof_index
int * node_dof_index
Definition: hecmw_struct.h:174
hecmwST_local_mesh::n_elem_mat_ID
int n_elem_mat_ID
Definition: hecmw_struct.h:200
hecmw_io_sgrp
Definition: hecmw_io_struct.h:58
hecmwST_contact_pair::n_pair
int n_pair
Definition: hecmw_struct.h:122
HECMW_set_int_init
int HECMW_set_int_init(struct hecmw_set_int *set)
Definition: hecmw_set_int.c:16
HECMW_io_get_elem_max_id
int HECMW_io_get_elem_max_id(void)
Definition: hecmw_io_mesh.c:746
hecmw_io_section
Definition: hecmw_io_struct.h:118
HECMW_io_check_mpc_dof
int HECMW_io_check_mpc_dof(int dof)
Definition: hecmw_io_mesh.c:3965
hecmw_io_section::egrp
char egrp[HECMW_NAME_LEN+1]
Definition: hecmw_io_struct.h:119
hecmw_io_element::mpc_sectid
int mpc_sectid
Definition: hecmw_io_struct.h:43
HECMW_LOG_ERROR
#define HECMW_LOG_ERROR
Definition: hecmw_log.h:15
HECMW_io_add_initial
struct hecmw_io_initial * HECMW_io_add_initial(int type, int node, const char *ngrp, double val)
Definition: hecmw_io_mesh.c:700
hecmw_io_element::matitem
double * matitem
Definition: hecmw_io_struct.h:40
HECMW_NAME_LEN
#define HECMW_NAME_LEN
Definition: hecmw_config.h:70
hecmwST_section::sect_mat_ID_index
int * sect_mat_ID_index
Definition: hecmw_struct.h:30
HECMW_IO_W1007
#define HECMW_IO_W1007
Definition: hecmw_msgno.h:261
hecmw_io_amplitude::last
struct hecmw_io_amplitude_item * last
Definition: hecmw_io_struct.h:88
HECMW_is_etype_link
int HECMW_is_etype_link(int etype)
Definition: hecmw_etype.c:1987
hecmw_io_amplitude::type_time
int type_time
Definition: hecmw_io_struct.h:80
hecmwST_amplitude::n_amp
int n_amp
Definition: hecmw_struct.h:58
hecmw_io_zero
Definition: hecmw_io_struct.h:26
hecmw_config.h
HECMW_map_int_mark_init
int HECMW_map_int_mark_init(struct hecmw_map_int *map)
Definition: hecmw_map_int.c:281
hecmwST_local_mesh::material
struct hecmwST_material * material
Definition: hecmw_struct.h:246
hecmw_io_initial::type
int type
Definition: hecmw_io_struct.h:93
hecmwST_local_mesh::node_val_item
double * node_val_item
Definition: hecmw_struct.h:178
hecmwST_local_mesh::elem_mat_ID_index
int * elem_mat_ID_index
Definition: hecmw_struct.h:198
hecmw_io_section::hecmw_io_section_item::hecmw_io_section_solid::thickness
double thickness
Definition: hecmw_io_struct.h:127
hecmwST_material::mat_temp
double * mat_temp
Definition: hecmw_struct.h:45
hecmw_io_sgrp::name
char name[HECMW_NAME_LEN+1]
Definition: hecmw_io_struct.h:59
hecmwST_local_mesh::hecmw_flag_adapt
int hecmw_flag_adapt
Definition: hecmw_struct.h:140
hecmwST_mpc::n_mpc
int n_mpc
Definition: hecmw_struct.h:49
hecmwST_surf_grp::n_grp
int n_grp
Definition: hecmw_struct.h:107
HECMW_CONTACT_TYPE_NODE_SURF
#define HECMW_CONTACT_TYPE_NODE_SURF
Definition: hecmw_struct.h:125
hecmwST_local_mesh::amp
struct hecmwST_amplitude * amp
Definition: hecmw_struct.h:248
HECMW_io_get_node_in_ngrp
struct hecmw_io_id_array * HECMW_io_get_node_in_ngrp(const char *name)
Definition: hecmw_io_mesh.c:1071
hecmwST_local_mesh::zero_temp
double zero_temp
Definition: hecmw_struct.h:158
hecmw_io_element::nmatitem
int nmatitem
Definition: hecmw_io_struct.h:39
HECMW_io_get_version
int HECMW_io_get_version(void)
Definition: hecmw_io_mesh.c:3976
hecmwST_surf_grp::bc_grp_index
int * bc_grp_index
Definition: hecmw_struct.h:117
hash_mat
hecmw_hash_p * hash_mat
Definition: hecmw_hash.c:37
hecmwST_local_mesh::node_internal_list
int * node_internal_list
Definition: hecmw_struct.h:165
hecmw_io_element::matname
char matname[HECMW_NAME_LEN+1]
Definition: hecmw_io_struct.h:41
hecmwST_local_mesh::elem_val_index
int * elem_val_index
Definition: hecmw_struct.h:204
hecmw_io_section::sect
union hecmw_io_section::hecmw_io_section_item sect
HECMW_is_etype_solid
int HECMW_is_etype_solid(int etype)
Definition: hecmw_etype.c:1925
HECMW_strdup
#define HECMW_strdup(s)
Definition: hecmw_malloc.h:23
hecmwST_local_mesh::adapt_level
int * adapt_level
Definition: hecmw_struct.h:231
hecmwST_local_mesh::elem_node_index
int * elem_node_index
Definition: hecmw_struct.h:195
HECMW_IO_W1001
#define HECMW_IO_W1001
Definition: hecmw_msgno.h:255
hecmw_set_int
Definition: hecmw_set_int.h:11
hecmw_io_section::type
int type
Definition: hecmw_io_struct.h:123
hecmw_io_mpc
Definition: hecmw_io_struct.h:64
hecmwST_local_mesh::n_elem_type
int n_elem_type
Definition: hecmw_struct.h:192
HECMW_io_get_nnode_in_ngrp
int HECMW_io_get_nnode_in_ngrp(const char *name)
Definition: hecmw_io_mesh.c:1030
HECMW_IO_E0003
#define HECMW_IO_E0003
Definition: hecmw_msgno.h:139
HECMW_IO_E0001
#define HECMW_IO_E0001
Definition: hecmw_msgno.h:137
hecmwST_section
Definition: hecmw_struct.h:11
HECMW_io_add_elem
struct hecmw_io_element * HECMW_io_add_elem(int id, int type, int *node, int nmatitem, double *matitem)
Definition: hecmw_io_mesh.c:769
hecmwST_node_grp::n_bc
int n_bc
Definition: hecmw_struct.h:81
HECMW_map_int_get
void * HECMW_map_int_get(const struct hecmw_map_int *map, int key)
Definition: hecmw_map_int.c:242
hecmw_io_mpc::neq
int neq
Definition: hecmw_io_struct.h:65
hecmw_io_header
Definition: hecmw_io_struct.h:22
HECMW_hash_finalize
int HECMW_hash_finalize(void)
Definition: hecmw_io_mesh.c:3996
HECMW_io_is_reserved_name
int HECMW_io_is_reserved_name(const char *name)
Definition: hecmw_io_mesh.c:3970
hecmw_io_sgrp::next
struct hecmw_io_sgrp * next
Definition: hecmw_io_struct.h:61
hecmw_io_contact
Definition: hecmw_io_struct.h:153
hecmw_io_initial::next
struct hecmw_io_initial * next
Definition: hecmw_io_struct.h:98
HECMW_is_etype_shell
int HECMW_is_etype_shell(int etype)
Definition: hecmw_etype.c:1973
HECMW_is_etype_patch
int HECMW_is_etype_patch(int etype)
Definition: hecmw_etype.c:2048
hecmwST_local_mesh::PEsmpTOT
int PEsmpTOT
Definition: hecmw_struct.h:211
hecmwST_elem_grp::grp_item
int * grp_item
Definition: hecmw_struct.h:96
hecmwST_node_grp::grp_index
int * grp_index
Definition: hecmw_struct.h:78
hecmw_io_amplitude::next
struct hecmw_io_amplitude * next
Definition: hecmw_io_struct.h:89
HECMW_set_verror
int HECMW_set_verror(int errorno, const char *fmt, va_list ap)
Definition: hecmw_error.c:17
hecmw_io_id_array
Definition: hecmw_io_struct.h:12
HECMW_get_max_node
int HECMW_get_max_node(int etype)
Definition: hecmw_etype.c:413
hecmwST_elem_grp::grp_name
char ** grp_name
Definition: hecmw_struct.h:94
HECMW_map_int_mark
int HECMW_map_int_mark(struct hecmw_map_int *map, int key)
Definition: hecmw_map_int.c:300
HECMW_IO_E1014
#define HECMW_IO_E1014
Definition: hecmw_msgno.h:146
hecmwST_local_mesh::hecmw_flag_initcon
int hecmw_flag_initcon
Definition: hecmw_struct.h:141
hecmwST_local_mesh::adapt_children_index
int * adapt_children_index
Definition: hecmw_struct.h:234
hecmwST_local_mesh::elem_type_index
int * elem_type_index
Definition: hecmw_struct.h:193
hecmw_io_contact::next
struct hecmw_io_contact * next
Definition: hecmw_io_struct.h:159
HECMW_ALL_E0101
#define HECMW_ALL_E0101
Definition: hecmw_msgno.h:8
hecmw_io_section::composite
int composite
Definition: hecmw_io_struct.h:121
hecmw_io_section::hecmw_io_section_item::hecmw_io_section_shell::thickness
double thickness
Definition: hecmw_io_struct.h:131
HECMW_io_set_zero
void HECMW_io_set_zero(struct hecmw_io_zero *zero)
Definition: hecmw_io_mesh.c:1470
HECMW_is_etype_beam
int HECMW_is_etype_beam(int etype)
Definition: hecmw_etype.c:1963
HECMW_io_get_node
struct hecmw_io_node * HECMW_io_get_node(int id)
Definition: hecmw_io_mesh.c:975
hecmw_io_mpc::next
struct hecmw_io_mpc * next
Definition: hecmw_io_struct.h:74
HECMW_IO_W1019
#define HECMW_IO_W1019
Definition: hecmw_msgno.h:268
hecmw_io_contact::slave_grp
char slave_grp[HECMW_NAME_LEN+1]
Definition: hecmw_io_struct.h:157
hecmwST_contact_pair::type
int * type
Definition: hecmw_struct.h:124
hecmw_io_amplitude::item
struct hecmw_io_amplitude::hecmw_io_amplitude_item * item
HECMW_dist_get_egrp_id
int HECMW_dist_get_egrp_id(const struct hecmwST_elem_grp *egrp, const char *name)
Definition: hecmw_dist.c:63
hecmw_io_initial
Definition: hecmw_io_struct.h:92
HECMW_SECT_TYPE_SHELL
#define HECMW_SECT_TYPE_SHELL
Definition: hecmw_struct.h:19
HECMW_is_etype_interface
int HECMW_is_etype_interface(int etype)
Definition: hecmw_etype.c:1946
hecmw_io_zero::zero
double zero
Definition: hecmw_io_struct.h:27
hecmwST_node_grp::grp_item
int * grp_item
Definition: hecmw_struct.h:79
HECMW_set_int_iter_next
int HECMW_set_int_iter_next(struct hecmw_set_int *set, int *value)
Definition: hecmw_set_int.c:128
HECMW_CONTACT_TYPE_NODE_ELEM
#define HECMW_CONTACT_TYPE_NODE_ELEM
Definition: hecmw_struct.h:127
hecmwST_local_mesh::elem_val_item
double * elem_val_item
Definition: hecmw_struct.h:205
hecmwST_amplitude::amp_name
char ** amp_name
Definition: hecmw_struct.h:59
hecmw_io_material::next
struct hecmw_io_material * next
Definition: hecmw_io_struct.h:115
hecmwST_section::sect_mat_ID_item
int * sect_mat_ID_item
Definition: hecmw_struct.h:31
hecmwST_material::n_mat
int n_mat
Definition: hecmw_struct.h:36
HECMW_IO_E1021
#define HECMW_IO_E1021
Definition: hecmw_msgno.h:149
hecmw_map_int
Definition: hecmw_map_int.h:21
HECMW_map_int_check_dup
size_t HECMW_map_int_check_dup(struct hecmw_map_int *map)
Definition: hecmw_map_int.c:158
hecmwST_node_grp
Definition: hecmw_struct.h:75
hecmwST_local_mesh::elem_mat_ID_item
int * elem_mat_ID_item
Definition: hecmw_struct.h:199
hecmwST_node_grp::bc_grp_ID
int * bc_grp_ID
Definition: hecmw_struct.h:82
hecmw_io_section::hecmw_io_section_item::hecmw_io_section_interface::gaprad2
double gaprad2
Definition: hecmw_io_struct.h:147
HECMW_IO_W1002
#define HECMW_IO_W1002
Definition: hecmw_msgno.h:256
HECMW_IO_E1028
#define HECMW_IO_E1028
Definition: hecmw_msgno.h:156
hecmwST_local_mesh::n_refine
int n_refine
Definition: hecmw_struct.h:238
hecmwST_node_grp::bc_grp_type
int * bc_grp_type
Definition: hecmw_struct.h:84
hecmw_dist_free_f::free_egrp
subroutine free_egrp(grp)
Definition: hecmw_dist_free_f.f90:171
hecmwST_material::n_mat_item
int n_mat_item
Definition: hecmw_struct.h:37
hecmw_io_egrp
Definition: hecmw_io_struct.h:52
hecmw_dist_free_f::free_elem
subroutine free_elem(mesh)
Definition: hecmw_dist_free_f.f90:59
hecmwST_local_mesh::when_i_was_refined_node
int * when_i_was_refined_node
Definition: hecmw_struct.h:227
HECMW_SUCCESS
#define HECMW_SUCCESS
Definition: hecmw_config.h:64
hecmwST_material::mat_name
char ** mat_name
Definition: hecmw_struct.h:40
HECMW_FLAG_PARTTYPE_UNKNOWN
#define HECMW_FLAG_PARTTYPE_UNKNOWN
Definition: hecmw_struct.h:143
hecmw_io_section::hecmw_io_section_item::hecmw_io_section_beam::vxyz
double vxyz[3]
Definition: hecmw_io_struct.h:136
hecmw_hash_p
Definition: hecmw_hash.c:28
HECMW_IO_E1018
#define HECMW_IO_E1018
Definition: hecmw_msgno.h:148
hecmwST_local_mesh::nn_internal
int nn_internal
Definition: hecmw_struct.h:164
hecmwST_elem_grp::bc_grp_ID
int * bc_grp_ID
Definition: hecmw_struct.h:99
hecmw_io_material::hecmw_io_matitem::subitem
struct hecmw_io_material::hecmw_io_matitem::hecmw_io_matsubitem * subitem
hecmwST_local_mesh::node_init_val_item
double * node_init_val_item
Definition: hecmw_struct.h:181
hecmwST_local_mesh::n_adapt
int n_adapt
Definition: hecmw_struct.h:226
hecmw_io_section::secopt
int secopt
Definition: hecmw_io_struct.h:122
hecmw_io_mesh.h
hecmw_io_amplitude::type_val
int type_val
Definition: hecmw_io_struct.h:81
HECMW_IO_W1004
#define HECMW_IO_W1004
Definition: hecmw_msgno.h:258
HECMW_map_int_del_unmarked
int HECMW_map_int_del_unmarked(struct hecmw_map_int *map)
Definition: hecmw_map_int.c:343
hecmw_io_mpc::hecmw_io_mpcitem::dof
int dof
Definition: hecmw_io_struct.h:71
hecmwST_surf_grp
Definition: hecmw_struct.h:106
hecmw_io_initial::node
int node
Definition: hecmw_io_struct.h:95
hecmwST_contact_pair
Definition: hecmw_struct.h:121
hecmwST_material::mat_item_index
int * mat_item_index
Definition: hecmw_struct.h:41
hecmwST_contact_pair::slave_grp_id
int * slave_grp_id
Definition: hecmw_struct.h:128
hecmw_io_ngrp::name
char name[HECMW_NAME_LEN+1]
Definition: hecmw_io_struct.h:47
HECMW_IO_W1020
#define HECMW_IO_W1020
Definition: hecmw_msgno.h:269
hecmwST_local_mesh::n_dof
int n_dof
Definition: hecmw_struct.h:171
hecmw_io_section::hecmw_io_section_item::hecmw_io_section_beam::Jx
double Jx
Definition: hecmw_io_struct.h:140
HECMW_io_make_local_mesh
struct hecmwST_local_mesh * HECMW_io_make_local_mesh(void)
Definition: hecmw_io_mesh.c:4068
hecmwST_local_mesh::n_subdomain
int n_subdomain
Definition: hecmw_struct.h:214
HECMW_io_get_egrp
struct hecmw_io_egrp * HECMW_io_get_egrp(const char *name)
Definition: hecmw_io_mesh.c:844
hecmwST_local_mesh::import_index
int * import_index
Definition: hecmw_struct.h:217
hecmw_io_sgrp::item
struct hecmw_set_int * item
Definition: hecmw_io_struct.h:60
HECMW_IO_W1009
#define HECMW_IO_W1009
Definition: hecmw_msgno.h:263
hecmw_io_contact::name
char name[HECMW_NAME_LEN+1]
Definition: hecmw_io_struct.h:154
hecmw_io_section::hecmw_io_section_item::hecmw_io_section_interface::gaprad1
double gaprad1
Definition: hecmw_io_struct.h:146
hecmwST_local_mesh::hecmw_flag_version
int hecmw_flag_version
Definition: hecmw_struct.h:147
hecmw_hash.h
hecmw_io_section::hecmw_io_section_item::hecmw_io_section_shell::integpoints
int integpoints
Definition: hecmw_io_struct.h:132
hecmw_io_ngrp::node
struct hecmw_set_int * node
Definition: hecmw_io_struct.h:48
HECMW_io_print_all
void HECMW_io_print_all(FILE *fp)
Definition: hecmw_io_mesh.c:418
hecmw_io_mpc::hecmw_io_mpcitem::node
int node
Definition: hecmw_io_struct.h:70
HECMW_map_int_finalize
void HECMW_map_int_finalize(struct hecmw_map_int *map)
Definition: hecmw_map_int.c:40
hecmwST_surf_grp::n_bc
int n_bc
Definition: hecmw_struct.h:112
hecmwST_local_mesh::zero
int zero
Definition: hecmw_struct.h:208
hecmwST_elem_grp::n_bc
int n_bc
Definition: hecmw_struct.h:98
hecmwST_contact_pair::name
char ** name
Definition: hecmw_struct.h:123
hecmwST_local_mesh::files
char ** files
Definition: hecmw_struct.h:156
hecmwST_elem_grp::n_grp
int n_grp
Definition: hecmw_struct.h:93
HECMW_io_add_sgrp
int HECMW_io_add_sgrp(const char *name, int n_item, int *elem, int *surf)
Definition: hecmw_io_mesh.c:1233
hecmw_io_struct.h
hecmwST_material::mat_val
double * mat_val
Definition: hecmw_struct.h:44
hecmwST_local_mesh::section
struct hecmwST_section * section
Definition: hecmw_struct.h:245
hecmw_io_element
Definition: hecmw_io_struct.h:36
hecmwST_elem_grp::grp_index
int * grp_index
Definition: hecmw_struct.h:95
hecmwST_node_grp::grp_name
char ** grp_name
Definition: hecmw_struct.h:77
hecmw_io_element::type
int type
Definition: hecmw_io_struct.h:37
hecmw_dist_free_f::free_node
subroutine free_node(mesh)
Definition: hecmw_dist_free_f.f90:43
hecmwST_node_grp::bc_grp_index
int * bc_grp_index
Definition: hecmw_struct.h:87
NULL
#define NULL
Definition: hecmw_io_nastran.c:30
HECMW_get_max_surf
int HECMW_get_max_surf(int etype)
Definition: hecmw_etype.c:743
HECMW_IO_E1024
#define HECMW_IO_E1024
Definition: hecmw_msgno.h:152
HECMW_free
#define HECMW_free(ptr)
Definition: hecmw_malloc.h:24
HECMW_IO_E1027
#define HECMW_IO_E1027
Definition: hecmw_msgno.h:155
hecmw_io_hec.h
HECMW_IO_W1010
#define HECMW_IO_W1010
Definition: hecmw_msgno.h:264
hecmw_io_initial::val
double val
Definition: hecmw_io_struct.h:97
HECMW_hash_init
int HECMW_hash_init(void)
Definition: hecmw_io_mesh.c:3978
hecmw_io_material::hecmw_io_matitem::nval
int nval
Definition: hecmw_io_struct.h:107
hecmwST_elem_grp::bc_grp_type
int * bc_grp_type
Definition: hecmw_struct.h:101
hecmwST_local_mesh::n_elem_gross
int n_elem_gross
Definition: hecmw_struct.h:185
HECMW_FLAG_PARTCONTACT_UNKNOWN
#define HECMW_FLAG_PARTCONTACT_UNKNOWN
Definition: hecmw_struct.h:149
HECMW_assert
#define HECMW_assert(cond)
Definition: hecmw_util.h:40
hecmwST_local_mesh::adapt_children_item
int * adapt_children_item
Definition: hecmw_struct.h:235
hecmwST_material
Definition: hecmw_struct.h:35
hecmwST_local_mesh::header
char header[HECMW_HEADER_LEN+1]
Definition: hecmw_struct.h:157
HECMW_FILENAME_LEN
#define HECMW_FILENAME_LEN
Definition: hecmw_config.h:72
hecmwST_mpc::mpc_index
int * mpc_index
Definition: hecmw_struct.h:50
hecmwST_surf_grp::grp_name
char ** grp_name
Definition: hecmw_struct.h:108
hecmw_system_param
Definition: hecmw_system.h:11
HECMW_dist_get_mat_id
int HECMW_dist_get_mat_id(const struct hecmwST_material *mat, const char *name)
Definition: hecmw_dist.c:13
hash_eg
hecmw_hash_p * hash_eg
Definition: hecmw_hash.c:35
hecmwST_local_mesh::n_neighbor_pe
int n_neighbor_pe
Definition: hecmw_struct.h:215
hecmw_io_section::hecmw_io_section_item::hecmw_io_section_interface::thickness
double thickness
Definition: hecmw_io_struct.h:144
hecmwST_local_mesh::global_elem_ID
int * global_elem_ID
Definition: hecmw_struct.h:190
hecmwST_local_mesh::surf_group
struct hecmwST_surf_grp * surf_group
Definition: hecmw_struct.h:251
hecmw_io_egrp::next
struct hecmw_io_egrp * next
Definition: hecmw_io_struct.h:55
hecmwST_local_mesh::n_dof_grp
int n_dof_grp
Definition: hecmw_struct.h:172
hecmw_io_amplitude::type_def
int type_def
Definition: hecmw_io_struct.h:79
hecmwST_local_mesh::node_group
struct hecmwST_node_grp * node_group
Definition: hecmw_struct.h:249
hecmw_util.h
hecmw_io_section::next
struct hecmw_io_section * next
Definition: hecmw_io_struct.h:150
HECMW_io_pre_process
int HECMW_io_pre_process(void)
Definition: hecmw_io_mesh.c:4038
hecmwST_contact_pair::master_grp_id
int * master_grp_id
Definition: hecmw_struct.h:130
hecmw_io_amplitude
Definition: hecmw_io_struct.h:77
hecmwST_local_mesh::node_init_val_index
int * node_init_val_index
Definition: hecmw_struct.h:180
hecmwST_local_mesh::contact_pair
struct hecmwST_contact_pair * contact_pair
Definition: hecmw_struct.h:252
hecmw_io_initial::ngrp
char ngrp[HECMW_NAME_LEN+1]
Definition: hecmw_io_struct.h:96
HECMW_io_get_n_node
int HECMW_io_get_n_node(void)
Definition: hecmw_io_mesh.c:981
hecmwST_local_mesh::HECMW_COMM
HECMW_Comm HECMW_COMM
Definition: hecmw_struct.h:209
hecmwST_surf_grp::bc_grp_type
int * bc_grp_type
Definition: hecmw_struct.h:115
HECMW_IO_W1008
#define HECMW_IO_W1008
Definition: hecmw_msgno.h:262
hecmwST_amplitude::amp_type_definition
int * amp_type_definition
Definition: hecmw_struct.h:61
hecmwST_local_mesh::elem_internal_list
int * elem_internal_list
Definition: hecmw_struct.h:187
HECMW_io_free_all
int HECMW_io_free_all(void)
Definition: hecmw_io_mesh.c:604
HECMW_io_add_node
struct hecmw_io_node * HECMW_io_add_node(int id, double x, double y, double z)
Definition: hecmw_io_mesh.c:994
HECMW_io_get_elem
struct hecmw_io_element * HECMW_io_get_elem(int id)
Definition: hecmw_io_mesh.c:734
hecmw_io_mpc::cnst
double cnst
Definition: hecmw_io_struct.h:66
HECMW_IO_W1006
#define HECMW_IO_W1006
Definition: hecmw_msgno.h:260