libsurf
Programmer's Documentation

nstrecord.h (r6227/r5385)
1 
2 /* Copyright (C) 2015 David Eller <david@larosterna.com>
3  *
4  * Commercial License Usage
5  * Licensees holding valid commercial licenses may use this file in accordance
6  * with the terms contained in their respective non-exclusive license agreement.
7  * For further information contact david@larosterna.com .
8  *
9  * GNU General Public License Usage
10  * Alternatively, this file may be used under the terms of the GNU General
11  * Public License version 3.0 as published by the Free Software Foundation and
12  * appearing in the file gpl.txt included in the packaging of this file.
13  */
14 
15 #ifndef SURF_NSTRECORD_H
16 #define SURF_NSTRECORD_H
17 
18 #include "nstelements.h"
19 
20 class NstReader;
21 
22 typedef enum { RidUndefined = 0,
23  RidGRID,
24  RidCONM2,
25  RidCMASS2,
26  RidCELAS2,
27  RidCBEAM,
28  RidCTRIA3,
29  RidCTRIAR,
30  RidCTRIA6,
31  RidCQUAD4,
32  RidCQUADR,
33  RidCQUAD8,
34  RidCHEXA,
35  RidCTETRA,
36  RidRBAR,
37  RidRBE2,
38  // RidRBE3,
39  RidMPC,
40  RidCORD2R,
41  RidEigMode,
42  RidPkSubspaceMode,
43  RidDispl,
44  RidElmStress,
45  RidSubcase,
46  RidEndBulk,
47  RidEigTable } NstRecordId;
48 
60 class NstRecord
61 {
62 public:
63 
65  NstRecord() : rid(RidUndefined), lbegin(0), lend(0) {}
66 
68  void firstLine(uint i) {
69  lbegin = i;
70  lend = i+1;
71  }
72 
74  void lastLine(uint i) {
75  lend = (i >= lend) ? i+1 : lend;
76  }
77 
79  void merge(const NstRecord & a) {
80  lbegin = std::min(lbegin, a.lbegin);
81  lend = std::max(lend, a.lend);
82  }
83 
85  uint first() const {return lbegin;}
86 
88  uint last() const {
89  return lend-1;
90  }
91 
93  void id(NstRecordId i) {rid = i;}
94 
96  NstRecordId id() const {return rid;}
97 
99  bool empty() const {return lbegin == lend;}
100 
102  uint size() const {return lend-lbegin;}
103 
105  void clear() {
106  rid = RidUndefined;
107  lbegin = lend = 0;
108  }
109 
111  static bool gscan(const char *s) {
112  const char *pos = strstr(s, "GRID");
113  return (pos == s) ? true : false;
114  }
115 
117  static NstRecordId toposcan(const char *s, bool ispunch=false);
118 
120  static uint evscan(const char *s) {
121  const char key[] = "E I G E N V E C T O R N O .";
122  const char *pos = strstr(s, key);
123  return (pos == 0) ? 0 : atoi(pos+sizeof(key));
124  }
125 
127  static bool eigtablescan(const char *s) {
128  const char key[] = "R E A L E I G E N V A L U E S";
129  const char *pos = strstr(s, key);
130  return (pos != 0);
131  }
132 
134  static bool pkzscan(const char *s) {
135  const char key[] = "EIGENVECTOR FROM THE PK METHOD";
136  const char *pos = strstr(s, key);
137  return (pos != 0);
138  }
139 
141  static int subcasescan(const char *s) {
142  const char key[] = "SUBCASE";
143  const char *pos = strstr(s, key);
144  if (pos == 0)
145  return 0;
146  pos += sizeof(key);
147  while ((*pos != 0) and (not isdigit(*pos)))
148  ++pos;
149  return (*pos != 0) ? strtol(pos, 0, 10) : -1;
150  }
151 
153  static double timescan(const char *s) {
154  const char key[] = "TIME";
155  const char *pos = strstr(s, key);
156  if (pos == 0)
157  return NotDouble;
158  const char *head = strchr(pos+sizeof(key), '=');
159  if (head == 0)
160  return NotDouble;
161  char *tail;
162  double t = strtod(head+1, &tail);
163  return (tail != head+1) ? t : NotDouble;
164  }
165 
167  static bool dspscan(const char *s, bool ispunch) {
168  if (ispunch) {
169  const char key[] = "$DISPLACEMENTS";
170  const char *pos = strstr(s, key);
171  return (pos != 0);
172  } else {
173  const char key[] = "D I S P L A C E M E N T V E C T O R";
174  const char *pos = strstr(s, key);
175  return (pos != 0);
176  }
177  }
178 
180  static bool sigscan(const char *s, bool ispunch) {
181  if (ispunch) {
182  const char key[] = "$ELEMENT STRESSES";
183  const char *pos = strstr(s, key);
184  return (pos != 0);
185  } else {
186  const char key[] = "S T R E S S E S";
187  const char *pos = strstr(s, key);
188  return (pos != 0);
189  }
190  }
191 
193  void process(NstReader & rdr) const;
194 
196  bool mprocess(uint i, NstReader & rdr, bool ispunch) const;
197 
199  void dprocess(NstReader & rdr, bool ispunch) const;
200 
202  void pkprocess(NstReader &rdr) const;
203 
205  void sigprocess(NstReader &rdr) const;
206 
208  void readGrid(NstReader & rdr) const;
209 
210  // debugging : dump record to text stream
211  void dump(const NstReader & rdr, std::ostream & os) const;
212 
213 private:
214 
216  void readBeam(NstReader & rdr) const;
217 
219  void readTria3(NstReader & rdr) const;
220 
222  void readTriaR(NstReader & rdr) const;
223 
225  void readTria6(NstReader & rdr) const;
226 
228  void readQuad4(NstReader & rdr) const;
229 
231  void readQuadR(NstReader & rdr) const;
232 
234  void readQuad8(NstReader & rdr) const;
235 
237  void readHexa(NstReader & rdr) const;
238 
240  void readTetra(NstReader & rdr) const;
241 
243  void readConm2(NstReader & rdr) const;
244 
246  void readCmass2(NstReader & rdr) const;
247 
249  void readCelas2(NstReader & rdr) const;
250 
252  void readRbar(NstReader & rdr) const;
253 
255  void readRbe2(NstReader & rdr) const;
256 
258  void readCord2r(NstReader & rdr) const;
259 
261  bool readPunchMode(uint mi, NstReader &rdr) const;
262 
264  bool readPrintMode(uint mi, NstReader &rdr) const;
265 
267  void appendMode(Matrix &z, uint mi, NstReader &rdr, Real kg=0) const;
268 
269 private:
270 
272  NstRecordId rid;
273 
275  uint lbegin, lend;
276 };
277 
278 typedef std::vector<NstRecord> NstRecordArray;
279 
280 #endif
void readHexa(NstReader &rdr) const
create CHEXA element
Definition: nstrecord.cpp:1154
uint size() const
number of lines in this record
Definition: nstrecord.h:102
bool empty() const
check if record is empty
Definition: nstrecord.h:99
static bool dspscan(const char *s, bool ispunch)
scan for displacement header
Definition: nstrecord.h:167
void appendMode(Matrix &z, uint mi, NstReader &rdr, Real kg=0) const
insert eigenmode into mesh
Definition: nstrecord.cpp:611
bool readPunchMode(uint mi, NstReader &rdr) const
read eigenvector from punch file
Definition: nstrecord.cpp:528
static NstRecordId toposcan(const char *s, bool ispunch=false)
scan line for elements
Definition: nstrecord.cpp:309
uint lbegin
line index : first and one-past last line
Definition: nstrecord.h:275
void readQuad8(NstReader &rdr) const
create CQUAD8 element
Definition: nstrecord.cpp:1117
NstRecordId rid
typecode
Definition: nstrecord.h:272
void readCord2r(NstReader &rdr) const
create new coordinate system
Definition: nstrecord.cpp:1496
NstRecordId id() const
access record id
Definition: nstrecord.h:96
void readRbe2(NstReader &rdr) const
create RBE2 element
Definition: nstrecord.cpp:1454
static uint evscan(const char *s)
scan for eigenvector header
Definition: nstrecord.h:120
void pkprocess(NstReader &rdr) const
add flutter modes in modal subspace
Definition: nstrecord.cpp:625
void dprocess(NstReader &rdr, bool ispunch) const
add displacement to mesh
Definition: nstrecord.cpp:804
void readConm2(NstReader &rdr) const
create CONM2 element
Definition: nstrecord.cpp:1318
NstRecord()
construct record with id and reader ref
Definition: nstrecord.h:65
uint first() const
index of the first line
Definition: nstrecord.h:85
void readTriaR(NstReader &rdr) const
create CTRIAR element
Definition: nstrecord.cpp:1000
uint last() const
index of the last line
Definition: nstrecord.h:88
void lastLine(uint i)
add another line to record
Definition: nstrecord.h:74
void merge(const NstRecord &a)
merge lines from another record
Definition: nstrecord.h:79
bool mprocess(uint i, NstReader &rdr, bool ispunch) const
add modeshape to mesh
Definition: nstrecord.cpp:430
void clear()
clear lines and set id to undefined
Definition: nstrecord.h:105
void readRbar(NstReader &rdr) const
create RBAR element
Definition: nstrecord.cpp:1426
void sigprocess(NstReader &rdr) const
add stress results for supported element types
Definition: nstrecord.cpp:671
void readGrid(NstReader &rdr) const
read grid point coordinates and gid
Definition: nstrecord.cpp:916
void readCmass2(NstReader &rdr) const
create CMASS2 element
Definition: nstrecord.cpp:1365
static bool sigscan(const char *s, bool ispunch)
scan for stress header
Definition: nstrecord.h:180
bool readPrintMode(uint mi, NstReader &rdr) const
read eigenvactor from .f06 file
Definition: nstrecord.cpp:470
void readTetra(NstReader &rdr) const
create CTETRA element
Definition: nstrecord.cpp:1257
static bool gscan(const char *s)
scan line for grid point
Definition: nstrecord.h:111
void readQuadR(NstReader &rdr) const
create CQUADR element
Definition: nstrecord.cpp:1090
void readBeam(NstReader &rdr) const
create CBEAM element
Definition: nstrecord.cpp:947
void id(NstRecordId i)
access record id
Definition: nstrecord.h:93
Reads nastran files.
Definition: nstreader.h:58
A group of lines in a NASTRAN text file.
Definition: nstrecord.h:60
static bool pkzscan(const char *s)
scan for flutter eigenvector header
Definition: nstrecord.h:134
void firstLine(uint i)
set first line of record
Definition: nstrecord.h:68
void readTria6(NstReader &rdr) const
create CTRIA6 element
Definition: nstrecord.cpp:1026
void process(NstReader &rdr) const
add elements to mesh, if any
Definition: nstrecord.cpp:371
static double timescan(const char *s)
scan for timestep identifier
Definition: nstrecord.h:153
static bool eigtablescan(const char *s)
scan for eigenvector header
Definition: nstrecord.h:127
void readTria3(NstReader &rdr) const
create CTRIA3 element
Definition: nstrecord.cpp:974
static int subcasescan(const char *s)
scan for subcase identifier
Definition: nstrecord.h:141
void readCelas2(NstReader &rdr) const
create CELAS2 element
Definition: nstrecord.cpp:1391
void readQuad4(NstReader &rdr) const
create CQUAD4 element
Definition: nstrecord.cpp:1058
Generated on Wed Jan 19 2022 03:03:15 for libsurf by   doxygen 1.8.5