FEDEM Model Database  R8.0
Source code of the FEDEM model database
FFlNastranReader.H
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: 2023 SAP SE
2 //
3 // SPDX-License-Identifier: Apache-2.0
4 //
5 // This file is part of FEDEM - https://openfedem.org
7 
8 #ifndef FFL_NASTRAN_READER_H
9 #define FFL_NASTRAN_READER_H
10 
12 #include "FFlLib/FFlUtils.H"
15 #include <string>
16 #include <vector>
17 #include <map>
18 #include <set>
19 
20 
21 #define DEF_PROCESSOR(rec) bool process_##rec (std::vector<std::string>& entry);
22 
23 class FFlCrossSection;
24 class FFaCheckSum;
25 
26 #ifdef FF_NAMESPACE
27 namespace FF_NAMESPACE {
28 #endif
29 
30 class FFlAttributeBase;
31 class FFlElementBase;
32 class FFlLoadBase;
33 class FFlGroup;
34 
35 
37 {
38 public:
39 
41  {
42  UNDEFINED = 0,
43  CONT_FIELD = -2,
44  FREE_FIELD = -1,
45  SMALL_FIELD = 8,
46  LARGE_FIELD = 16
47  };
48 
50  {
53  spherical
54  };
55 
56  struct BulkEntry
57  {
58  std::string name;
60  std::vector<std::string> fields;
61  std::string cont;
62  };
63 
64 private:
65 
66  struct CORD
67  {
68  bool isComputed = false;
69  coordSysType type = rectangular;
70  int RID = 0;
71  int G[3] = { 0, 0, 0 };
76  };
77 
78  struct GRDSET
79  {
80  int CP = 0;
81  int CD = 0;
82  int PS = 0;
83  int SEID = 0;
84  };
85 
86  struct BEAMOR
87  {
88  int PID = 0;
89  int G0 = 0;
91  bool isBAR;
92  bool basic = false;
93  bool empty[5] = { false, false, false, false, false };
94  BEAMOR(bool b = false) : isBAR(b) {}
95  };
96 
97  using IntPair = std::pair<int,int>;
98  using IntMap = std::map<int,int>;
99  using ElementMap = std::map<int,FFlElementBase*>;
100  using LoadFaceMap = std::map<FFlLoadBase*,IntPair>;
101 
102  std::map<std::string,int> ignoredBulk; // Number of unsupported entries
103  std::map<std::string,int> sxErrorBulk; // Number of syntax errors
104 
105  std::vector<BulkEntry> ucEntries; // List of uncompleted bulk entries
106  std::set<int> beamPIDnsm; // Set of PIDs for beam elements with NSM property
107  std::set<int> shellPIDnsm; // Set PIDs for shell elements with NSM property
108 
109  std::map<int,CORD*> cordSys; // coordinate system ID --> coordinate system
110  IntMap nodeStat; // node ID --> dof status (exteral/internal)
111  IntMap nodeCPID; // node ID --> coordinate system ID for positions
112  IntMap nodeCDID; // node ID --> coordinate system ID for displacements
113  IntMap massCID; // element ID --> coordinate system ID for mass matrix
114  IntMap solidPID; // element ID --> property ID for solid elements
115  IntMap shellPID; // element ID --> property ID for shell elements
116  IntMap sprPID; // element ID --> property ID for spring elements
117  IntMap sprComp; // element ID --> component number for spring elements
118  IntMap weldGS; // element ID --> location node ID for weld elements
119  std::map<int,double> sprK; // element ID --> spring stiffness
120  std::map<int,double> propK; // property ID --> spring stiffness
121  std::map<int,IntMap> propMID;// element category -> property ID -> material ID
122  std::map<int,BEAMOR*> bOri; // element ID --> Bar/Beam-orientation vectors
123  std::map<int,FaVec3*> massX; // element ID --> offset distance for mass matrix
124  GRDSET* gridDefault; // Default options for GRID entries
125  BEAMOR* barDefault; // Default property values for CBAR entries
126  BEAMOR* beamDefault; // Default property values for CBEAM entries
127  FFlGroup* lastGroup; // Last element group added
128  std::set<int> PTHICKs; // Set of PIDs that are of PTHICK type
129  std::set<int> PCOMPs; // Set of PIDs that are of PCOMP type
130 
131  std::vector<FFlElementBase*> myWelds; // Temporary vector of all weld elements
132  std::vector<ElementMap> weld; // Weld connectivities
133 
134  LoadFaceMap loadFace; // Pressure load --> element face nodes
135  std::map<FFlLoadBase*,int> loadCID; // Load --> coord. system ID for direction
136 
138 
139  static int nWarnings, nNotes; // Accumulates the number of warnings and notes
140  static int nWnotImpl; // Number of not-implemented warnings
141 
142  mutable std::pair<int,std::string> lastComment;
143 
144 private:
146  bool sizeOK;
147 
148 public:
149 
150  FFlNastranReader (FFlLinkHandler* readIntoLink, const int startHere);
152  virtual ~FFlNastranReader ();
153 
154  FFlNastranReader& operator= (const FFlNastranReader&) = delete;
155 
156  static void init ();
157  static void identifierCB (const std::string& fileName, int& positiveIdent);
158  static void readerCB (const std::string& fileName, FFlLinkHandler* link);
159 
160 protected:
161 
162  bool read (const std::string& fileName, bool includedFile = false);
163  bool read (std::istream& is);
164  bool resolve (bool stillOk);
165 
166  void processAssignFile (const std::string& line);
167 
168  // Detection and parsing of Nastran sets
169  bool setsArePresent (const std::string& fileName);
170  bool processSet (const std::string& fileName, const int startBlk);
171  bool processAllSets (std::istream& fs, const int startBulk);
172  FFlGroup* processThisSet (std::string& setLine,
173  const int startL, const int stopL);
174 
175  bool extractNameFromLastComment (bool first = false,
176  const char* NXkeyword = "NX ");
177  // Extract element group name from the last comment read
178  void nameFromLastComment (FFlGroup* group, bool first = false);
179  // Extract attribute name from the last comment read
180  void nameFromLastComment (FFlAttributeBase* att,
181  const char* keyword = "Property",
182  bool first = false);
183 
184  // Read next bulk-entry from the input stream
185  bool getNextEntry (std::istream& is, BulkEntry& entry);
186  // Read data fields for the given entry from the input stream
187  bool getFields (std::istream& is, BulkEntry& entry);
188 
189  // Read next (name- or data-) field from the input stream
190  int getNextField (std::istream& is, std::string& field,
191  const FieldFormat size = UNDEFINED);
192 
193  // Parse the given entry and put the data into the FFlLinkHandler object
194  bool processThisEntry (BulkEntry& entry);
195 
196  // Methods for resolving references after finished parsing
197  // These methods are defined in FFlNastranResolver.C
198 
199  bool resolveCoordinates ();
200  bool transformNode (IntMap::iterator& nit);
201  bool transformPoint (FaVec3& X, const int CID, bool orientationOnly = false);
202  bool computeTmatrix (const int CID, CORD& cs);
203  bool getTmatrixAtPt (const int CID, CORD& cs, const FaVec3& X, FaMat33& T);
204  bool resolveAttributes ();
205 
206  int resolveBeamAttributes (FFlElementBase* theBeam, bool& ok);
207  bool resolveWeldElement (FFlElementBase* theElem, int& newEID,
208  const int PID);
209  bool getElementAxis (FFlElementBase* theElem,
210  const int n1, const int n2, FaVec3& axis);
211  void resolveSpringAttributes (FFlElementBase* theSpring,
212  const double K, const int C, bool& ok);
213  void resolveBushAttributes (FFlElementBase* theSpring,
214  const double S, const int CID, bool& ok);
215 
216  bool transformMassMatrix (FFlElementBase* theMass, const int CID, FaVec3* X);
217  bool transformSymmMatrix6 (double mat[6][6], const FaVec3& X,
218  const int CID, const int node = 0);
219 
220  bool transformVec3 (FaVec3& v, const FaVec3& X, const int CID);
221 
222  bool resolveLoads ();
223  bool resolveLoadFace (const FFlLoadBase* load, const IntPair& nodes) const;
224  bool resolveLoadDirection (const FFlLoadBase* load, int CID);
225 
226  // The remaining methods are defined in FFlNastranProcessor.C
227 
228  bool processThisEntry (const std::string& name,
229  std::vector<std::string>& entry);
230 
231  bool createBeamSection (const char* bulk, int PID, int MID,
232  FFlCrossSection& data);
233 
234  IntMap::iterator setDofFlag (int n, int flg);
235 
236  // Alphabetical list of bulk entries that will be processed by this reader:
237  DEF_PROCESSOR( ASET ) // Specification of external nodes
238  DEF_PROCESSOR( ASET1 ) // Specification of external nodes, alternate form
239  DEF_PROCESSOR( BAROR ) // Default orientation and properties for CBAR
240  DEF_PROCESSOR( BEAMOR ) // Default orientation and properties for CBEAM
241  DEF_PROCESSOR( CBAR ) // Prismatic beam element (beam without tapering)
242  DEF_PROCESSOR( CBEAM ) // General beam element
243  DEF_PROCESSOR( CBUSH ) // Generalized spring connection
244  DEF_PROCESSOR( CHEXA ) // Hexahedron solid element
245  DEF_PROCESSOR( CELAS1 ) // Scalar spring element
246  DEF_PROCESSOR( CELAS2 ) // Scalar spring element without reference to PELAS
247  DEF_PROCESSOR( CONROD ) // Rod element with only axial and torsional stiffness
248  DEF_PROCESSOR( CONM1 ) // Concentrated mass element, 6x6 mass matrix
249  DEF_PROCESSOR( CONM2 ) // Concentrated mass element
250  DEF_PROCESSOR( CORD1C ) // Cylindrical coordinate system
251  DEF_PROCESSOR( CORD1R ) // Rectangular coordinate system
252  DEF_PROCESSOR( CORD1S ) // Spherical coordinate system
253  DEF_PROCESSOR( CORD2C ) // Cylindrical coordinate system
254  DEF_PROCESSOR( CORD2R ) // Rectangular coordinate system
255  DEF_PROCESSOR( CORD2S ) // Spherical coordinate system
256  DEF_PROCESSOR( CPENTA ) // Pentahedron solid element
257  DEF_PROCESSOR( CQUAD4 ) // 4-noded shell element
258  DEF_PROCESSOR( CQUAD8 ) // 8-noded shell element
259  DEF_PROCESSOR( CROD ) // Rod element with only axial and torsional stiffness
260  DEF_PROCESSOR( CTETRA ) // Tetrahedron solid element
261  DEF_PROCESSOR( CTRIA3 ) // 3-noded shell element
262  DEF_PROCESSOR( CTRIA6 ) // 6-noded shell element
263  DEF_PROCESSOR( CWELD ) // Spot weld element
264  DEF_PROCESSOR( FORCE ) // Concentrated force at grid point
265  DEF_PROCESSOR( GRDSET ) // Default coordinate system IDs
266  DEF_PROCESSOR( GRID ) // Nodal Grid point
267  DEF_PROCESSOR( INCLUDE) // Include another bulk-data file
268  DEF_PROCESSOR( MAT1 ) // Material properties
269  DEF_PROCESSOR( MAT2 ) // Material properties
270  DEF_PROCESSOR( MAT8 ) // Material properties
271  DEF_PROCESSOR( MAT9 ) // Material properties
272  DEF_PROCESSOR( MOMENT ) // Concentrated moment at grid point
273  DEF_PROCESSOR( MPC ) // Multi-point constraints
274  DEF_PROCESSOR( PBAR ) // Properties for CBAR
275  DEF_PROCESSOR( PBARL ) // Properties for CBAR with cross section dimensions
276  DEF_PROCESSOR( PBEAM ) // Properties for CBEAM
277  DEF_PROCESSOR( PBEAML ) // Properties for CBEAM with cross section dimensions
278  DEF_PROCESSOR( PBUSH ) // Properties for CBUSH
279  DEF_PROCESSOR( PCOMP ) // Properties for composite shell
280  DEF_PROCESSOR( PELAS ) // Properties for CELAS1
281  DEF_PROCESSOR( PLOAD2 ) // Uniform normal pressure load on a surface element
282  DEF_PROCESSOR( PLOAD4 ) // Pressure load on surfaces and solid element faces
283  DEF_PROCESSOR( PROD ) // Properties for CROD
284  DEF_PROCESSOR( PSHELL ) // Properties for shell elements
285  DEF_PROCESSOR( PSOLID ) // Properties for solid elements
286  DEF_PROCESSOR( PWELD ) // Properties for spot weld element
287  DEF_PROCESSOR( QSET1 ) // Specification of component modes
288  DEF_PROCESSOR( RBAR ) // Rigid bar element
289  DEF_PROCESSOR( RBE2 ) // Rigid body with any number of dependent nodes
290  DEF_PROCESSOR( RBE3 ) // Motion of a reference node as a weighted average
291  DEF_PROCESSOR( SET1 ) // Element groups
292  DEF_PROCESSOR( SPC ) // Single-point constraints
293  DEF_PROCESSOR( SPC1 ) // Single-point constraints, alternate form
294 };
295 
296 #ifdef FF_NAMESPACE
297 } // namespace
298 #endif
299 #endif
const double const double const double const double double * X
Definition: ChainShape.H:20
Position matrices in 3D space.
Point vectors in 3D space.
static int startBulk
Definition: FFlNastranReader.C:49
#define DEF_PROCESSOR(rec)
Definition: FFlNastranReader.H:21
Class for holding and calculation of checksum value of objects.
Definition: FFaCheckSum.H:30
Definition: FFlAttributeBase.H:26
Definition: FFlElementBase.H:43
Class for grouping of elements.
Definition: FFlGroup.H:28
Container class for finite element models.
Definition: FFlLinkHandler.H:95
Definition: FFlLoadBase.H:31
Definition: FFlNastranReader.H:37
std::map< FFlLoadBase *, IntPair > LoadFaceMap
Definition: FFlNastranReader.H:100
FieldFormat
Definition: FFlNastranReader.H:41
std::map< int, CORD * > cordSys
Definition: FFlNastranReader.H:109
LoadFaceMap loadFace
Definition: FFlNastranReader.H:134
IntMap sprPID
Definition: FFlNastranReader.H:116
std::map< int, BEAMOR * > bOri
Definition: FFlNastranReader.H:122
BEAMOR * barDefault
Definition: FFlNastranReader.H:125
std::map< int, double > sprK
Definition: FFlNastranReader.H:119
std::map< FFlLoadBase *, int > loadCID
Definition: FFlNastranReader.H:135
std::map< int, int > IntMap
Definition: FFlNastranReader.H:98
std::map< int, IntMap > propMID
Definition: FFlNastranReader.H:121
IntMap massCID
Definition: FFlNastranReader.H:113
IntMap weldGS
Definition: FFlNastranReader.H:118
FFlNastranReader(const FFlNastranReader &)=delete
std::vector< BulkEntry > ucEntries
Definition: FFlNastranReader.H:105
IntMap::iterator setDofFlag(int n, int flg)
GRDSET * gridDefault
Definition: FFlNastranReader.H:124
std::pair< int, int > IntPair
Definition: FFlNastranReader.H:97
std::map< int, FaVec3 * > massX
Definition: FFlNastranReader.H:123
std::set< int > PCOMPs
Definition: FFlNastranReader.H:129
static int nWnotImpl
Definition: FFlNastranReader.H:140
static int nNotes
Definition: FFlNastranReader.H:139
FFlGroup * lastGroup
Definition: FFlNastranReader.H:127
std::set< int > shellPIDnsm
Definition: FFlNastranReader.H:107
IntMap nodeStat
Definition: FFlNastranReader.H:110
int lineCounter
Definition: FFlNastranReader.H:145
std::vector< FFlElementBase * > myWelds
Definition: FFlNastranReader.H:131
IntMap sprComp
Definition: FFlNastranReader.H:117
IntMap nodeCPID
Definition: FFlNastranReader.H:111
std::map< int, double > propK
Definition: FFlNastranReader.H:120
IntMap shellPID
Definition: FFlNastranReader.H:115
std::map< std::string, int > ignoredBulk
Definition: FFlNastranReader.H:102
std::vector< ElementMap > weld
Definition: FFlNastranReader.H:132
std::set< int > beamPIDnsm
Definition: FFlNastranReader.H:106
std::map< std::string, int > sxErrorBulk
Definition: FFlNastranReader.H:103
bool sizeOK
Definition: FFlNastranReader.H:146
FFl::MPCMap myMPCs
Definition: FFlNastranReader.H:137
BEAMOR * beamDefault
Definition: FFlNastranReader.H:126
IntMap solidPID
Definition: FFlNastranReader.H:114
IntMap nodeCDID
Definition: FFlNastranReader.H:112
std::set< int > PTHICKs
Definition: FFlNastranReader.H:128
std::pair< int, std::string > lastComment
Definition: FFlNastranReader.H:142
coordSysType
Definition: FFlNastranReader.H:50
@ cylindrical
Definition: FFlNastranReader.H:52
@ rectangular
Definition: FFlNastranReader.H:51
std::map< int, FFlElementBase * > ElementMap
Definition: FFlNastranReader.H:99
Definition: FFlReaderBase.H:23
Class for point transformations in 3D space.
Definition: FFaMat33.H:27
Class for positions in 3D space.
Definition: FFaMat34.H:32
Class for point vectors in 3D space.
Definition: FFaVec3.H:40
int read(FILE *fd, std::string &tag, unsigned int &cs, int tagLength=LEN_TAG)
Reads the file tag and checksum from the provided file.
Definition: FFaTag.C:317
std::map< short int, DepDOFs > MPC
Definition: FFlUtils.H:35
std::map< int, MPC > MPCMap
Definition: FFlUtils.H:36
void init()
Definition: FmDB.C:518
@ UNDEFINED
Definition: FmFuncAdmin.H:45
Struct with beam cross section parameters.
Definition: FFlCrossSection.H:21
Definition: FFlNastranReader.H:87
BEAMOR(bool b=false)
Definition: FFlNastranReader.H:94
FaVec3 X
Definition: FFlNastranReader.H:90
bool isBAR
Definition: FFlNastranReader.H:91
Definition: FFlNastranReader.H:57
std::string cont
Definition: FFlNastranReader.H:61
std::string name
Definition: FFlNastranReader.H:58
std::vector< std::string > fields
Definition: FFlNastranReader.H:60
Definition: FFlNastranReader.H:67
FaVec3 XZpnt
Definition: FFlNastranReader.H:74
FaMat34 Tmat
Definition: FFlNastranReader.H:75
FaVec3 Zaxis
Definition: FFlNastranReader.H:73
FaVec3 Origo
Definition: FFlNastranReader.H:72
Definition: FFlNastranReader.H:79