FrontISTR  5.7.0
Large-scale structural analysis program with finit element method
CFSTRDB_Radiate.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  CFSTRDB_Radiate Ver.1.0
7 */
8 
9 #include "CFSTRDB.h"
10 #include "CHECData.h"
11 
12 using namespace std;
13 using namespace hecd_util;
14 
15 // static method
16 
17 const char *CFSTRDB_Radiate::LoadTypeName(int type) {
18  const char *pn[] = {"R0", "R1", "R2", "R3", "R4", "R5", "R6", "unknown"};
19 
20  if (type < 0 || type >= TypeNumber()) return "";
21 
22  return pn[type];
23 }
24 
26  : CFSTRDataBlock(FSTRDB_RADIATE), ItemList() {
27  amp1[0] = 0;
28  amp2[0] = 0;
29 }
30 
32 
34  ItemList.clear();
35  amp1[0] = 0;
36  amp2[0] = 0;
37 }
38 
40  char buff[256];
41 
42  if (ItemList.size() == 0) return;
43 
44  strcpy(buff, "!RADIATE");
45 
46  if (amp1[0] != 0) {
47  strcat(buff, ",AMP1=");
48  strcat(buff, amp1);
49  }
50 
51  if (amp2[0] != 0) {
52  strcat(buff, ",AMP2=");
53  strcat(buff, amp2);
54  }
55 
56  hecd->WriteHeader(buff);
57  vector<CItem>::iterator iter;
58 
59  for (iter = ItemList.begin(); iter != ItemList.end(); iter++) {
60  hecd->WriteData("SSFF", iter->egrp, LoadTypeName(iter->type), iter->value,
61  iter->sink);
62  }
63 }
64 
65 bool CFSTRDB_Radiate::Read(CHECData *hecd, char *header_line) {
66  int rcode[10];
67  char s[256];
68  int type;
69  amp1[0] = 0;
70  amp2[0] = 0;
71 
72  if (!hecd->ParseHeader(header_line, rcode, "SS", "AMP1", amp1, "AMP2", amp2))
73  return false;
74 
75  while (1) {
76  CItem item;
77  bool fg =
78  hecd->ReadData(rcode, "SSFF", item.egrp, s, &item.value, &item.sink);
79 
80  if (!fg) break;
81 
82  cleanup_token(s);
83  toupper(s);
84 
85  for (type = 0; type < TypeNumber(); type++) {
86  if (strcmp(LoadTypeName(type), s) == 0) break;
87  }
88 
89  if (type == TypeNumber()) return false;
90 
91  item.type = type;
92  ItemList.push_back(item);
93  }
94 
95  return true;
96 }
CHECData::ParseHeader
virtual bool ParseHeader(char *header_line, int *rcode, const char *fmt,...)
Definition: CHECData.cpp:506
CHECData.h
CFSTRDB_Radiate::Read
virtual bool Read(class CHECData *hecd, char *header_line)
Definition: CFSTRDB_Radiate.cpp:65
hecd_util::toupper
void toupper(char *s)
Definition: hecd_util.cpp:40
CFSTRDB_Radiate::CItem::value
double value
Definition: CFSTRDB.h:581
CFSTRDB_Radiate::LoadTypeName
static const char * LoadTypeName(int type)
Definition: CFSTRDB_Radiate.cpp:17
CFSTRDB.h
hecd_util::cleanup_token
void cleanup_token(char *s)
Definition: hecd_util.cpp:16
CFSTRDB_Radiate::CItem::egrp
char egrp[hec_name_size]
Definition: CFSTRDB.h:579
CFSTRDB_Radiate::amp2
char amp2[hec_name_size]
Definition: CFSTRDB.h:597
CHECData::WriteData
virtual void WriteData(const char *fmt,...)
Definition: CHECData.cpp:162
CFSTRDB_Radiate::~CFSTRDB_Radiate
virtual ~CFSTRDB_Radiate()
Definition: CFSTRDB_Radiate.cpp:31
CHECData::ReadData
virtual bool ReadData(int *rcode, const char *fmt,...)
Definition: CHECData.cpp:548
CFSTRDB_Radiate::TypeNumber
static int TypeNumber()
Definition: CFSTRDB.h:574
CFSTRDB_Radiate::CFSTRDB_Radiate
CFSTRDB_Radiate()
Definition: CFSTRDB_Radiate.cpp:25
CFSTRDB_Radiate::ItemList
std::vector< CItem > ItemList
Definition: CFSTRDB.h:601
CHECData::WriteHeader
virtual void WriteHeader(const char *name, const char *fmt="",...)
Definition: CHECData.cpp:68
CFSTRDB_Radiate::amp1
char amp1[hec_name_size]
Definition: CFSTRDB.h:596
FSTRDB_RADIATE
@ FSTRDB_RADIATE
Definition: CFSTRDB.h:51
CHECData
Definition: CHECData.h:25
CFSTRDB_Radiate::CItem
Definition: CFSTRDB.h:577
hecd_util
Definition: hecd_util.cpp:11
CFSTRDB_Radiate::Write
virtual void Write(class CHECData *hecd)
Definition: CFSTRDB_Radiate.cpp:39
CFSTRDataBlock
Definition: CFSTRDB.h:58
CFSTRDB_Radiate::CItem::type
int type
Definition: CFSTRDB.h:580
CFSTRDB_Radiate::CItem::sink
double sink
Definition: CFSTRDB.h:582
CFSTRDB_Radiate::Clear
virtual void Clear()
Definition: CFSTRDB_Radiate.cpp:33