-
Notifications
You must be signed in to change notification settings - Fork 27
/
Copy pathxpltReader2.h
371 lines (316 loc) · 10.7 KB
/
xpltReader2.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
/*This file is part of the FEBio Studio source code and is licensed under the MIT license
listed below.
See Copyright-FEBio-Studio.txt for details.
Copyright (c) 2021 University of Utah, The Trustees of Columbia University in
the City of New York, and others.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.*/
#pragma once
#include "xpltFileReader.h"
#include <MeshLib/FEElement.h>
namespace Post {
class FEState;
class FEPostMesh;
class FEMeshData;
}
//-----------------------------------------------------------------------------
// This class reads the XPLT file, version 2.0
class XpltReader2 : public xpltParser
{
protected:
// file tags
enum {
PLT_ROOT = 0x01000000,
PLT_HEADER = 0x01010000,
PLT_HDR_VERSION = 0x01010001,
// PLT_HDR_NODES = 0x01010002,
// PLT_HDR_MAX_FACET_NODES = 0x01010003, // removed (redefined in seach SURFACE section)
PLT_HDR_COMPRESSION = 0x01010004,
PLT_HDR_AUTHOR = 0x01010005, // new in 2.0
PLT_HDR_SOFTWARE = 0x01010006, // new in 2.0
PLT_DICTIONARY = 0x01020000,
PLT_DIC_ITEM = 0x01020001,
PLT_DIC_ITEM_TYPE = 0x01020002,
PLT_DIC_ITEM_FMT = 0x01020003,
PLT_DIC_ITEM_NAME = 0x01020004,
PLT_DIC_ITEM_ARRAYSIZE = 0x01020005, // added in version 0x05
PLT_DIC_ITEM_ARRAYNAME = 0x01020006, // added in version 0x05
PLT_DIC_GLOBAL = 0x01021000,
// PLT_DIC_MATERIAL = 0x01022000, // this was removed
PLT_DIC_NODAL = 0x01023000,
PLT_DIC_DOMAIN = 0x01024000,
PLT_DIC_SURFACE = 0x01025000,
// PLT_MATERIALS = 0x01030000, // This was removed
// PLT_MATERIAL = 0x01030001,
// PLT_MAT_ID = 0x01030002,
// PLT_MAT_NAME = 0x01030003,
PLT_MESH = 0x01040000, // this was PLT_GEOMETRY
PLT_NODE_SECTION = 0x01041000,
PLT_NODE_HEADER = 0x01041100, // new in 2.0
PLT_NODE_SIZE = 0x01041101, // new in 2.0
PLT_NODE_DIM = 0x01041102, // new in 2.0
PLT_NODE_NAME = 0x01041103, // new in 2.0
PLT_NODE_COORDS = 0x01041200, // new in 2.0
PLT_DOMAIN_SECTION = 0x01042000,
PLT_DOMAIN = 0x01042100,
PLT_DOMAIN_HDR = 0x01042101,
PLT_DOM_ELEM_TYPE = 0x01042102,
PLT_DOM_PART_ID = 0x01042103, // this was PLT_DOM_MAT_ID
PLT_DOM_ELEMS = 0x01032104,
PLT_DOM_NAME = 0x01032105,
PLT_DOM_ELEM_LIST = 0x01042200,
PLT_ELEMENT = 0x01042201,
PLT_SURFACE_SECTION = 0x01043000,
PLT_SURFACE = 0x01043100,
PLT_SURFACE_HDR = 0x01043101,
PLT_SURFACE_ID = 0x01043102,
PLT_SURFACE_FACES = 0x01043103,
PLT_SURFACE_NAME = 0x01043104,
PLT_SURFACE_MAX_FACET_NODES = 0x01043105, // new in 2.0 (max number of nodes per facet)
PLT_FACE_LIST = 0x01043200,
PLT_FACE = 0x01043201,
PLT_NODESET_SECTION = 0x01044000,
PLT_NODESET = 0x01044100,
PLT_NODESET_HDR = 0x01044101,
PLT_NODESET_ID = 0x01044102,
PLT_NODESET_NAME = 0x01044103,
PLT_NODESET_SIZE = 0x01044104,
PLT_NODESET_LIST = 0x01044200,
PLT_PARTS_SECTION = 0x01045000, // new in 2.0
PLT_PART = 0x01045100,
PLT_PART_ID = 0x01045101,
PLT_PART_NAME = 0x01045102,
PLT_STATE = 0x02000000,
PLT_STATE_HEADER = 0x02010000,
PLT_STATE_HDR_ID = 0x02010001,
PLT_STATE_HDR_TIME = 0x02010002,
PLT_STATE_DATA = 0x02020000,
PLT_STATE_VARIABLE = 0x02020001,
PLT_STATE_VAR_ID = 0x02020002,
PLT_STATE_VAR_DATA = 0x02020003,
PLT_GLOBAL_DATA = 0x02020100,
// PLT_MATERIAL_DATA = 0x02020200, // this was removed
PLT_NODE_DATA = 0x02020300,
PLT_ELEMENT_DATA = 0x02020400,
PLT_FACE_DATA = 0x02020500,
PLT_MESH_STATE = 0x02030000,
PLT_ELEMENT_STATE = 0x02030001
};
protected:
// FEBio tag
enum {FEBIO_TAG = 0x00464542 };
// variable types
enum Var_Type { FLOAT, VEC3F, MAT3FS, MAT3FD, TENS4FS, MAT3F, ARRAY, ARRAY_VEC3F };
// variable format
enum Var_Fmt { FMT_NODE, FMT_ITEM, FMT_MULT, FMT_REGION };
// element types
enum Elem_Type {
PLT_ELEM_HEX8,
PLT_ELEM_PENTA,
PLT_ELEM_TET4,
PLT_ELEM_QUAD,
PLT_ELEM_TRI,
PLT_ELEM_TRUSS,
PLT_ELEM_HEX20,
PLT_ELEM_TET10,
PLT_ELEM_TET15,
PLT_ELEM_HEX27,
PLT_ELEM_TRI6,
PLT_ELEM_QUAD8,
PLT_ELEM_QUAD9,
PLT_ELEM_PENTA15,
PLT_ELEM_TET20,
PLT_ELEM_TRI10,
PLT_ELEM_PYRA5,
PLT_ELEM_TET5,
PLT_ELEM_PYRA13
};
// size of name variables
enum { DI_NAME_SIZE = 64 };
public:
class DICT_ITEM
{
public:
DICT_ITEM();
DICT_ITEM(const DICT_ITEM& item);
public:
unsigned int ntype;
unsigned int nfmt;
char szname[DI_NAME_SIZE];
unsigned int index; // index into data manager list
unsigned int arraySize; // only used for array variables (plt version 0x05)
std::vector<string> arrayNames; // (optional) names of array components
};
class Dictionary
{
public:
std::vector<DICT_ITEM> m_Glb;
std::vector<DICT_ITEM> m_Mat;
std::vector<DICT_ITEM> m_Node;
std::vector<DICT_ITEM> m_Elem;
std::vector<DICT_ITEM> m_Face;
public:
void Clear()
{
m_Glb.clear();
m_Mat.clear();
m_Node.clear();
m_Elem.clear();
m_Face.clear();
}
};
struct MATERIAL
{
int nid;
char szname[DI_NAME_SIZE];
};
struct NODE
{
int id;
float x[3];
};
struct ELEM
{
int eid;
int index;
int node[FSElement::MAX_NODES];
};
struct FACE
{
int nid;
int nn;
int node[9];
};
class Domain
{
public:
int etype;
int mid;
int ne;
int nid; // domain ID
char szname[64];
std::vector<int> elist;
std::vector<ELEM> elem;
public:
Domain() { ne = 0; szname[0] = 0; }
Domain(const Domain& d) { nid = d.nid; etype = d.etype; mid = d.mid; ne = d.ne; elem = d.elem; elist = d.elist; strncpy(szname, d.szname, 64); }
void operator = (const Domain& d) { nid = d.nid; etype = d.etype; mid = d.mid; ne = d.ne; elem = d.elem; elist = d.elist; strncpy(szname, d.szname, 64); }
};
class Surface
{
public:
int sid;
int nfaces; // number of faces
int maxNodes; // max nr of nodes
std::vector<FACE> face;
char szname[64];
public:
Surface() { nfaces = 0; maxNodes = 0; szname[0] = 0; }
Surface(const Surface& s) { nfaces = s.nfaces; maxNodes = s.maxNodes; face = s.face; strncpy(szname, s.szname, 64); }
void operator = (const Surface& s) { nfaces = s.nfaces; maxNodes = s.maxNodes; face = s.face; }
};
class NodeSet
{
public:
int nid;
int nn;
char szname[64];
std::vector<int> node;
public:
NodeSet() { nn = 0; szname[0] = 0; }
NodeSet(const NodeSet& s) { nn = s.nn; node = s.node; strncpy(szname, s.szname, 64); }
};
class XMesh
{
public:
std::vector<MATERIAL> m_Mat;
std::vector<NODE> m_Node;
std::vector<Domain> m_Dom;
std::vector<Surface> m_Surf;
std::vector<NodeSet> m_NodeSet;
public:
void Clear();
int materials() const { return (int)m_Mat.size(); }
void addMaterial(MATERIAL& mat);
MATERIAL& material(int i) { return m_Mat[i]; }
int nodes() const { return (int)m_Node.size(); }
NODE& node(int i) { return m_Node[i]; }
void addNodes(std::vector<NODE>& nodes);
int domains() const { return (int)m_Dom.size(); }
void addDomain(Domain& dom);
Domain& domain(int i) { return m_Dom[i]; }
int surfaces() const { return (int)m_Surf.size(); }
void addSurface(Surface& surf);
Surface& surface(int i) { return m_Surf[i]; }
int nodeSets() const { return (int)m_NodeSet.size(); }
void addNodeSet(NodeSet& nset);
NodeSet& nodeSet(int i) { return m_NodeSet[i]; }
};
public:
XpltReader2(xpltFileReader* xplt);
~XpltReader2();
bool Load(Post::FEPostModel& fem);
protected:
bool ReadRootSection(Post::FEPostModel& fem);
bool ReadStateSection(Post::FEPostModel& fem);
bool ReadDictionary(Post::FEPostModel& fem);
bool ReadMesh(Post::FEPostModel& fem);
bool ReadDictItem(DICT_ITEM& it);
void CreateMaterials(Post::FEPostModel& fem);
bool BuildMesh(Post::FEPostModel& fem);
protected:
bool ReadGlobalDicItems ();
bool ReadMaterialDicItems();
bool ReadNodeDicItems ();
bool ReadElemDicItems ();
bool ReadFaceDicItems ();
bool ReadNodeSection (Post::FEPostModel& fem);
bool ReadDomainSection (Post::FEPostModel& fem);
bool ReadSurfaceSection(Post::FEPostModel& fem);
bool ReadNodeSetSection(Post::FEPostModel& fem);
bool ReadPartsSection (Post::FEPostModel& fem);
bool ReadGlobalData (Post::FEPostModel& fem, Post::FEState* pstate);
bool ReadMaterialData(Post::FEPostModel& fem, Post::FEState* pstate);
bool ReadNodeData (Post::FEPostModel& fem, Post::FEState* pstate);
bool ReadElemData (Post::FEPostModel& fem, Post::FEState* pstate);
bool ReadFaceData (Post::FEPostModel& fem, Post::FEState* pstate);
bool ReadElemData_NODE(Post::FEPostMesh& m, Domain& d, Post::FEMeshData& s, int ntype, int arrSize);
bool ReadElemData_ITEM(Domain& d, Post::FEMeshData& s, int ntype, int arrSize);
bool ReadElemData_MULT(Domain& d, Post::FEMeshData& s, int ntype);
bool ReadFaceData_NODE(Post::FEPostMesh& m, Surface& s, Post::FEMeshData& data, int ntype);
bool ReadFaceData_ITEM(Surface& s, Post::FEMeshData& data, int ntype);
bool ReadFaceData_MULT(Post::FEPostMesh& m, Surface& s, Post::FEMeshData& data, int ntype);
void Clear();
protected:
Post::FEPostMesh* GetCurrentMesh() { return m_mesh; }
protected:
Dictionary m_dic;
XMesh m_xmesh;
bool m_bHasDispl; // has displacement field
bool m_bHasStress; // has stress field
bool m_bHasNodalStress; // has nodal stress field
bool m_bHasShellThickness; // has shell thicknesses
bool m_bHasFluidPressure; // has fluid pressure field
bool m_bHasElasticity; // has elasticity field
int m_ngvsize; // size of all global variables
int m_nnvsize; // size of all nodal variables
int m_n3dsize; // size of all solid variables
int m_n2dsize; // size of all shell variables
int m_n1dsize; // size of all beam variables
int m_nel;
Post::FEState* m_pstate; //!< last read state section
Post::FEPostMesh* m_mesh; //!< current mesh
};