Mesh Oriented datABase  (version 5.5.0)
An array-based unstructured mesh library
ReadABAQUS.hpp
Go to the documentation of this file.
1 /**
2  * MOAB, a Mesh-Oriented datABase, is a software component for creating,
3  * storing and accessing finite element mesh data.
4  *
5  * Copyright 2004 Sandia Corporation. Under the terms of Contract
6  * DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government
7  * retains certain rights in this software.
8  *
9  * This library is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Lesser General Public
11  * License as published by the Free Software Foundation; either
12  * version 2.1 of the License, or (at your option) any later version.
13  *
14  */
15 
16 //-------------------------------------------------------------------------
17 // Filename : ReadABAQUS.hpp
18 //
19 // Purpose : ABAQUS inp file reader
20 //
21 // Special Notes : Started with NetCDF EXODUS II reader
22 //
23 // Creator : Paul Wilson & Patrick Snouffer
24 //
25 // Date : 08/2009
26 //
27 // Owner : Paul Wilson
28 //-------------------------------------------------------------------------
29 
30 /** Implementation of ABAQUS mesh hierarchy and meta-data on MOAB
31 
32 
33 This reader processes data written by the ABAQUS computer-aided engineering
34 front-end. While that tool writes binary files in its own proprietary format,
35 it also writes an ASCII input file that is the fundamental input to the
36 ABAQUS solver itself. A published syntax for this format is available from Simulia.
37 
38 This reader only supports a subset of the mesh syntax necessary to support
39 a basic thermal analysis of solid systems.
40 
41 An ABAQUS mesh makes use of the common paradigms of building a
42 geometry as an "assembly" of "instances" of "parts".
43 
44 A "part" is defined as a set of "nodes" and "elements" connecting
45 those nodes. The nodes and elements can be arranged in "node sets" and
46 "element sets" and specific "materials" can be assigned to "element
47 sets" other features of parts are not currently used by applications
48 and are not implemented.
49 
50 
51 Overview of supported structure
52 
53 * File:
54  * Heading
55  * Part
56  * Nodes
57  * Elements
58  * Node Sets
59  * Element Sets
60  * Solid Sections
61  * Assembly
62  * Instance
63  * Nodes
64  * Elements
65  * Node Sets
66  * Element Sets
67  * Solid Sections
68  * Node Sets
69 
70 
71 An "instance" is a full copy of a "part" with a linear geometric
72 transformation. To create a full copy:
73 • a duplicate set of nodes is created by copying the coordinates of
74  the part nodes and applying a linear geometric transformation - the
75  new coords are used to define the new nodes
76 • a new node set is created for each node set in the part and the set
77  of nodes among the duplicates are assigned to the new node set
78 • a duplicate set of elements is defined by creating a new element
79  with a connectivity made up of the duplicate nodes that correspond
80  to the appropriate original element
81 • a new element set is created for each element set in the part and
82  the set of elements among the duplicates are assigned to the new
83  element set; the corresponding material is also assigned go the new
84  element sets
85 
86 It is also possible for an "instance" to contain the complete
87 definition of the mesh, copying nothing from the "part" (the "part"
88 may have no mesh defined). It is unclear whether an "instance" can
89 combine mesh from the "part" definition with mesh contained only in
90 the "instance" definition. (Not appropriately documented in ABAUQUS
91 Reference Manual.)
92 
93 In order to provide convenient access to the data and mesh structures
94 the following data model is used:
95 
96 • EntitySet file_set
97  • tags
98  • NONE
99  • members
100  • all nodes of all parts and all instances
101  • all elements of all parts and all instances
102  • all assembly_sets
103  • all part_sets
104 • EntitySet part_set
105  • tags
106  • mSetNameTag (opaque=char*)
107  name of entity set
108  • members
109  • part nodes
110  • part elements
111  • part node sets
112  • part element sets
113 • EntitySet assembly_set
114  • tags
115  • mSetNameTag (opaque=char*)
116  name of entity set
117  • members
118  • instance_sets
119  • instance element_sets
120  • instance node_sets
121  • instance nodes
122  • instance elements
123 • EntitySet instance_set
124  • tags
125  • mSetNameTag (opaque=char*)
126  name of entity set
127  • mPartHandleTag (handle)
128  pointer to part from which this instance was generated
129  • mAssemblyHandleTag (handle)
130  pointer to assembly in which this instance exists
131  • mInstancePIDTag (int)
132  ordinal number indicating which instance of this part
133  • mInstanceGIDTag (int)
134  ordinal number indicating which instance in this assembly
135  • members
136  • instance nodes
137  • instance elements
138  • instance node_sets
139  • instance element_sets
140 • EntitySet node_set
141  • tags
142  • mSetNameTag (opaque=char*)
143  name of entity set
144  • mPartHandleTag (handle)
145  pointer to part in which this node set exists
146  (only defined for node sets that are in an instance and
147  derive from a part)
148  • mInstanceHandleTag (handle)
149  pointer back to instance set in which this node set exists
150  (NULL if this node_set is not in an instance)
151  • mAssemblyHandleTag (handle)
152  pointer to assembly in which this node set exists
153  (NULL if this node_set is not in an assembly)
154  • members
155  • nodes
156 • EntitySet element_set
157  • tags
158  • mSetNameTag (opaque=char*)
159  name of entity set
160  • mPartHandleTag (handle)
161  pointer to part in which this element set exists
162  (only defined for node sets that are in an instance and
163  derive from a part)
164  • mInstanceHandleTag (handle)
165  pointer back to instance set in which this element set exists
166  (NULL if this node_set is not in an instance)
167  • mAssemblyHandleTag (handle)
168  pointer to assembly in which this element set exists
169  (NULL if this node_set is not in an assembly)
170  • mMatNameTag (opaque=char*)
171  name of material in these elements
172  • mMaterialSetTag (integer)
173  material id in these elements
174  • members
175  • elements
176 • Entity node
177  • tags
178  • mLocalIDTag (int)
179  numerical ID of node in local scope (part, instance)
180  • mInstanceHandleTag (handle)
181  pointer back to instance set in which this node exists
182  (NULL if this node is not in an instance)
183 • Entity element
184  • tags
185  • mLocalIDTag (int)
186  numerical ID of element in local scope (part, instance)
187  • mInstanceHandleTag (handle)
188  pointer back to instance set in which this element exists
189  (NULL if this element is not in an instance)
190 
191 
192  **/
193 
194 #ifndef READABAQUS_HPP
195 #define READABAQUS_HPP
196 
197 #ifndef IS_BUILDING_MB
198 #error "ReadABAQUS.hpp isn't supposed to be included into an application"
199 #endif
200 
201 #include <vector>
202 #include <map>
203 #include <string>
204 #include <iostream>
205 #include <fstream>
206 
207 #include "moab/Forward.hpp"
208 #include "moab/ReaderIface.hpp"
209 #include "moab/Range.hpp"
210 
211 namespace moab
212 {
213 
214 #define ABAQUS_SET_TYPE_TAG_NAME "abaqus_set_type"
215 #define ABAQUS_SET_NAME_TAG_NAME "abaqus_set_name"
216 #define ABAQUS_SET_NAME_LENGTH 100
217 #define ABAQUS_LOCAL_ID_TAG_NAME "abaqus_local_id"
218 
219 // Many sets should know who contains them
220 #define ABAQUS_INSTANCE_HANDLE_TAG_NAME "abaqus_instance_handle"
221 #define ABAQUS_ASSEMBLY_HANDLE_TAG_NAME "abaqus_assembly_handle"
222 #define ABAQUS_PART_HANDLE_TAG_NAME "abaqus_part_handle"
223 
224 // Instances should know things about themselves:
225 // * which part they derive from (see ABAQUS_PART_HANDLE_TAG_NAME above)
226 // * which instance of a part this is
227 // * which instance of an assembly this is
228 #define ABAQUS_INSTANCE_PART_ID_TAG_NAME "abaqus_instance_part_id"
229 #define ABAQUS_INSTANCE_GLOBAL_ID_TAG_NAME "abaqus_instance_global_id"
230 
231 // Element sets have material name
232 // Using MOAB's general MATERIAL_SET to store material id
233 #define ABAQUS_MAT_NAME_TAG_NAME "abaqus_mat_name"
234 #define ABAQUS_MAT_NAME_LENGTH 100
235 
236 #define ABQ_ASSEMBLY_SET 1
237 #define ABQ_PART_SET 2
238 #define ABQ_INSTANCE_SET 3
239 #define ABQ_NODE_SET 4
240 #define ABQ_ELEMENT_SET 5
241 
243 {
249  abq_eof
250 };
251 
253 {
269 };
270 
272 {
276 };
277 
279 {
284 };
285 
287 {
291 };
292 
294 {
299 };
300 
302 {
307 };
308 
310 {
318 };
319 
321 {
328 };
329 
331 {
337 };
338 
340 {
345 };
346 
347 class ReadUtilIface;
348 
349 class ReadABAQUS : public ReaderIface
350 {
351  public:
352  static ReaderIface* factory( Interface* );
353 
354  void tokenize( const std::string& str, std::vector< std::string >& tokens, const char* delimiters );
355 
356  //! Load an ABAQUS file
357  ErrorCode load_file( const char* file_name,
358  const EntityHandle* file_set,
359  const FileOptions& opts,
360  const SubsetList* subset_list = 0,
361  const Tag* file_id_tag = 0 );
362 
363  ErrorCode read_tag_values( const char* file_name,
364  const char* tag_name,
365  const FileOptions& opts,
366  std::vector< int >& tag_values_out,
367  const SubsetList* subset_list = 0 );
368 
369  //! Constructor
370  ReadABAQUS( Interface* impl = NULL );
371 
372  //! Destructor
373  virtual ~ReadABAQUS();
374 
375  private:
376  void reset();
377 
378  ErrorCode read_heading( EntityHandle file_set );
379  ErrorCode read_part( EntityHandle file_set );
382  ErrorCode read_node_list( EntityHandle parent_set, EntityHandle assembly_set = 0 );
383  ErrorCode read_element_list( EntityHandle parent_set, EntityHandle assembly_set = 0 );
384  ErrorCode read_node_set( EntityHandle parent_set, EntityHandle file_set = 0, EntityHandle assembly_set = 0 );
385  ErrorCode read_element_set( EntityHandle parent_set, EntityHandle file_set = 0, EntityHandle assembly_set = 0 );
387  ErrorCode read_instance( EntityHandle assembly_set, EntityHandle file_set );
388 
390  std::vector< int > element_ids_subset,
391  Range& element_range );
392 
393  ErrorCode get_nodes_by_id( EntityHandle parent_set, std::vector< int > node_ids_subset, Range& node_range );
394 
396  int ABQ_set_type,
397  const std::string& set_name,
398  EntityHandle& set_handle );
399 
400  ErrorCode get_set_elements( EntityHandle set_handle, Range& element_range );
401 
403  int ABQ_set_type,
404  const std::string& set_name,
405  Range& element_range );
406 
408  int ABQ_set_type,
409  const std::string& set_name,
410  Range& node_range );
411 
413  int ABQ_set_type,
414  const std::string& set_name,
415  EntityHandle& entity_set );
416 
418  const EntityHandle parent_set,
419  const std::string& part_name,
420  const std::string& instance_name,
421  EntityHandle& entity_set,
422  const std::vector< double >& translation,
423  const std::vector< double >& rotation );
424 
425  Tag get_tag( const char* tag_name,
426  int tag_size,
427  TagType tag_type,
428  DataType tag_data_type,
429  const void* def_val = 0 );
430 
431  void cyl2rect( std::vector< double > coord_list );
432 
433  void sph2rect( std::vector< double > coord_list );
434 
437 
438  template < class T >
439  std::string match( const std::string& token, std::map< std::string, T >& tokenList );
440 
441  void stringToUpper( const std::string& toBeConverted, std::string& converted );
442 
443  void extract_keyword_parameters( const std::vector< std::string >& tokens,
444  std::map< std::string, std::string >& params );
445 
446  //! Interface instance
448 
449  //! Read mesh interface
451 
452  std::ifstream abFile; // abaqus file
453 
454  std::string readline;
455 
456  unsigned lineNo;
457 
458  //! Cached tags for reading. Note that all these tags are defined when the
459  //! core is initialized.
464 
469 
473 
476 
478 
479  std::map< EntityHandle, unsigned int > num_part_instances;
480  std::map< EntityHandle, unsigned int > num_assembly_instances;
481  std::map< std::string, unsigned int > matIDmap;
482  unsigned mat_id;
483 };
484 
485 } // namespace moab
486 
487 #endif