FrontISTR 5.2.0
Large-scale structural analysis program with finit element method
Loading...
Searching...
No Matches
CHECDB_Element.cpp
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 CHECDB_Element Ver.1.0
7*/
8
9#include <set>
10#include "CHECDB.h"
11#include "CHECData.h"
12
13using namespace std;
14
16 switch (type) {
17 case 111:
18 return 2;
19
20 case 112:
21 return 3;
22
23 case 231:
24 return 3;
25
26 case 232:
27 return 6;
28
29 case 241:
30 return 4;
31
32 case 242:
33 return 8;
34
35 case 341:
36 return 4;
37
38 case 342:
39 return 10;
40
41 case 351:
42 return 6;
43
44 case 352:
45 return 15;
46
47 case 361:
48 return 8;
49
50 case 362:
51 return 20;
52
53 case 541:
54 return 8;
55
56 case 542:
57 return 16;
58
59 case 611:
60 return 2;
61
62 case 612:
63 return 3;
64
65 case 731:
66 return 3;
67
68 case 732:
69 return 6;
70
71 case 741:
72 return 4;
73
74 case 742:
75 return 8;
76
77 default:
78 return 0;
79 }
80}
81
83 switch (type) {
84 case 111:
85 return 0;
86
87 case 112:
88 return 0;
89
90 case 231:
91 return 3;
92
93 case 232:
94 return 3;
95
96 case 241:
97 return 4;
98
99 case 242:
100 return 4;
101
102 case 341:
103 return 4;
104
105 case 342:
106 return 4;
107
108 case 351:
109 return 5;
110
111 case 352:
112 return 5;
113
114 case 361:
115 return 6;
116
117 case 362:
118 return 6;
119
120 case 541:
121 return 2;
122
123 case 542:
124 return 2;
125
126 case 611:
127 return 0;
128
129 case 612:
130 return 0;
131
132 case 731:
133 return 1;
134
135 case 732:
136 return 1;
137
138 case 741:
139 return 1;
140
141 case 742:
142 return 1;
143
144 default:
145 return 0;
146 }
147}
148
150 switch (type) {
151 case 111:
152 return 1;
153
154 case 112:
155 return 1;
156
157 case 231:
158 return 2;
159
160 case 232:
161 return 2;
162
163 case 241:
164 return 2;
165
166 case 242:
167 return 2;
168
169 case 341:
170 return 3;
171
172 case 342:
173 return 3;
174
175 case 351:
176 return 3;
177
178 case 352:
179 return 3;
180
181 case 361:
182 return 3;
183
184 case 362:
185 return 3;
186
187 case 541:
188 return 3;
189
190 case 542:
191 return 3;
192
193 case 611:
194 return 3;
195
196 case 612:
197 return 3;
198
199 case 731:
200 return 6;
201
202 case 732:
203 return 6;
204
205 case 741:
206 return 6;
207
208 case 742:
209 return 6;
210
211 default:
212 return 0;
213 }
214}
215
216int *Connectivity(int type, int face_id, int &n) {
217 static int tc111[][20] = {{0, 1}};
218 static int tn111[] = {2, 0};
219 static int tc112[][20] = {{0, 1, 2}};
220 static int tn112[] = {2, 0};
221 static int tc231[][20] = {{1, 2}, {2, 0}, {0, 1}};
222 static int tn231[] = {2, 2, 2, 0};
223 static int tc232[][20] = {{1, 3, 2}, {2, 4, 0}, {0, 5, 1}};
224 static int tn232[] = {3, 3, 3, 0};
225 static int tc241[][20] = {{3, 0}, {1, 2}, {0, 1}, {2, 3}};
226 static int tn241[] = {2, 2, 2, 2, 0};
227 static int tc242[][20] = {{3, 7, 0}, {1, 5, 2}, {0, 4, 1}, {2, 6, 3}};
228 static int tn242[] = {3, 3, 3, 3, 0};
229 static int tc341[][20] = {{1, 2, 3}, {0, 3, 2}, {0, 1, 3}, {0, 2, 1}};
230 static int tn341[] = {3, 3, 3, 3, 0};
231 static int tc342[][20] = {{1, 4, 2, 9, 3, 8},
232 {0, 7, 3, 9, 2, 5},
233 {0, 6, 1, 8, 3, 7},
234 {0, 5, 2, 4, 1, 6}};
235 static int tn342[] = {6, 6, 6, 6, 0};
236 static int tc351[][20] = {
237 {1, 2, 5, 4}, {2, 0, 3, 5}, {0, 1, 4, 3}, {2, 1, 0}, {3, 4, 5}};
238 static int tn351[] = {4, 4, 4, 3, 3, 0};
239 static int tc352[][20] = {{1, 6, 2, 14, 5, 9, 4, 13},
240 {2, 7, 0, 12, 3, 10, 5, 14},
241 {0, 8, 1, 13, 4, 11, 3, 12},
242 {2, 6, 1, 8, 0, 7},
243 {3, 11, 4, 9, 5, 10}};
244 static int tn352[] = {8, 8, 8, 6, 6, 0};
245 static int tc361[][20] = {{3, 0, 4, 7}, {1, 2, 6, 5}, {0, 1, 5, 4},
246 {2, 3, 7, 6}, {3, 2, 1, 0}, {4, 5, 6, 7}};
247 static int tn361[] = {4, 4, 4, 4, 4, 4, 0};
248 static int tc362[][20] = {
249 {3, 11, 0, 16, 4, 15, 7, 19}, {1, 9, 2, 18, 6, 13, 5, 17},
250 {0, 8, 1, 17, 5, 12, 4, 16}, {2, 10, 3, 19, 7, 14, 6, 18},
251 {3, 10, 2, 9, 1, 8, 0, 11}, {4, 12, 5, 13, 6, 14, 7, 15}};
252 static int tn362[] = {8, 8, 8, 8, 8, 8, 0};
253 static int tc541[][20] = {{3, 2, 1, 0}, {4, 5, 6, 7}};
254 static int tn541[] = {4, 4, 0};
255 static int tc542[][20] = {{3, 10, 2, 9, 1, 8, 0, 11},
256 {4, 12, 5, 13, 6, 14, 7, 15}};
257 static int tn542[] = {8, 8, 0};
258 static int tc611[][20] = {{0, 1}};
259 static int tn611[] = {2, 0};
260 static int tc612[][20] = {{0, 1, 2}};
261 static int tn612[] = {3, 0};
262 static int tc731[][20] = {{0, 1, 2}, {2, 1, 0}};
263 static int tn731[] = {3, 3, 0};
264 static int tc732[][20] = {{0, 3, 1, 4, 2, 5}, {2, 4, 1, 3, 0, 5}};
265 static int tn732[] = {6, 6, 0};
266 static int tc741[][20] = {{0, 1, 2, 3}, {3, 2, 1, 0}};
267 static int tn741[] = {4, 4, 0};
268 static int tc742[][20] = {{0, 4, 1, 5, 2, 6, 3, 7}, {3, 6, 2, 5, 1, 4, 0, 7}};
269 static int tn742[] = {4, 4, 0};
270#define CODE_GENERATE(x) \
271 case x: \
272 n = tn##x[face_id]; \
273 return tc##x[face_id];
274
275 switch (type) {
276 CODE_GENERATE(111)
277 CODE_GENERATE(112)
278 CODE_GENERATE(231)
279 CODE_GENERATE(232)
280 CODE_GENERATE(241)
281 CODE_GENERATE(242)
282 CODE_GENERATE(341)
283 CODE_GENERATE(342)
284 CODE_GENERATE(351)
285 CODE_GENERATE(352)
286 CODE_GENERATE(361)
287 CODE_GENERATE(362)
288 CODE_GENERATE(541)
289 CODE_GENERATE(542)
290 CODE_GENERATE(611)
291 CODE_GENERATE(612)
292 CODE_GENERATE(731)
293 CODE_GENERATE(732)
294 CODE_GENERATE(741)
295 CODE_GENERATE(742)
296
297 default:
298 assert(0);
299 }
300
301 return 0;
302}
303
305 const int type_list[] = {111, 112, 231, 232, 241, 242, 351, 352, 361,
306 362, 541, 542, 611, 612, 731, 732, 741, 742};
307 int type_n = sizeof(type_list);
308
309 for (int i = 0; i < type_n; i++) {
310 if (type == type_list[i]) return true;
311 }
312
313 return false;
314}
315
317 : CHECDataBlock(HECDB_ELEMENT), type(0), sec_id(0), option(0), ElemList() {}
318
320
322
324 if (ElemList.size() == 0) return;
325
326 hecd->WriteHeader("!ELEMENT", "I", "TYPE", type);
327 int n = NodeNumber(type);
328 set<CElemItem>::iterator iter;
329
330 for (iter = ElemList.begin(); iter != ElemList.end(); iter++) {
331 hecd->ClearDataLineBuffer();
332 hecd->AddDataLineItems("I", iter->ID);
333
334 for (int i = 0; i < n; i++) {
335 hecd->AddDataLineItems("I", iter->node[i]);
336 }
337
338 hecd->WriteDataLine();
339 }
340}
341
343 set<CElemItem>::iterator iter;
344
345 for (iter = ElemList.begin(); iter != ElemList.end(); iter++) {
346 if (iter->ID == id) return (CElemItem *)&(*iter);
347 }
348
349 return 0;
350 /*
351 iter = find( ElemList.begin(), ElemList.end(), checdb_id_class(id) );
352 if( iter == ElemList.end()) return 0;
353 return (CElemItem*)&(*iter);
354 */
355}
356
357bool CHECDB_Element::Read(CHECData *hecd, char *header_line) {
358 int rcode[10];
359 hecd->ParseHeader(header_line, rcode, "I", "TYPE", &type);
360 int n = NodeNumber(type);
361
362 if (n <= 0) return false;
363
364 CElemItem item(type);
365 char line[256];
366
367 while (hecd->ReadLine(line)) {
368 if (line[0] == '!') {
369 hecd->PushReadLine(line);
370 break;
371 }
372
373 char *token = strtok(line, ",\r\n");
374
375 if (!token) return false;
376
377 if (sscanf(token, "%d", &item.ID) != 1) return false;
378
379 for (int i = 0; i < n; i++) {
380 token = strtok(0, ",\r\n");
381
382 if (!token) return false;
383
384 int nid;
385
386 if (sscanf(token, "%d", &nid) != 1) return false;
387
388 item.node[i] = nid;
389 }
390
391 ElemList.insert(item);
392 }
393
394 return true;
395}
@ HECDB_ELEMENT
Definition: CHECDB.h:20
int * Connectivity(int type, int face_id, int &n)
#define CODE_GENERATE(x)
virtual bool Read(class CHECData *hecd, char *header_line)
CElemItem * GetElem(int id)
static int DOFNumber(int type)
static int NodeNumber(int type)
virtual ~CHECDB_Element()
static int FaceNumber(int type)
static bool CheckType(int type)
std::set< CElemItem > ElemList
Definition: CHECDB.h:96
virtual void Clear()
virtual void Write(class CHECData *hecd)
virtual void WriteDataLine()
Definition: CHECData.cpp:234
virtual bool ParseHeader(char *header_line, int *rcode, const char *fmt,...)
Definition: CHECData.cpp:506
virtual bool ReadLine(char *s, int size=256)
Definition: CHECData.cpp:307
virtual void WriteHeader(const char *name, const char *fmt="",...)
Definition: CHECData.cpp:68
virtual void ClearDataLineBuffer()
Definition: CHECData.cpp:199
virtual void AddDataLineItems(const char *fmt,...)
Definition: CHECData.cpp:201
virtual void PushReadLine(const char *s)
Definition: CHECData.cpp:328