moab
|
00001 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 class ReadUtilIface; 00048 00049 struct ReadBlockData 00050 { 00051 int blockId; 00052 int startExoId; 00053 EntityHandle startMBId; 00054 int numElements; 00055 bool reading_in; 00056 ExoIIElementType elemType; 00057 }; 00058 00060 class ReadNCDF : public ReaderIface 00061 { 00062 00063 public: 00064 00065 static ReaderIface* factory( Interface* ); 00066 00067 void tokenize( const std::string& str, 00068 std::vector<std::string>& tokens, 00069 const char* delimiters ); 00070 00072 ErrorCode load_file( const char* file_name, 00073 const EntityHandle* file_set, 00074 const FileOptions& opts, 00075 const SubsetList* subset_list = 0, 00076 const Tag* file_id_tag = 0 ); 00077 00078 ErrorCode read_tag_values( const char* file_name, 00079 const char* tag_name, 00080 const FileOptions& opts, 00081 std::vector<int>& tag_values_out, 00082 const SubsetList* subset_list = 0 ); 00083 00085 ReadNCDF(Interface* impl = NULL); 00086 00088 virtual ~ReadNCDF(); 00089 00090 //update the coords for deformed mesh according to FileOptions 00091 ErrorCode update(const char *exodus_file_name, const FileOptions& opts, 00092 const int num_blocks, const int *blocks_to_load, 00093 const EntityHandle file_set ); 00094 00095 private: 00096 00097 ReadUtilIface* readMeshIface; 00098 00099 bool dimension_exists(const char *attrib_name); 00100 00101 void reset(); 00102 00104 ErrorCode read_exodus_header(); 00105 00107 ErrorCode read_nodes(const Tag* file_id_tag); 00108 00110 ErrorCode read_block_headers(const int *blocks_to_load, 00111 const int num_blocks); 00112 00114 ErrorCode read_elements(const Tag* file_id_tag); 00115 00117 ErrorCode read_global_ids(); 00118 00120 ErrorCode read_nodesets(); 00121 00123 ErrorCode read_sidesets(); 00124 00126 int exodus_file(); 00127 00129 int number_dimensions(); 00130 00132 ErrorCode get_type(char *exo_element_type, 00133 EntityType &elem_type); 00134 00135 ErrorCode get_type(EntityType &elem_type, 00136 std::string &exo_element_type); 00137 00138 /* 00139 int get_int_tag(const MB_MeshSet *this_ms, 00140 const TagHandle tag_id); 00141 */ 00142 00143 //qa record stuff 00144 ErrorCode read_qa_records(EntityHandle file_set); 00145 ErrorCode read_qa_information( std::vector<std::string> &qa_record_list); 00146 00147 ErrorCode read_qa_string(char *string, 00148 int record_number, 00149 int record_position); 00150 00151 ErrorCode create_ss_elements( int *element_ids, int *side_list, 00152 int num_sides, int num_dist_factors, 00153 std::vector<EntityHandle> &entities_to_add, 00154 std::vector<EntityHandle> &reverse_entities, 00155 std::vector<double> &dist_factor_vector, 00156 int ss_seq_id); 00157 00158 ErrorCode find_side_element_type( const int element_id, ExoIIElementType &type, 00159 ReadBlockData &block_data, int &df_index, int side_id ); 00160 00161 /* ErrorCode assign_block_ids_to_ssets(EntityHandle ss_handle, 00162 MB_MeshSet *ss_mesh_set); 00163 */ 00164 00166 ErrorCode create_sideset_element( const std::vector<EntityHandle>&, EntityType, EntityHandle&, int&); 00167 00168 int get_number_nodes( EntityHandle handle ); 00169 00170 00171 00172 //------------member variables ------------// 00173 00175 Interface* mdbImpl; 00176 00177 int ncFile; // netcdf/exodus file 00178 00179 int CPU_WORD_SIZE; 00180 int IO_WORD_SIZE; 00181 00183 int vertexOffset; 00184 00186 std::string exodusFile; 00187 00189 int numberNodes_loading; 00190 00192 int numberElements_loading; 00193 00195 int numberElementBlocks_loading; 00196 00198 int numberNodeSets_loading; 00199 00201 int numberSideSets_loading; 00202 00203 int numberDimensions_loading; 00204 00206 EntityHandle mCurrentMeshHandle; 00207 00208 //keeps track of the exodus ids of the elements and nodes just loaded 00209 std::vector<char> nodesInLoadedBlocks; 00210 //note- vector<bool> has limited capabilities 00211 00212 //vector of blocks that are loading 00213 std::vector< ReadBlockData > blocksLoading; 00214 00217 Tag mMaterialSetTag; 00218 Tag mDirichletSetTag; 00219 Tag mNeumannSetTag; 00220 Tag mHasMidNodesTag; 00221 Tag mDistFactorTag; 00222 Tag mGlobalIdTag; 00223 Tag mQaRecordTag; 00224 00225 int max_line_length, max_str_length; 00226 00228 Range initRange; 00229 }; 00230 00231 // inline functions 00232 inline int ReadNCDF::number_dimensions() 00233 { 00234 return numberDimensions_loading; 00235 } 00236 00237 } // namespace moab 00238 00239 #endif 00240 00241 00242 00243