FrontISTR  5.7.0
Large-scale structural analysis program with finit element method
hecmw_conn_conv.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 "hecmw_util.h"
7 #include "hecmw_common_define.h"
8 #include "hecmw_etype.h"
9 #include "hecmw_conn_conv.h"
10 
11 struct conn_conv {
14 };
15 
16 static struct conn_conv conn_conv_abaqus[] = {
17  {232, {1, 2, 3, 6, 4, 5}},
18  {342, {1, 2, 3, 4, 7, 5, 6, 8, 9, 10}},
19  {352, {1, 2, 3, 4, 5, 6, 9, 7, 8, 12, 10, 11, 13, 14, 15}},
20  {542, {1, 2, 3, 4, 9, 10, 11, 12, 5, 6, 7, 8, 13, 14, 15, 16}},
21  {-1, {-1}} /* terminator */
22 };
23 
24 #if 0
25 static struct conn_conv conn_conv_nastran[] = {
26  { -1, { -1}} /* terminator */
27 };
28 #endif
29 
30 struct conn_order {
31  int node;
33 };
34 
35 static int conn_comp(const void *c1, const void *c2) {
36  int co1 = ((struct conn_order *)c1)->hecmw_order;
37  int co2 = ((struct conn_order *)c2)->hecmw_order;
38 
39  if (co1 == co2) return 0;
40 
41  if (co1 < co2) return -1;
42 
43  return 1;
44 }
45 
46 int HECMW_convert_connectivity(int from, int hecmw_etype, int *conn) {
47  int i, j, n;
48  struct conn_conv *from_table;
49  struct conn_order order[HECMW_MAX_NODE_MAX];
50 
51  if (conn == NULL) {
53  "Connectivity contversion: 'conn' is NULL");
54  return -1;
55  }
56 
57  switch (from) {
59  return 0;
60 
62  from_table = conn_conv_abaqus;
63  break;
64 #if 0
65 
67  from_table = conn_conv_nastran;
68  break;
69 #endif
70 
71  default:
73  "Connectivity conversion: Unsupported connectivity type");
74  return -1;
75  }
76 
77  if ((n = HECMW_get_max_node(hecmw_etype)) == -1) {
79  "Connectivity conversion: Invalid 'hecmw_etype'");
80  return -1;
81  }
82 
83  for (i = 0; from_table[i].hecmw_etype != -1; i++) {
84  if (from_table[i].hecmw_etype != hecmw_etype) continue;
85 
86  for (j = 0; j < n; j++) {
87  order[j].node = conn[j];
88  order[j].hecmw_order = from_table[i].connectivity[j];
89  }
90 
91  qsort(order, n, sizeof(*order), conn_comp);
92 
93  for (j = 0; j < n; j++) {
94  conn[j] = order[j].node;
95  }
96 
97  break;
98  }
99 
100  return 0;
101 }
#define HECMW_MAX_NODE_MAX
int HECMW_convert_connectivity(int from, int hecmw_etype, int *conn)
#define HECMW_CONNTYPE_ABAQUS
#define HECMW_CONNTYPE_NASTRAN
#define HECMW_CONNTYPE_HECMW
int HECMW_set_error(int errorno, const char *fmt,...)
Definition: hecmw_error.c:37
int HECMW_get_max_node(int etype)
Definition: hecmw_etype.c:413
#define NULL
#define HECMW_ALL_E0101
Definition: hecmw_msgno.h:8
I/O and Utility.
int connectivity[HECMW_MAX_NODE_MAX]