ReadABAQUS.hpp 15.9 KB
Newer Older
1
2
3
4
5
/**
 * MOAB, a Mesh-Oriented datABase, is a software component for creating,
 * storing and accessing finite element mesh data.
 * 
 * Copyright 2004 Sandia Corporation.  Under the terms of Contract
6
 * DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
 * retains certain rights in this software.
 * 
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 * 
 */

//-------------------------------------------------------------------------
// Filename      : ReadABAQUS.hpp
//
// Purpose       : ABAQUS inp file reader
//
// Special Notes : Started with NetCDF EXODUS II reader
//
// Creator       : Paul Wilson & Patrick Snouffer
//
// Date          : 08/2009
//
// Owner         : Paul Wilson
//-------------------------------------------------------------------------

30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/** Implementation of ABAQUS mesh hierarchy and meta-data on MOAB


This reader processes data written by the ABAQUS computer-aided engineering
front-end.  While that tool writes binary files in its own proprietary format,
it also writes an ASCII input file that is the fundamental input to the
ABAQUS solver itself.  A published syntax for this format is available from Simulia.

This reader only supports a subset of the mesh syntax necessary to support 
a basic thermal analysis of solid systems.

An ABAQUS mesh makes use of the common paradigms of building a
geometry as an "assembly" of "instances" of "parts".

A "part" is defined as a set of "nodes" and "elements" connecting
those nodes. The nodes and elements can be arranged in "node sets" and
"element sets" and specific "materials" can be assigned to "element
sets" other features of parts are not currently used by applications
and are not implemented.


51
Overview of supported structure
52
53
54
55

* File:
   * Heading
   * Part
56
      * Nodes 
57
58
59
60
61
62
      * Elements
      * Node Sets
      * Element Sets
      * Solid Sections
   * Assembly
      * Instance
63
64
65
66
67
        * Nodes 
        * Elements
        * Node Sets
        * Element Sets
        * Solid Sections
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
      * Node Sets


An "instance" is a full copy of a "part" with a linear geometric
transformation. To create a full copy:
• a duplicate set of nodes is created by copying the coordinates of
  the part nodes and applying a linear geometric transformation - the
  new coords are used to define the new nodes
• a new node set is created for each node set in the part and the set
  of nodes among the duplicates are assigned to the new node set
• a duplicate set of elements is defined by creating a new element
  with a connectivity made up of the duplicate nodes that correspond
  to the appropriate original element
• a new element set is created for each element set in the part and
  the set of elements among the duplicates are assigned to the new
  element set; the corresponding material is also assigned go the new
  element sets

86
87
88
89
90
91
92
It is also possible for an "instance" to contain the complete
definition of the mesh, copying nothing from the "part" (the "part"
may have no mesh defined).  It is unclear whether an "instance" can
combine mesh from the "part" definition with mesh contained only in
the "instance" definition. (Not appropriately documented in ABAUQUS
Reference Manual.)

93
94
95
In order to provide convenient access to the data and mesh structures
the following data model is used:

's avatar
committed
96
• EntitySet file_set
97
98
99
100
101
102
103
   • tags
       • NONE
   • members
       • all nodes of all parts and all instances
       • all elements of all parts and all instances
       • all assembly_sets
       • all part_sets
's avatar
committed
104
• EntitySet part_set
105
106
   • tags
       • mSetNameTag (opaque=char*)
107
         name of entity set
108
109
110
111
112
   • members
       • part nodes
       • part elements
       • part node sets
       • part element sets
's avatar
committed
113
• EntitySet assembly_set
114
115
   • tags
       • mSetNameTag (opaque=char*)
116
         name of entity set
117
118
   • members
      • instance_sets
119
      • instance element_sets
120
121
122
      • instance node_sets  
      • instance nodes
      • instance elements
's avatar
committed
123
• EntitySet instance_set
124
125
   • tags
       • mSetNameTag (opaque=char*)
126
         name of entity set
127
128
129
130
131
132
133
134
135
136
137
138
       • mPartHandleTag (handle)
         pointer to part from which this instance was generated
       • mAssemblyHandleTag (handle)
         pointer to assembly in which this instance exists
       • mInstancePIDTag (int)
         ordinal number indicating which instance of this part
       • mInstanceGIDTag (int)
         ordinal number indicating which instance in this assembly
   • members
      • instance nodes
      • instance elements
      • instance node_sets  
139
      • instance element_sets
's avatar
committed
140
• EntitySet node_set
141
142
   • tags
       • mSetNameTag (opaque=char*)
143
         name of entity set
144
145
       • mPartHandleTag (handle)
         pointer to part in which this node set exists
146
147
	 (only defined for node sets that are in an instance and 
          derive from a part)
148
149
150
151
152
153
154
155
       • mInstanceHandleTag (handle)
         pointer back to instance set in which this node set exists
         (NULL if this node_set is not in an instance)
       • mAssemblyHandleTag (handle)
         pointer to assembly in which this node set exists
         (NULL if this node_set is not in an assembly)
   • members
      • nodes
's avatar
committed
156
• EntitySet element_set
157
158
   • tags
       • mSetNameTag (opaque=char*)
159
         name of entity set
160
161
       • mPartHandleTag (handle)
         pointer to part in which this element set exists
162
163
	 (only defined for node sets that are in an instance and 
          derive from a part)
164
165
166
167
168
169
170
171
172
173
174
175
       • mInstanceHandleTag (handle)
         pointer back to instance set in which this element set exists
         (NULL if this node_set is not in an instance)
       • mAssemblyHandleTag (handle)
         pointer to assembly in which this element set exists
         (NULL if this node_set is not in an assembly)
       • mMatNameTag (opaque=char*)
         name of material in these elements
       • mMaterialSetTag (integer)
         material id in these elements
   • members
      • elements
's avatar
committed
176
• Entity node
177
178
179
180
181
182
   • tags
       • mLocalIDTag (int)
         numerical ID of node in local scope (part, instance)
       • mInstanceHandleTag (handle)
         pointer back to instance set in which this node exists
         (NULL if this node is not in an instance)
's avatar
committed
183
• Entity element
184
185
186
187
188
189
190
191
192
193
   • tags
       • mLocalIDTag (int)
         numerical ID of element in local scope (part, instance)
       • mInstanceHandleTag (handle)
         pointer back to instance set in which this element exists
         (NULL if this element is not in an instance)


 **/

194
195
196
197
198
199
200
201
202
203
204
205
206
#ifndef READABAQUS_HPP
#define READABAQUS_HPP

#ifndef IS_BUILDING_MB
  #error "ReadABAQUS.hpp isn't supposed to be included into an application"
#endif

#include <vector>
#include <map>
#include <string>
#include <iostream>
#include <fstream>

's avatar
committed
207
208
209
210
211
#include "moab/Forward.hpp"
#include "moab/ReaderIface.hpp"
#include "moab/Range.hpp"

namespace moab {
212
213
214
215
216
217

#define ABAQUS_SET_TYPE_TAG_NAME "abaqus_set_type"
#define ABAQUS_SET_NAME_TAG_NAME "abaqus_set_name"
#define ABAQUS_SET_NAME_LENGTH   100
#define ABAQUS_LOCAL_ID_TAG_NAME "abaqus_local_id"

218
219
// Many sets should know who contains them
#define ABAQUS_INSTANCE_HANDLE_TAG_NAME "abaqus_instance_handle"
220
#define ABAQUS_ASSEMBLY_HANDLE_TAG_NAME "abaqus_assembly_handle"
221
#define ABAQUS_PART_HANDLE_TAG_NAME     "abaqus_part_handle"
222

223
// Instances should know things about themselves:
224
225
226
227
228
229
//  * which part they derive from (see ABAQUS_PART_HANDLE_TAG_NAME above)
//  * which instance of a part this is
//  * which instance of an assembly this is
#define ABAQUS_INSTANCE_PART_ID_TAG_NAME   "abaqus_instance_part_id"
#define ABAQUS_INSTANCE_GLOBAL_ID_TAG_NAME "abaqus_instance_global_id"

230
231
// Element sets have material name
// Using MOAB's general MATERIAL_SET to store material id
232
233
234
235
236
237
238
239
240
#define ABAQUS_MAT_NAME_TAG_NAME "abaqus_mat_name"
#define ABAQUS_MAT_NAME_LENGTH   100

#define ABQ_ASSEMBLY_SET 1
#define ABQ_PART_SET     2
#define ABQ_INSTANCE_SET 3
#define ABQ_NODE_SET     4
#define ABQ_ELEMENT_SET  5

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
enum abaqus_line_types {abq_undefined_line = 0,
                        abq_blank_line,
                        abq_comment_line,
                        abq_keyword_line,
                        abq_data_line,
                        abq_eof};

enum abaqus_keyword_type {abq_undefined = 0,
                          abq_unsupported,
                          abq_ambiguous,
                          abq_heading,
                          abq_part,
                          abq_end_part,
                          abq_assembly,
                          abq_end_assembly,
                          abq_node,
                          abq_element,
                          abq_nset,
                          abq_elset,
                          abq_instance,
                          abq_end_instance,
                          abq_solid_section};

enum abaqus_part_params {abq_part_undefined = 0,
                         abq_part_ambiguous,
                         abq_part_name};

enum abaqus_instance_params {abq_instance_undefined = 0,
                             abq_instance_ambiguous,
                             abq_instance_name,
                             abq_instance_part};

enum abaqus_assembly_params {abq_assembly_undefined = 0,
                             abq_assembly_ambiguous,
                             abq_assembly_name};

enum abaqus_node_params {abq_node_undefined = 0,
                         abq_node_ambiguous,
                         abq_node_nset,
                         abq_node_system};

enum abaqus_element_params {abq_element_undefined = 0,
                            abq_element_ambiguous,
                            abq_element_elset,
                            abq_element_type};

enum abaqus_element_type {abq_eletype_unsupported = 0,
                          abq_eletype_dc3d8,
                          abq_eletype_c3d8r,
                          abq_eletype_dcc3d8,
                          abq_eletype_c3d4,
                          abq_eletype_dc3d4,
                          abq_eletype_ds4};

enum abaqus_nset_params {abq_nset_undefined = 0,
                         abq_nset_ambiguous,
                         abq_nset_nset,
                         abq_nset_elset,
                         abq_nset_generate,
                         abq_nset_instance};

enum abaqus_elset_params {abq_elset_undefined = 0,
                          abq_elset_ambiguous,
                          abq_elset_elset,
                          abq_elset_generate,
                          abq_elset_instance};

enum abaqus_solid_section_params {abq_solid_section_undefined = 0,
                                  abq_solid_section_ambiguous,
                                  abq_solid_section_elset,
                                  abq_solid_section_matname};
312

's avatar
committed
313
class ReadUtilIface;
314

's avatar
committed
315
class ReadABAQUS : public ReaderIface
316
317
{
public:
318
319
320
321
322
323
324
325
326
327
328
329
330

  static ReaderIface* factory(Interface*);

  void tokenize(const std::string& str,
                std::vector<std::string>& tokens,
                const char* delimiters);

  //! Load an ABAQUS file
  ErrorCode load_file(const char* file_name,
                      const EntityHandle* file_set,
                      const FileOptions& opts,
                      const SubsetList* subset_list = 0,
                      const Tag* file_id_tag = 0);
331
  
332
333
334
335
336
337
  ErrorCode read_tag_values(const char* file_name,
                            const char* tag_name,
                            const FileOptions& opts,
                            std::vector<int>& tag_values_out,
                            const SubsetList* subset_list = 0);

338
  //! Constructor
's avatar
committed
339
  ReadABAQUS(Interface* impl = NULL);
340
341
342
  
  //! Destructor
  virtual ~ReadABAQUS();
343

344
private:
345

346
  void reset();
347

's avatar
committed
348
349
350
351
  ErrorCode read_heading(EntityHandle file_set);
  ErrorCode read_part(EntityHandle file_set);
  ErrorCode read_assembly(EntityHandle file_set);
  ErrorCode read_unsupported(EntityHandle file_set);
352
  ErrorCode read_node_list(EntityHandle parent_set,
353
                           EntityHandle assembly_set = 0);
354
  ErrorCode read_element_list(EntityHandle parent_set,
355
                              EntityHandle assembly_set = 0);
's avatar
committed
356
  ErrorCode read_node_set(EntityHandle parent_set,
357
358
                          EntityHandle file_set = 0,
                          EntityHandle assembly_set = 0);
's avatar
committed
359
  ErrorCode read_element_set(EntityHandle parent_set,
360
361
                             EntityHandle file_set = 0,
                             EntityHandle assembly_set = 0);
's avatar
committed
362
363
  ErrorCode read_solid_section(EntityHandle parent_set);
  ErrorCode read_instance(EntityHandle assembly_set,
364
365
                          EntityHandle file_set);

's avatar
committed
366
  ErrorCode get_elements_by_id(EntityHandle parent_set,
367
368
369
                               std::vector<int> element_ids_subset,
                               Range &element_range);

's avatar
committed
370
  ErrorCode get_nodes_by_id(EntityHandle parent_set,
371
372
                            std::vector<int> node_ids_subset,
                            Range &node_range);
373
    
's avatar
committed
374
  ErrorCode get_set_by_name(EntityHandle parent_set,
375
                            int ABQ_set_type,
376
                            const std::string &set_name,
377
                            EntityHandle &set_handle);
378

's avatar
committed
379
  ErrorCode get_set_elements(EntityHandle set_handle,
380
                             Range &element_range);
381

's avatar
committed
382
  ErrorCode get_set_elements_by_name(EntityHandle parent_set,
383
                                     int ABQ_set_type,
384
                                     const std::string &set_name,
385
386
                                     Range &element_range);

's avatar
committed
387
  ErrorCode get_set_nodes(EntityHandle parent_set,
388
                          int ABQ_set_type,
389
                          const std::string &set_name,
390
391
                          Range &node_range);

's avatar
committed
392
  ErrorCode add_entity_set(EntityHandle parent_set,
393
                           int ABQ_set_type,
394
                           const std::string &set_name,
395
                           EntityHandle &entity_set);
396

's avatar
committed
397
  ErrorCode create_instance_of_part(const EntityHandle file_set,
398
                                    const EntityHandle parent_set,
399
400
                                    const std::string &part_name,
                                    const std::string &instance_name,
401
402
403
                                    EntityHandle &entity_set,
                                    const std::vector<double> &translation,
                                    const std::vector<double> &rotation);
404

's avatar
committed
405
  Tag get_tag(const char* tag_name, int tag_size, TagType tag_type,
406
407
              DataType tag_data_type, const void* def_val = 0);

408
409
410
411
412
413
  void cyl2rect(std::vector<double> coord_list);

  void sph2rect(std::vector<double> coord_list);

  abaqus_line_types get_next_line_type();
  abaqus_keyword_type get_keyword();
414

415
  template <class T>
416
417
  std::string match(const std::string &token,
                    std::map<std::string,T> &tokenList);
418

419
  void stringToUpper(const std::string& toBeConverted,std::string& converted);
420

421
  void extract_keyword_parameters(const std::vector<std::string>& tokens,
422
                                  std::map<std::string, std::string>& params);
423

424
  //! Interface instance
's avatar
committed
425
  Interface* mdbImpl;
426

427
  //! Read mesh interface
's avatar
committed
428
  ReadUtilIface* readMeshIface;
429

430
  std::ifstream abFile; // abaqus file
431
432

  std::string readline;
433

's avatar
committed
434
  unsigned lineNo;
435

436
  //! Cached tags for reading. Note that all these tags are defined when the
437
  //! core is initialized.
's avatar
committed
438
439
440
441
  Tag mMaterialSetTag;
  Tag mDirichletSetTag;
  Tag mNeumannSetTag;
  Tag mHasMidNodesTag;
442

's avatar
committed
443
444
445
446
  Tag mSetTypeTag;
  Tag mPartHandleTag;
  Tag mInstancePIDTag;
  Tag mInstanceGIDTag;
447

's avatar
committed
448
449
450
  Tag mLocalIDTag;
  Tag mInstanceHandleTag;
  Tag mAssemblyHandleTag;
451

's avatar
committed
452
453
  Tag mSetNameTag;
  Tag mMatNameTag;
454

455
  abaqus_line_types next_line_type;
456

457
458
459
  std::map<EntityHandle, unsigned int> num_part_instances;
  std::map<EntityHandle, unsigned int> num_assembly_instances;
  std::map<std::string, unsigned int> matIDmap;
460
  unsigned mat_id;
461

462
463
};

's avatar
committed
464
} // namespace moab
465
466

#endif