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
242 enum abaqus_line_types
243 {
244 abq_undefined_line = 0,
245 abq_blank_line,
246 abq_comment_line,
247 abq_keyword_line,
248 abq_data_line,
249 abq_eof
250 };
251
252 enum abaqus_keyword_type
253 {
254 abq_undefined = 0,
255 abq_unsupported,
256 abq_ambiguous,
257 abq_heading,
258 abq_part,
259 abq_end_part,
260 abq_assembly,
261 abq_end_assembly,
262 abq_node,
263 abq_element,
264 abq_nset,
265 abq_elset,
266 abq_instance,
267 abq_end_instance,
268 abq_solid_section
269 };
270
271 enum abaqus_part_params
272 {
273 abq_part_undefined = 0,
274 abq_part_ambiguous,
275 abq_part_name
276 };
277
278 enum abaqus_instance_params
279 {
280 abq_instance_undefined = 0,
281 abq_instance_ambiguous,
282 abq_instance_name,
283 abq_instance_part
284 };
285
286 enum abaqus_assembly_params
287 {
288 abq_assembly_undefined = 0,
289 abq_assembly_ambiguous,
290 abq_assembly_name
291 };
292
293 enum abaqus_node_params
294 {
295 abq_node_undefined = 0,
296 abq_node_ambiguous,
297 abq_node_nset,
298 abq_node_system
299 };
300
301 enum abaqus_element_params
302 {
303 abq_element_undefined = 0,
304 abq_element_ambiguous,
305 abq_element_elset,
306 abq_element_type
307 };
308
309 enum abaqus_element_type
310 {
311 abq_eletype_unsupported = 0,
312 abq_eletype_dc3d8,
313 abq_eletype_c3d8r,
314 abq_eletype_dcc3d8,
315 abq_eletype_c3d4,
316 abq_eletype_dc3d4,
317 abq_eletype_ds4
318 };
319
320 enum abaqus_nset_params
321 {
322 abq_nset_undefined = 0,
323 abq_nset_ambiguous,
324 abq_nset_nset,
325 abq_nset_elset,
326 abq_nset_generate,
327 abq_nset_instance
328 };
329
330 enum abaqus_elset_params
331 {
332 abq_elset_undefined = 0,
333 abq_elset_ambiguous,
334 abq_elset_elset,
335 abq_elset_generate,
336 abq_elset_instance
337 };
338
339 enum abaqus_solid_section_params
340 {
341 abq_solid_section_undefined = 0,
342 abq_solid_section_ambiguous,
343 abq_solid_section_elset,
344 abq_solid_section_matname
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 );
380 ErrorCode read_assembly( EntityHandle file_set );
381 ErrorCode read_unsupported( 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 );
386 ErrorCode read_solid_section( EntityHandle parent_set );
387 ErrorCode read_instance( EntityHandle assembly_set, EntityHandle file_set );
388
389 ErrorCode get_elements_by_id( EntityHandle parent_set,
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
395 ErrorCode get_set_by_name( EntityHandle parent_set,
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
402 ErrorCode get_set_elements_by_name( EntityHandle parent_set,
403 int ABQ_set_type,
404 const std::string& set_name,
405 Range& element_range );
406
407 ErrorCode get_set_nodes( EntityHandle parent_set,
408 int ABQ_set_type,
409 const std::string& set_name,
410 Range& node_range );
411
412 ErrorCode add_entity_set( EntityHandle parent_set,
413 int ABQ_set_type,
414 const std::string& set_name,
415 EntityHandle& entity_set );
416
417 ErrorCode create_instance_of_part( const EntityHandle file_set,
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
435 abaqus_line_types get_next_line_type();
436 abaqus_keyword_type get_keyword();
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
447 Interface* mdbImpl;
448
449 //! Read mesh interface
450 ReadUtilIface* readMeshIface;
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.
460 Tag mMaterialSetTag;
461 Tag mDirichletSetTag;
462 Tag mNeumannSetTag;
463 Tag mHasMidNodesTag;
464
465 Tag mSetTypeTag;
466 Tag mPartHandleTag;
467 Tag mInstancePIDTag;
468 Tag mInstanceGIDTag;
469
470 Tag mLocalIDTag;
471 Tag mInstanceHandleTag;
472 Tag mAssemblyHandleTag;
473
474 Tag mSetNameTag;
475 Tag mMatNameTag;
476
477 abaqus_line_types next_line_type;
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