MOAB: Mesh Oriented datABase
(version 5.4.1)
|
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 : ReadNCDF.hpp 00018 // 00019 // Purpose : ExodusII reader 00020 // 00021 // Special Notes : Lots of code taken from verde implementation 00022 // 00023 // Creator : Tim Tautges & Corey Ernst 00024 // 00025 // Date : 3/02 00026 // 00027 // Owner : Tim Tautges & Corey Ernst 00028 //------------------------------------------------------------------------- 00029 00030 #ifndef READNCDF_HPP 00031 #define READNCDF_HPP 00032 00033 #ifndef IS_BUILDING_MB 00034 //#error "ReadNCDF.hpp isn't supposed to be included into an application" 00035 #endif 00036 00037 #include <vector> 00038 #include <string> 00039 00040 #include "moab/Forward.hpp" 00041 #include "moab/ReaderIface.hpp" 00042 #include "moab/ExoIIInterface.hpp" 00043 #include "moab/Range.hpp" 00044 00045 namespace moab 00046 { 00047 00048 class ReadUtilIface; 00049 00050 struct ReadBlockData 00051 { 00052 int blockId; 00053 int startExoId; 00054 EntityHandle startMBId; 00055 int numElements; 00056 bool reading_in; 00057 ExoIIElementType elemType; 00058 std::vector< EntityHandle > polys; // used only if elem type is polyhedra or polygons 00059 // because the order has to be maintained 00060 }; 00061 00062 // these are for polyhedra only 00063 struct ReadFaceBlockData 00064 { 00065 int faceBlockId; 00066 int startExoId; 00067 int numElements; 00068 bool reading_in; 00069 // ExoIIElementType elemType; should be polygons 00070 }; 00071 00072 //! Output Exodus File for VERDE 00073 class ReadNCDF : public ReaderIface 00074 { 00075 00076 public: 00077 static ReaderIface* factory( Interface* ); 00078 00079 void tokenize( const std::string& str, std::vector< std::string >& tokens, const char* delimiters ); 00080 00081 //! load an ExoII file 00082 ErrorCode load_file( const char* file_name, 00083 const EntityHandle* file_set, 00084 const FileOptions& opts, 00085 const SubsetList* subset_list = 0, 00086 const Tag* file_id_tag = 0 ); 00087 00088 ErrorCode read_tag_values( const char* file_name, 00089 const char* tag_name, 00090 const FileOptions& opts, 00091 std::vector< int >& tag_values_out, 00092 const SubsetList* subset_list = 0 ); 00093 00094 //! Constructor 00095 ReadNCDF( Interface* impl = NULL ); 00096 00097 //! Destructor 00098 virtual ~ReadNCDF(); 00099 00100 // update the coords for deformed mesh according to FileOptions 00101 ErrorCode update( const char* exodus_file_name, 00102 const FileOptions& opts, 00103 const int num_blocks, 00104 const int* blocks_to_load, 00105 const EntityHandle file_set ); 00106 00107 private: 00108 ReadUtilIface* readMeshIface; 00109 00110 bool dimension_exists( const char* attrib_name ); 00111 00112 void reset(); 00113 00114 //! read the header from the ExoII file 00115 ErrorCode read_exodus_header(); 00116 00117 //! read the nodes 00118 ErrorCode read_nodes( const Tag* file_id_tag ); 00119 00120 // face blocks for polyhedra 00121 ErrorCode read_face_blocks_headers(); // all of them? 00122 00123 //! read block headers, containing info about element type, number, etc. 00124 ErrorCode read_block_headers( const int* blocks_to_load, const int num_blocks ); 00125 00126 // these are needed only when polyhedra are present 00127 ErrorCode read_polyhedra_faces(); 00128 00129 //! read the element blocks 00130 ErrorCode read_elements( const Tag* file_id_tag ); 00131 00132 //! read in the global element ids 00133 ErrorCode read_global_ids(); 00134 00135 //! read the nodesets into meshsets 00136 ErrorCode read_nodesets(); 00137 00138 //! read the sidesets (does nothing for now) 00139 ErrorCode read_sidesets(); 00140 00141 //! exodus file bound to this object 00142 int exodus_file(); 00143 00144 //! number of dimensions in this exo file 00145 int number_dimensions(); 00146 00147 //! map a character exodusII element type to a TSTT type & topology 00148 ErrorCode get_type( char* exo_element_type, EntityType& elem_type ); 00149 00150 ErrorCode get_type( EntityType& elem_type, std::string& exo_element_type ); 00151 00152 /* 00153 int get_int_tag(const MB_MeshSet *this_ms, 00154 const TagHandle tag_id); 00155 */ 00156 00157 // qa record stuff 00158 ErrorCode read_qa_records( EntityHandle file_set ); 00159 ErrorCode read_qa_information( std::vector< std::string >& qa_record_list ); 00160 00161 ErrorCode read_qa_string( char* string, int record_number, int record_position ); 00162 00163 ErrorCode create_ss_elements( int* element_ids, 00164 int* side_list, 00165 int num_sides, 00166 int num_dist_factors, 00167 std::vector< EntityHandle >& entities_to_add, 00168 std::vector< EntityHandle >& reverse_entities, 00169 std::vector< double >& dist_factor_vector, 00170 int ss_seq_id ); 00171 00172 ErrorCode find_side_element_type( const int element_id, 00173 ExoIIElementType& type, 00174 ReadBlockData& block_data, 00175 int& df_index, 00176 int side_id ); 00177 00178 /* ErrorCode assign_block_ids_to_ssets(EntityHandle ss_handle, 00179 MB_MeshSet *ss_mesh_set); 00180 */ 00181 00182 //! creates an element with the given connectivity 00183 ErrorCode create_sideset_element( const std::vector< EntityHandle >&, EntityType, EntityHandle&, int& ); 00184 00185 int get_number_nodes( EntityHandle handle ); 00186 00187 //------------member variables ------------// 00188 00189 //! interface instance 00190 Interface* mdbImpl; 00191 00192 int ncFile; // netcdf/exodus file 00193 00194 int CPU_WORD_SIZE; 00195 int IO_WORD_SIZE; 00196 00197 //! int to offset vertex ids with 00198 int vertexOffset; 00199 00200 //! file name 00201 std::string exodusFile; 00202 00203 //! number of nodes in the current exoII file 00204 int numberNodes_loading; 00205 00206 //! number of elements in the current exoII file 00207 int numberElements_loading; 00208 00209 //! number of blocks in the current exoII file 00210 int numberElementBlocks_loading; 00211 00212 //! number of face blocks in the current exoII file (used for polyhedra) 00213 int numberFaceBlocks_loading; 00214 00215 //! number of nodesets in the current exoII file 00216 int numberNodeSets_loading; 00217 00218 //! number of sidesets in the current exoII file 00219 int numberSideSets_loading; 00220 00221 int numberDimensions_loading; 00222 00223 //! Meshset Handle for the mesh that is currently being read 00224 EntityHandle mCurrentMeshHandle; 00225 00226 // keeps track of the exodus ids of the elements and nodes just loaded 00227 std::vector< char > nodesInLoadedBlocks; 00228 // note- vector<bool> has limited capabilities 00229 00230 // vector of blocks that are loading 00231 std::vector< ReadBlockData > blocksLoading; 00232 00233 std::vector< EntityHandle > polyfaces; // the order is maintained with this for polyhedra 00234 00235 // vector of face blocks that are loading : these are for polyhedra blocks 00236 std::vector< ReadFaceBlockData > faceBlocksLoading; 00237 00238 //! Cached tags for reading. Note that all these tags are defined when the 00239 //! core is initialized. 00240 Tag mMaterialSetTag; 00241 Tag mDirichletSetTag; 00242 Tag mNeumannSetTag; 00243 Tag mHasMidNodesTag; 00244 Tag mDistFactorTag; 00245 Tag mGlobalIdTag; 00246 Tag mQaRecordTag; 00247 00248 int max_line_length, max_str_length; 00249 00250 //! range of entities in initial mesh, before this read 00251 Range initRange; 00252 }; 00253 00254 // inline functions 00255 inline int ReadNCDF::number_dimensions() 00256 { 00257 return numberDimensions_loading; 00258 } 00259 00260 } // namespace moab 00261 00262 #endif