libsurf
Programmer's Documentation

nstreader.h (r6227/r5389)
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_NSTREADER_H
16 #define SURF_NSTREADER_H
17 
18 #include "nstmesh.h"
19 #include "nstelements.h"
20 #include "nstrecord.h"
21 #include "nstcoordsys.h"
22 #include <genua/csrmatrix.h>
23 #include <genua/logger.h>
24 
58 class NstReader : public Logger
59 {
60 public:
61 
63  NstReader(NstMesh & m) : msh(m), solSequence(0) {}
64 
66  const NstMesh & mesh() const {return msh;}
67 
69  NstMesh & mesh() {return msh;}
70 
72  const std::string & line(uint i) const {
73  assert(i < lines.size());
74  return lines[i];
75  }
76 
78  uint addNode(const Vct3 & p, uint gid, uint cid = 0, uint cd = 0) {
79  uint inpos = msh.addVertex(p, gid);
80  if (cid != 0)
81  insert_once( cid2gid[cid], gid );
82  if (cd != 0)
83  insert_once( cid2def[cd], gid );
84  return inpos;
85  }
86 
88  void addElement(Element *ep) {
89  msh.addElement(ep);
90  }
91 
93  void addCoordSys(uint cid, const NstCoordSys & cs) {
94  crdsys[cid] = cs;
95  }
96 
98  void transformMode(Matrix & z) const;
99 
101  void read(const std::string & fname);
102 
104  static void readOp4Ascii(const std::string & fname, CsrMatrix<Real> & mtx);
105 
106 private:
107 
109  void readLines(std::istream & in);
110 
112  void parseTopo();
113 
115  uint parseEvec();
116 
118  uint parsePkz();
119 
121  uint parseDisp();
122 
124  uint parseElmStress();
125 
127  void transformPoints();
128 
129 private:
130 
131  typedef std::map<uint, Indices> Cid2GidsMap;
132  typedef std::map<uint, NstCoordSys> CidMap;
133 
136 
138  StringArray lines;
139 
141  NstRecordArray toprec, evrec, pkzrec, dsprec, estressrec;
142 
144  Cid2GidsMap cid2gid, cid2def;
145 
147  CidMap crdsys;
148 
151 
154 
156  bool ispunch;
157 };
158 
159 #endif
bool isf06Output
true if file is .f06 output (determined from extension...)
Definition: nstreader.h:153
Nastran mesh.
Definition: nstmesh.h:35
void transformMode(Matrix &z) const
interface for NstRecord: transform modeshape to global
Definition: nstreader.cpp:508
void transformPoints()
transform points not in default coordinates
Definition: nstreader.cpp:486
Cid2GidsMap cid2gid
remember coordinate system indices for grid points
Definition: nstreader.h:144
void readLines(std::istream &in)
read file line-by line
Definition: nstreader.cpp:30
NstMesh & msh
mesh where data is stored
Definition: nstreader.h:135
uint parseElmStress()
filter lines and read element stress data (limited subset supported)
Definition: nstreader.cpp:420
const std::string & line(uint i) const
access line with index i
Definition: nstreader.h:72
NstMesh & mesh()
mesh to which elements are attached
Definition: nstreader.h:69
uint parseDisp()
filter lines and read displacements
Definition: nstreader.cpp:326
const NstMesh & mesh() const
mesh to which elements are attached
Definition: nstreader.h:66
uint addNode(const Vct3 &p, uint gid, uint cid=0, uint cd=0)
add grid point to mesh
Definition: nstreader.h:78
Cartesian coordinate system (Nastran)
Definition: nstcoordsys.h:26
int solSequence
solution type (SOL = ...), if identified, else zero
Definition: nstreader.h:150
void read(const std::string &fname)
read file
Definition: nstreader.cpp:530
void addCoordSys(uint cid, const NstCoordSys &cs)
add coordinate system
Definition: nstreader.h:93
uint parsePkz()
filter lines and read flutter modes in modal subspace
Definition: nstreader.cpp:283
uint addElement(Element *ep)
Reads nastran files.
Definition: nstreader.h:58
NstReader(NstMesh &m)
initialize with mesh object in which data is stored
Definition: nstreader.h:63
uint parseEvec()
filter lines and read eigenmode shapes
Definition: nstreader.cpp:199
static void readOp4Ascii(const std::string &fname, CsrMatrix< Real > &mtx)
static utility to read NASTRAN system matrices
Definition: nstreader.cpp:663
void parseTopo()
filter lines and create records for topology elements
Definition: nstreader.cpp:146
StringArray lines
buffer for lines stored
Definition: nstreader.h:138
void addElement(Element *ep)
add element to mesh
Definition: nstreader.h:88
CidMap crdsys
stores coordinate systems
Definition: nstreader.h:147
bool ispunch
true if file is a punch file (.pch)
Definition: nstreader.h:156
NstRecordArray toprec
buffer for string records
Definition: nstreader.h:141
uint addVertex(const Vct3 &p, uint gid)
add a vertex with GID
Definition: nstmesh.cpp:25
Generated on Wed Jan 19 2022 03:03:15 for libsurf by   doxygen 1.8.5