moab
ReadABAQUS.hpp
Go to the documentation of this file.
00001 
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 
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 
00202 #include <vector>
00203 #include <map>
00204 #include <string>
00205 #include <iostream>
00206 #include <fstream>
00207 
00208 #include "moab/Forward.hpp"
00209 #include "moab/ReaderIface.hpp"
00210 #include "moab/Range.hpp"
00211 
00212 namespace moab {
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 
00243 enum abaqus_line_types { abq_undefined_line = 0,
00244              abq_blank_line, 
00245              abq_comment_line, 
00246              abq_keyword_line, 
00247              abq_data_line, 
00248              abq_eof };
00249 
00250 enum abaqus_keyword_type { abq_undefined = 0,
00251                abq_unsupported,
00252                abq_ambiguous,
00253                abq_heading,
00254                abq_part,
00255                abq_end_part,
00256                abq_assembly,
00257                            abq_end_assembly,
00258                abq_node,
00259                abq_element,
00260                abq_nset,
00261                abq_elset,
00262                abq_instance,
00263                abq_end_instance,
00264                abq_solid_section};
00265 
00266 enum abaqus_part_params { abq_part_undefined = 0,
00267               abq_part_ambiguous,
00268               abq_part_name};
00269 
00270 enum abaqus_instance_params { abq_instance_undefined = 0,
00271                   abq_instance_ambiguous,
00272                   abq_instance_name,
00273                   abq_instance_part};
00274 
00275 enum abaqus_assembly_params { abq_assembly_undefined = 0,
00276                   abq_assembly_ambiguous,
00277                   abq_assembly_name};
00278 
00279 enum abaqus_node_params { abq_node_undefined = 0,
00280               abq_node_ambiguous,
00281               abq_node_nset,
00282               abq_node_system};
00283 
00284 enum abaqus_element_params { abq_element_undefined = 0,
00285                  abq_element_ambiguous,
00286                  abq_element_elset,
00287                  abq_element_type};
00288 
00289 enum abaqus_element_type { abq_eletype_unsupported = 0,
00290                abq_eletype_dc3d8,
00291                abq_eletype_c3d8r,
00292                abq_eletype_dcc3d8, 
00293                abq_eletype_c3d4,
00294                abq_eletype_dc3d4,
00295                            abq_eletype_ds4};
00296 
00297 enum abaqus_nset_params { abq_nset_undefined = 0,
00298               abq_nset_ambiguous,
00299               abq_nset_nset,
00300               abq_nset_elset,
00301               abq_nset_generate,
00302                           abq_nset_instance};           
00303 
00304 enum abaqus_elset_params { abq_elset_undefined = 0,
00305                abq_elset_ambiguous,
00306                abq_elset_elset,
00307                abq_elset_generate,
00308                            abq_elset_instance};
00309 
00310 enum abaqus_solid_section_params { abq_solid_section_undefined = 0,
00311                    abq_solid_section_ambiguous,
00312                    abq_solid_section_elset,
00313                    abq_solid_section_matname};
00314 
00315 
00316 
00317 
00318 class ReadUtilIface;
00319 
00320 class ReadABAQUS : public ReaderIface
00321 {
00322 public:
00323   
00324   static ReaderIface* factory( Interface* );
00325   
00326   void tokenize( const std::string& str,
00327                  std::vector<std::string>& tokens,
00328                  const char* delimiters );
00329   
00331   ErrorCode load_file( const char* file_name,
00332                        const EntityHandle* file_set,
00333                        const FileOptions& opts,
00334                        const SubsetList* subset_list = 0,
00335                        const Tag* file_id_tag = 0 );
00336   
00337   ErrorCode read_tag_values( const char* file_name,
00338                              const char* tag_name,
00339                              const FileOptions& opts,
00340                              std::vector<int>& tag_values_out,
00341                              const SubsetList* subset_list = 0 );
00342   
00344   ReadABAQUS(Interface* impl = NULL);
00345   
00347   virtual ~ReadABAQUS();
00348   
00349 private:
00350   
00351   void reset();
00352   
00353   ErrorCode read_heading(EntityHandle file_set);
00354   ErrorCode read_part(EntityHandle file_set);
00355   ErrorCode read_assembly(EntityHandle file_set);
00356   ErrorCode read_unsupported(EntityHandle file_set);
00357   ErrorCode read_node_list(EntityHandle parent_set,
00358                EntityHandle assembly_set = 0);
00359   ErrorCode read_element_list(EntityHandle parent_set,
00360                   EntityHandle assembly_set = 0);
00361   ErrorCode read_node_set(EntityHandle parent_set,
00362               EntityHandle file_set = 0,
00363               EntityHandle assembly_set = 0);
00364   ErrorCode read_element_set(EntityHandle parent_set,
00365                  EntityHandle file_set = 0,
00366                  EntityHandle assembly_set = 0);
00367   ErrorCode read_solid_section(EntityHandle parent_set);
00368   ErrorCode read_instance(EntityHandle assembly_set,
00369               EntityHandle file_set);
00370   
00371   
00372   ErrorCode get_elements_by_id(EntityHandle parent_set,
00373                  std::vector<int> element_ids_subset,
00374                  Range &element_range);
00375   
00376   ErrorCode get_nodes_by_id(EntityHandle parent_set,
00377                   std::vector<int> node_ids_subset,
00378                   Range &node_range);
00379     
00380   ErrorCode get_set_by_name(EntityHandle parent_set,
00381                   int ABQ_set_type,
00382                   std::string set_name,
00383                   EntityHandle &set_handle);
00384 
00385   ErrorCode get_set_elements(EntityHandle set_handle,
00386                    Range &element_range);
00387 
00388   ErrorCode get_set_elements_by_name(EntityHandle parent_set,
00389                        int ABQ_set_type,
00390                        std::string set_name,
00391                        Range &element_range);
00392     
00393                   
00394   ErrorCode get_set_nodes(EntityHandle parent_set,
00395                 int ABQ_set_type,
00396                 std::string set_name,
00397                 Range &node_range);
00398   
00399   ErrorCode add_entity_set(EntityHandle parent_set,
00400                  int ABQ_set_type,
00401                  std::string set_name,
00402                  EntityHandle &entity_set);
00403 
00404   ErrorCode create_instance_of_part(const EntityHandle file_set,
00405                       const EntityHandle parent_set,
00406                       const std::string part_name,
00407                       const std::string instance_name,
00408                       EntityHandle &entity_set,
00409                       const std::vector<double> &translation,
00410                       const std::vector<double> &rotation);
00411 
00412   Tag get_tag(const char* tag_name, int tag_size, TagType tag_type,
00413                 DataType tag_data_type, const void* def_val = 0);
00414   
00415   void cyl2rect(std::vector<double> coord_list);
00416 
00417   void sph2rect(std::vector<double> coord_list);
00418 
00419   abaqus_line_types get_next_line_type();
00420   abaqus_keyword_type get_keyword();
00421     
00422   template <class T>
00423   std::string match(const std::string &token, 
00424             std::map<std::string,T> &tokenList);
00425 
00426   void stringToUpper(std::string toBeConverted,std::string& converted);
00427 
00428   
00429   void extract_keyword_parameters(std::vector<std::string> tokens,
00430                   std::map<std::string,std::string>& params);
00431 
00433   Interface* mdbImpl;
00434 
00435   // read mesh interface
00436   ReadUtilIface* readMeshIface;
00437 
00438   std::ifstream abFile;        // abaqus file
00439 
00440   std::string readline;
00441   
00442   unsigned lineNo;
00443   
00444   void report_error( const char* );
00445 
00448   Tag mMaterialSetTag;
00449   Tag mDirichletSetTag;
00450   Tag mNeumannSetTag;
00451   Tag mHasMidNodesTag;
00452 
00453   Tag mSetTypeTag;
00454   Tag mPartHandleTag;
00455   Tag mInstancePIDTag;
00456   Tag mInstanceGIDTag;
00457 
00458   Tag mLocalIDTag;
00459   Tag mInstanceHandleTag;
00460   Tag mAssemblyHandleTag;
00461 
00462   Tag mSetNameTag;
00463   Tag mMatNameTag;
00464 
00465   abaqus_line_types  next_line_type;
00466 
00467   std::map<EntityHandle,unsigned int> num_part_instances;
00468   std::map<EntityHandle,unsigned int> num_assembly_instances;
00469   std::map<std::string,unsigned int> matIDmap;
00470   unsigned mat_id;
00471   
00472 };
00473 
00474 } // namespace moab
00475 
00476 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines