Mesh Oriented datABase
(version 5.4.1)
Array-based unstructured mesh datastructure
|
00001 /** 00002 * MOAB, a Mesh-Oriented datABase, is a software component for creating, 00003 * storing and accessing finite element mesh data. 00004 * 00005 * Copyright 2004 Sandia Corporation. Under the terms of Contract 00006 * DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government 00007 * retains certain rights in this software. 00008 * 00009 * This library is free software; you can redistribute it and/or 00010 * modify it under the terms of the GNU Lesser General Public 00011 * License as published by the Free Software Foundation; either 00012 * version 2.1 of the License, or (at your option) any later version. 00013 * 00014 */ 00015 00016 //------------------------------------------------------------------------- 00017 // Filename : ReadABAQUS.hpp 00018 // 00019 // Purpose : ABAQUS inp file reader 00020 // 00021 // Special Notes : Started with NetCDF EXODUS II reader 00022 // 00023 // Creator : Paul Wilson & Patrick Snouffer 00024 // 00025 // Date : 08/2009 00026 // 00027 // Owner : Paul Wilson 00028 //------------------------------------------------------------------------- 00029 00030 /** Implementation of ABAQUS mesh hierarchy and meta-data on MOAB 00031 00032 00033 This reader processes data written by the ABAQUS computer-aided engineering 00034 front-end. While that tool writes binary files in its own proprietary format, 00035 it also writes an ASCII input file that is the fundamental input to the 00036 ABAQUS solver itself. A published syntax for this format is available from Simulia. 00037 00038 This reader only supports a subset of the mesh syntax necessary to support 00039 a basic thermal analysis of solid systems. 00040 00041 An ABAQUS mesh makes use of the common paradigms of building a 00042 geometry as an "assembly" of "instances" of "parts". 00043 00044 A "part" is defined as a set of "nodes" and "elements" connecting 00045 those nodes. The nodes and elements can be arranged in "node sets" and 00046 "element sets" and specific "materials" can be assigned to "element 00047 sets" other features of parts are not currently used by applications 00048 and are not implemented. 00049 00050 00051 Overview of supported structure 00052 00053 * File: 00054 * Heading 00055 * Part 00056 * Nodes 00057 * Elements 00058 * Node Sets 00059 * Element Sets 00060 * Solid Sections 00061 * Assembly 00062 * Instance 00063 * Nodes 00064 * Elements 00065 * Node Sets 00066 * Element Sets 00067 * Solid Sections 00068 * Node Sets 00069 00070 00071 An "instance" is a full copy of a "part" with a linear geometric 00072 transformation. To create a full copy: 00073 • a duplicate set of nodes is created by copying the coordinates of 00074 the part nodes and applying a linear geometric transformation - the 00075 new coords are used to define the new nodes 00076 • a new node set is created for each node set in the part and the set 00077 of nodes among the duplicates are assigned to the new node set 00078 • a duplicate set of elements is defined by creating a new element 00079 with a connectivity made up of the duplicate nodes that correspond 00080 to the appropriate original element 00081 • a new element set is created for each element set in the part and 00082 the set of elements among the duplicates are assigned to the new 00083 element set; the corresponding material is also assigned go the new 00084 element sets 00085 00086 It is also possible for an "instance" to contain the complete 00087 definition of the mesh, copying nothing from the "part" (the "part" 00088 may have no mesh defined). It is unclear whether an "instance" can 00089 combine mesh from the "part" definition with mesh contained only in 00090 the "instance" definition. (Not appropriately documented in ABAUQUS 00091 Reference Manual.) 00092 00093 In order to provide convenient access to the data and mesh structures 00094 the following data model is used: 00095 00096 • EntitySet file_set 00097 • tags 00098 • NONE 00099 • members 00100 • all nodes of all parts and all instances 00101 • all elements of all parts and all instances 00102 • all assembly_sets 00103 • all part_sets 00104 • EntitySet part_set 00105 • tags 00106 • mSetNameTag (opaque=char*) 00107 name of entity set 00108 • members 00109 • part nodes 00110 • part elements 00111 • part node sets 00112 • part element sets 00113 • EntitySet assembly_set 00114 • tags 00115 • mSetNameTag (opaque=char*) 00116 name of entity set 00117 • members 00118 • instance_sets 00119 • instance element_sets 00120 • instance node_sets 00121 • instance nodes 00122 • instance elements 00123 • EntitySet instance_set 00124 • tags 00125 • mSetNameTag (opaque=char*) 00126 name of entity set 00127 • mPartHandleTag (handle) 00128 pointer to part from which this instance was generated 00129 • mAssemblyHandleTag (handle) 00130 pointer to assembly in which this instance exists 00131 • mInstancePIDTag (int) 00132 ordinal number indicating which instance of this part 00133 • mInstanceGIDTag (int) 00134 ordinal number indicating which instance in this assembly 00135 • members 00136 • instance nodes 00137 • instance elements 00138 • instance node_sets 00139 • instance element_sets 00140 • EntitySet node_set 00141 • tags 00142 • mSetNameTag (opaque=char*) 00143 name of entity set 00144 • mPartHandleTag (handle) 00145 pointer to part in which this node set exists 00146 (only defined for node sets that are in an instance and 00147 derive from a part) 00148 • mInstanceHandleTag (handle) 00149 pointer back to instance set in which this node set exists 00150 (NULL if this node_set is not in an instance) 00151 • mAssemblyHandleTag (handle) 00152 pointer to assembly in which this node set exists 00153 (NULL if this node_set is not in an assembly) 00154 • members 00155 • nodes 00156 • EntitySet element_set 00157 • tags 00158 • mSetNameTag (opaque=char*) 00159 name of entity set 00160 • mPartHandleTag (handle) 00161 pointer to part in which this element set exists 00162 (only defined for node sets that are in an instance and 00163 derive from a part) 00164 • mInstanceHandleTag (handle) 00165 pointer back to instance set in which this element set exists 00166 (NULL if this node_set is not in an instance) 00167 • mAssemblyHandleTag (handle) 00168 pointer to assembly in which this element set exists 00169 (NULL if this node_set is not in an assembly) 00170 • mMatNameTag (opaque=char*) 00171 name of material in these elements 00172 • mMaterialSetTag (integer) 00173 material id in these elements 00174 • members 00175 • elements 00176 • Entity node 00177 • tags 00178 • mLocalIDTag (int) 00179 numerical ID of node in local scope (part, instance) 00180 • mInstanceHandleTag (handle) 00181 pointer back to instance set in which this node exists 00182 (NULL if this node is not in an instance) 00183 • Entity element 00184 • tags 00185 • mLocalIDTag (int) 00186 numerical ID of element in local scope (part, instance) 00187 • mInstanceHandleTag (handle) 00188 pointer back to instance set in which this element exists 00189 (NULL if this element is not in an instance) 00190 00191 00192 **/ 00193 00194 #ifndef READABAQUS_HPP 00195 #define READABAQUS_HPP 00196 00197 #ifndef IS_BUILDING_MB 00198 #error "ReadABAQUS.hpp isn't supposed to be included into an application" 00199 #endif 00200 00201 #include <vector> 00202 #include <map> 00203 #include <string> 00204 #include <iostream> 00205 #include <fstream> 00206 00207 #include "moab/Forward.hpp" 00208 #include "moab/ReaderIface.hpp" 00209 #include "moab/Range.hpp" 00210 00211 namespace moab 00212 { 00213 00214 #define ABAQUS_SET_TYPE_TAG_NAME "abaqus_set_type" 00215 #define ABAQUS_SET_NAME_TAG_NAME "abaqus_set_name" 00216 #define ABAQUS_SET_NAME_LENGTH 100 00217 #define ABAQUS_LOCAL_ID_TAG_NAME "abaqus_local_id" 00218 00219 // Many sets should know who contains them 00220 #define ABAQUS_INSTANCE_HANDLE_TAG_NAME "abaqus_instance_handle" 00221 #define ABAQUS_ASSEMBLY_HANDLE_TAG_NAME "abaqus_assembly_handle" 00222 #define ABAQUS_PART_HANDLE_TAG_NAME "abaqus_part_handle" 00223 00224 // Instances should know things about themselves: 00225 // * which part they derive from (see ABAQUS_PART_HANDLE_TAG_NAME above) 00226 // * which instance of a part this is 00227 // * which instance of an assembly this is 00228 #define ABAQUS_INSTANCE_PART_ID_TAG_NAME "abaqus_instance_part_id" 00229 #define ABAQUS_INSTANCE_GLOBAL_ID_TAG_NAME "abaqus_instance_global_id" 00230 00231 // Element sets have material name 00232 // Using MOAB's general MATERIAL_SET to store material id 00233 #define ABAQUS_MAT_NAME_TAG_NAME "abaqus_mat_name" 00234 #define ABAQUS_MAT_NAME_LENGTH 100 00235 00236 #define ABQ_ASSEMBLY_SET 1 00237 #define ABQ_PART_SET 2 00238 #define ABQ_INSTANCE_SET 3 00239 #define ABQ_NODE_SET 4 00240 #define ABQ_ELEMENT_SET 5 00241 00242 enum abaqus_line_types 00243 { 00244 abq_undefined_line = 0, 00245 abq_blank_line, 00246 abq_comment_line, 00247 abq_keyword_line, 00248 abq_data_line, 00249 abq_eof 00250 }; 00251 00252 enum abaqus_keyword_type 00253 { 00254 abq_undefined = 0, 00255 abq_unsupported, 00256 abq_ambiguous, 00257 abq_heading, 00258 abq_part, 00259 abq_end_part, 00260 abq_assembly, 00261 abq_end_assembly, 00262 abq_node, 00263 abq_element, 00264 abq_nset, 00265 abq_elset, 00266 abq_instance, 00267 abq_end_instance, 00268 abq_solid_section 00269 }; 00270 00271 enum abaqus_part_params 00272 { 00273 abq_part_undefined = 0, 00274 abq_part_ambiguous, 00275 abq_part_name 00276 }; 00277 00278 enum abaqus_instance_params 00279 { 00280 abq_instance_undefined = 0, 00281 abq_instance_ambiguous, 00282 abq_instance_name, 00283 abq_instance_part 00284 }; 00285 00286 enum abaqus_assembly_params 00287 { 00288 abq_assembly_undefined = 0, 00289 abq_assembly_ambiguous, 00290 abq_assembly_name 00291 }; 00292 00293 enum abaqus_node_params 00294 { 00295 abq_node_undefined = 0, 00296 abq_node_ambiguous, 00297 abq_node_nset, 00298 abq_node_system 00299 }; 00300 00301 enum abaqus_element_params 00302 { 00303 abq_element_undefined = 0, 00304 abq_element_ambiguous, 00305 abq_element_elset, 00306 abq_element_type 00307 }; 00308 00309 enum abaqus_element_type 00310 { 00311 abq_eletype_unsupported = 0, 00312 abq_eletype_dc3d8, 00313 abq_eletype_c3d8r, 00314 abq_eletype_dcc3d8, 00315 abq_eletype_c3d4, 00316 abq_eletype_dc3d4, 00317 abq_eletype_ds4 00318 }; 00319 00320 enum abaqus_nset_params 00321 { 00322 abq_nset_undefined = 0, 00323 abq_nset_ambiguous, 00324 abq_nset_nset, 00325 abq_nset_elset, 00326 abq_nset_generate, 00327 abq_nset_instance 00328 }; 00329 00330 enum abaqus_elset_params 00331 { 00332 abq_elset_undefined = 0, 00333 abq_elset_ambiguous, 00334 abq_elset_elset, 00335 abq_elset_generate, 00336 abq_elset_instance 00337 }; 00338 00339 enum abaqus_solid_section_params 00340 { 00341 abq_solid_section_undefined = 0, 00342 abq_solid_section_ambiguous, 00343 abq_solid_section_elset, 00344 abq_solid_section_matname 00345 }; 00346 00347 class ReadUtilIface; 00348 00349 class ReadABAQUS : public ReaderIface 00350 { 00351 public: 00352 static ReaderIface* factory( Interface* ); 00353 00354 void tokenize( const std::string& str, std::vector< std::string >& tokens, const char* delimiters ); 00355 00356 //! Load an ABAQUS file 00357 ErrorCode load_file( const char* file_name, 00358 const EntityHandle* file_set, 00359 const FileOptions& opts, 00360 const SubsetList* subset_list = 0, 00361 const Tag* file_id_tag = 0 ); 00362 00363 ErrorCode read_tag_values( const char* file_name, 00364 const char* tag_name, 00365 const FileOptions& opts, 00366 std::vector< int >& tag_values_out, 00367 const SubsetList* subset_list = 0 ); 00368 00369 //! Constructor 00370 ReadABAQUS( Interface* impl = NULL ); 00371 00372 //! Destructor 00373 virtual ~ReadABAQUS(); 00374 00375 private: 00376 void reset(); 00377 00378 ErrorCode read_heading( EntityHandle file_set ); 00379 ErrorCode read_part( EntityHandle file_set ); 00380 ErrorCode read_assembly( EntityHandle file_set ); 00381 ErrorCode read_unsupported( EntityHandle file_set ); 00382 ErrorCode read_node_list( EntityHandle parent_set, EntityHandle assembly_set = 0 ); 00383 ErrorCode read_element_list( EntityHandle parent_set, EntityHandle assembly_set = 0 ); 00384 ErrorCode read_node_set( EntityHandle parent_set, EntityHandle file_set = 0, EntityHandle assembly_set = 0 ); 00385 ErrorCode read_element_set( EntityHandle parent_set, EntityHandle file_set = 0, EntityHandle assembly_set = 0 ); 00386 ErrorCode read_solid_section( EntityHandle parent_set ); 00387 ErrorCode read_instance( EntityHandle assembly_set, EntityHandle file_set ); 00388 00389 ErrorCode get_elements_by_id( EntityHandle parent_set, 00390 std::vector< int > element_ids_subset, 00391 Range& element_range ); 00392 00393 ErrorCode get_nodes_by_id( EntityHandle parent_set, std::vector< int > node_ids_subset, Range& node_range ); 00394 00395 ErrorCode get_set_by_name( EntityHandle parent_set, 00396 int ABQ_set_type, 00397 const std::string& set_name, 00398 EntityHandle& set_handle ); 00399 00400 ErrorCode get_set_elements( EntityHandle set_handle, Range& element_range ); 00401 00402 ErrorCode get_set_elements_by_name( EntityHandle parent_set, 00403 int ABQ_set_type, 00404 const std::string& set_name, 00405 Range& element_range ); 00406 00407 ErrorCode get_set_nodes( EntityHandle parent_set, 00408 int ABQ_set_type, 00409 const std::string& set_name, 00410 Range& node_range ); 00411 00412 ErrorCode add_entity_set( EntityHandle parent_set, 00413 int ABQ_set_type, 00414 const std::string& set_name, 00415 EntityHandle& entity_set ); 00416 00417 ErrorCode create_instance_of_part( const EntityHandle file_set, 00418 const EntityHandle parent_set, 00419 const std::string& part_name, 00420 const std::string& instance_name, 00421 EntityHandle& entity_set, 00422 const std::vector< double >& translation, 00423 const std::vector< double >& rotation ); 00424 00425 Tag get_tag( const char* tag_name, 00426 int tag_size, 00427 TagType tag_type, 00428 DataType tag_data_type, 00429 const void* def_val = 0 ); 00430 00431 void cyl2rect( std::vector< double > coord_list ); 00432 00433 void sph2rect( std::vector< double > coord_list ); 00434 00435 abaqus_line_types get_next_line_type(); 00436 abaqus_keyword_type get_keyword(); 00437 00438 template < class T > 00439 std::string match( const std::string& token, std::map< std::string, T >& tokenList ); 00440 00441 void stringToUpper( const std::string& toBeConverted, std::string& converted ); 00442 00443 void extract_keyword_parameters( const std::vector< std::string >& tokens, 00444 std::map< std::string, std::string >& params ); 00445 00446 //! Interface instance 00447 Interface* mdbImpl; 00448 00449 //! Read mesh interface 00450 ReadUtilIface* readMeshIface; 00451 00452 std::ifstream abFile; // abaqus file 00453 00454 std::string readline; 00455 00456 unsigned lineNo; 00457 00458 //! Cached tags for reading. Note that all these tags are defined when the 00459 //! core is initialized. 00460 Tag mMaterialSetTag; 00461 Tag mDirichletSetTag; 00462 Tag mNeumannSetTag; 00463 Tag mHasMidNodesTag; 00464 00465 Tag mSetTypeTag; 00466 Tag mPartHandleTag; 00467 Tag mInstancePIDTag; 00468 Tag mInstanceGIDTag; 00469 00470 Tag mLocalIDTag; 00471 Tag mInstanceHandleTag; 00472 Tag mAssemblyHandleTag; 00473 00474 Tag mSetNameTag; 00475 Tag mMatNameTag; 00476 00477 abaqus_line_types next_line_type; 00478 00479 std::map< EntityHandle, unsigned int > num_part_instances; 00480 std::map< EntityHandle, unsigned int > num_assembly_instances; 00481 std::map< std::string, unsigned int > matIDmap; 00482 unsigned mat_id; 00483 }; 00484 00485 } // namespace moab 00486 00487 #endif