FrontISTR 5.2.0
Large-scale structural analysis program with finit element method
Loading...
Searching...
No Matches
conv_neu2fstr_heat.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/* conv_neu2fstr_static ver.1.0 */
6
7#include <vector>
8#include <stdlib.h>
9
10#include "conv_neu2fstr_heat.h"
11#include "cconv_mat.h"
12#include "conv_util.h"
13
14using namespace std;
15using namespace n2h_util;
16
17static void ItoA(int i, char *s) { sprintf(s, "%d", i); }
18
19//-----------------------------------------------------------------------------
20// FIXTEMP
21//-----------------------------------------------------------------------------
22
23namespace {
24
25class cntemp {
26 public:
27 int nid;
28 double value;
29 cntemp(int id = -1, double v = 0) : nid(id), value(v) {}
30};
31
32inline bool operator==(const cntemp &a, const cntemp &b) {
33 return a.nid == b.nid;
34}
35inline bool operator<(const cntemp &a, const cntemp &b) {
36 return a.nid < b.nid;
37}
38inline bool operator>(const cntemp &a, const cntemp &b) {
39 return a.nid > b.nid;
40}
41
42} // of namespace
43
44static void SetFixtemp(CNFData &neu, CHECData &hec) {
45 if (neu.DB_507.size() == 0) return;
46
47 set<cntemp> ntlist;
48 vector<CNFDB_507 *>::iterator iter;
49
50 for (iter = neu.DB_507.begin(); iter != neu.DB_507.end(); iter++) {
51 CNFDB_507 *p = *iter;
52 // node temperature -------------------------------------
53 vector<CNFDB_507::ctemp_load_rec>::iterator siter;
54
55 for (siter = p->ndtemp_load_list.begin();
56 siter != p->ndtemp_load_list.end(); siter++) {
57 ntlist.insert(cntemp(siter->ID, siter->temp));
58 }
59
60 // element temperature ----------------------------------
61 for (siter = p->eltemp_load_list.begin();
62 siter != p->eltemp_load_list.end(); siter++) {
63 CHECDB_Element::CElemItem *e = hec.GetElemItem(siter->ID);
64
65 if (!e) {
66 printf("##Warning : Not exist element %d (FIXTEMP)\n", (int)siter->ID);
67 continue;
68 }
69
70 for (int i = 0; i < e->node_n; i++) {
71 ntlist.insert(cntemp(e->node[i], siter->temp));
72 }
73 }
74 }
75
76 if (ntlist.size() > 0) {
77 CFSTRDB_Fixtemp *dblock = new CFSTRDB_Fixtemp();
78 set<cntemp>::iterator it;
79
80 for (it = ntlist.begin(); it != ntlist.end(); it++) {
81 char name[256];
82 ItoA(it->nid, name);
83 CFSTRDB_Fixtemp::CItem item(name, it->value);
84 dblock->ItemList.push_back(item);
85 }
86
87 hec.DB.push_back(dblock);
88 }
89}
90
91//-----------------------------------------------------------------------------
92// CFLUX
93//-----------------------------------------------------------------------------
94
95static void SetCFlux(CNFData &neu, CHECData &hec) {
96 const int FEA_load_nHeatFlux = 10;
97
98 if (neu.DB_507.size() == 0) return;
99
100 CFSTRDB_CFlux *dblock = new CFSTRDB_CFlux();
101 vector<CNFDB_507 *>::iterator iter;
102
103 for (iter = neu.DB_507.begin(); iter != neu.DB_507.end(); iter++) {
104 CNFDB_507 *p = *iter;
105 vector<CNFDB_507::cstructural_load_rec>::iterator siter;
106
107 for (siter = p->structural_load_list.begin();
108 siter != p->structural_load_list.end(); siter++) {
109 if (siter->loadtype != FEA_load_nHeatFlux) continue;
110
111 char name[256];
112 ItoA(siter->loadID, name);
113 CFSTRDB_CFlux::CItem item(name, siter->value[0]);
114 dblock->ItemList.push_back(item);
115 }
116 }
117
118 if (dblock->ItemList.size() > 0) {
119 hec.DB.push_back(dblock);
120
121 } else {
122 delete dblock;
123 }
124}
125
126//-----------------------------------------------------------------------------
127// DFLUX
128//-----------------------------------------------------------------------------
129
130static void SetDFlux(CNFData &neu, CHECData &hec) {
131 const int FEA_load_eHeatFlux = 44;
132 const int FEA_load_eHeatGen = 47;
133
134 if (neu.DB_507.size() == 0) return;
135
136 CFSTRDB_DFlux *dblock = new CFSTRDB_DFlux();
137 vector<CNFDB_507 *>::iterator iter;
138
139 for (iter = neu.DB_507.begin(); iter != neu.DB_507.end(); iter++) {
140 CNFDB_507 *p = *iter;
141 vector<CNFDB_507::cstructural_load_rec>::iterator siter;
142
143 for (siter = p->structural_load_list.begin();
144 siter != p->structural_load_list.end(); siter++) {
145 if (siter->loadtype != FEA_load_eHeatFlux &&
146 siter->loadtype != FEA_load_eHeatGen)
147 continue;
148
149 int eid = siter->loadID;
150 int surf_no = siter->dof_face[0];
151 int hec_e_type = hec.GetElemType(eid);
152
153 if (hec_e_type == 0) continue;
154
155 int load_type;
156 double load;
157
158 if (siter->loadtype == FEA_load_eHeatFlux) {
159 int fg_front;
160 load_type =
161 CFSTRDB_DFlux::TYPE_S0 + hec_face_no(hec_e_type, surf_no, fg_front);
162 load = fg_front ? siter->value[0] : -siter->value[0];
163
164 } else {
165 load_type = CFSTRDB_DFlux::TYPE_BF;
166 load = siter->value[0];
167 }
168
169 char name[256];
170 ItoA(siter->loadID, name);
171 CFSTRDB_DFlux::CItem item(name, load_type, load);
172 dblock->ItemList.push_back(item);
173 }
174 }
175
176 if (dblock->ItemList.size() > 0) {
177 hec.DB.push_back(dblock);
178
179 } else {
180 delete dblock;
181 }
182}
183
184//-----------------------------------------------------------------------------
185// FILM
186//-----------------------------------------------------------------------------
187
188static void SetFilm(CNFData &neu, CHECData &hec) {
189 const int FEA_load_eConvection = 45;
190
191 if (neu.DB_507.size() == 0) return;
192
193 CFSTRDB_Film *dblock = new CFSTRDB_Film();
194 vector<CNFDB_507 *>::iterator iter;
195
196 for (iter = neu.DB_507.begin(); iter != neu.DB_507.end(); iter++) {
197 CNFDB_507 *p = *iter;
198 vector<CNFDB_507::cstructural_load_rec>::iterator siter;
199
200 for (siter = p->structural_load_list.begin();
201 siter != p->structural_load_list.end(); siter++) {
202 if (siter->loadtype != FEA_load_eConvection) continue;
203
204 int eid = siter->loadID;
205 int surf_no = siter->dof_face[0];
206 int hec_e_type = hec.GetElemType(eid);
207
208 if (hec_e_type == 0) continue;
209
210 double value = siter->value[0]; // coeff of heat transfer
211 double sink = siter->value[2]; // emvironmental temperature
212 int fg_front;
213 int load_type =
214 CFSTRDB_Film::TYPE_F0 + hec_face_no(hec_e_type, surf_no, fg_front);
215 char name[256];
216 ItoA(siter->loadID, name);
217 CFSTRDB_Film::CItem item(name, load_type, value, sink);
218 dblock->ItemList.push_back(item);
219 }
220 }
221
222 if (dblock->ItemList.size() > 0) {
223 hec.DB.push_back(dblock);
224
225 } else {
226 delete dblock;
227 }
228}
229
230//-----------------------------------------------------------------------------
231// RADIATE
232//-----------------------------------------------------------------------------
233
234static void SetRadiate(CNFData &neu, CHECData &hec) {
235 const int FEA_load_eRadiation = 46;
236
237 if (neu.DB_507.size() == 0) return;
238
239 CFSTRDB_Radiate *dblock = new CFSTRDB_Radiate();
240 vector<CNFDB_507 *>::iterator iter;
241
242 for (iter = neu.DB_507.begin(); iter != neu.DB_507.end(); iter++) {
243 CNFDB_507 *p = *iter;
244 vector<CNFDB_507::cstructural_load_rec>::iterator siter;
245
246 for (siter = p->structural_load_list.begin();
247 siter != p->structural_load_list.end(); siter++) {
248 if (siter->loadtype != FEA_load_eRadiation) continue;
249
250 int eid = siter->loadID;
251 int surf_no = siter->dof_face[0];
252 int hec_e_type = hec.GetElemType(eid);
253
254 if (hec_e_type == 0) continue;
255
256 double value = siter->value[0];
257 double sink = siter->value[2]; // emvironmental temperature
258 int fg_front;
259 int load_type =
260 CFSTRDB_Radiate::TYPE_R0 + hec_face_no(hec_e_type, surf_no, fg_front);
261 char name[256];
262 ItoA(siter->loadID, name);
263 CFSTRDB_Radiate::CItem item(name, load_type, value, sink);
264 dblock->ItemList.push_back(item);
265 }
266 }
267
268 if (dblock->ItemList.size() > 0) {
269 hec.DB.push_back(dblock);
270
271 } else {
272 delete dblock;
273 }
274}
275
276//=============================================================================
277// conv_neu2fstr_heat
278//=============================================================================
279
281 SetFixtemp(neu, hec);
282 SetCFlux(neu, hec);
283 SetDFlux(neu, hec);
284 SetFilm(neu, hec);
285 SetRadiate(neu, hec);
286}
std::vector< CItem > ItemList
Definition: CFSTRDB.h:399
std::vector< CItem > ItemList
Definition: CFSTRDB.h:445
std::vector< CItem > ItemList
Definition: CFSTRDB.h:520
std::vector< CItem > ItemList
Definition: CFSTRDB.h:373
std::vector< CItem > ItemList
Definition: CFSTRDB.h:601
virtual int GetElemType(int id)
Definition: CHECData.cpp:696
std::vector< CHECDataBlock * > DB
Definition: CHECData.h:30
virtual class CHECDB_Element::CElemItem * GetElemItem(int id)
Definition: CHECData.cpp:682
std::vector< ctemp_load_rec > eltemp_load_list
Definition: CNFDB_507.h:233
std::vector< cstructural_load_rec > structural_load_list
Definition: CNFDB_507.h:230
std::vector< ctemp_load_rec > ndtemp_load_list
Definition: CNFDB_507.h:232
void conv_neu2fstr_heat(CNFData &neu, CHECData &hec)
bool operator<(const cbitem &a, const cbitem &b)
bool operator>(const cbitem &a, const cbitem &b)
bool operator==(const cbitem &a, const cbitem &b)
int hec_face_no(int hec_etype, int neu_face, int &fg_front)
Definition: conv_util.h:36