moab
|
00001 00016 //------------------------------------------------------------------------- 00017 // Filename : WriteNCDF.hpp 00018 // 00019 // Purpose : ExodusII writer 00020 // 00021 // Special Notes : Lots of code taken from verde implementation 00022 // 00023 // Creator : Corey Ernst 00024 // 00025 // Date : 8/02 00026 // 00027 // Owner : Corey Ernst 00028 //------------------------------------------------------------------------- 00029 00030 #ifndef WRITENCDF_HPP 00031 #define WRITENCDF_HPP 00032 00033 #ifndef IS_BUILDING_MB 00034 #error "WriteNCDF.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/Range.hpp" 00042 #include "moab/ExoIIInterface.hpp" 00043 #include "moab/WriterIface.hpp" 00044 00045 namespace moab { 00046 00047 class WriteUtilIface; 00048 00051 struct MaterialSetData 00052 { 00053 int id; 00054 int number_elements; 00055 int number_nodes_per_element; 00056 int number_attributes; 00057 ExoIIElementType element_type; 00058 Range elements; 00059 }; 00060 00063 struct DirichletSetData 00064 { 00065 int id; 00066 int number_nodes; 00067 std::vector< EntityHandle > nodes; 00068 std::vector< double > node_dist_factors; 00069 00070 }; 00071 00074 struct NeumannSetData 00075 { 00076 int id; 00077 int number_elements; 00078 std::vector<EntityHandle> elements; 00079 std::vector<int> side_numbers; 00080 EntityHandle mesh_set_handle; 00081 std::vector< double > ss_dist_factors; 00082 }; 00083 00084 00086 class WriteNCDF : public WriterIface 00087 { 00088 00089 public: 00090 00091 static WriterIface* factory( Interface* ); 00092 00094 WriteNCDF(Interface *impl); 00095 00097 virtual ~WriteNCDF(); 00098 00100 ErrorCode write_file(const char *exodus_file_name, 00101 const bool overwrite, 00102 const FileOptions& opts, 00103 const EntityHandle *output_list, 00104 const int num_sets, 00105 const std::vector<std::string> &qa_records, 00106 const Tag* = NULL, 00107 int = 0, 00108 int user_dimension = 3); 00109 00110 protected: 00111 00113 //int number_dimensions(); 00114 00116 ErrorCode open_file(const char *file_name); 00117 00119 struct ExodusMeshInfo 00120 { 00121 unsigned int num_dim; 00122 unsigned int num_nodes; 00123 unsigned int num_elements; 00124 unsigned int num_elementblocks; 00125 std::vector<std::string> qaRecords; 00126 Range nodes; 00127 }; 00128 00129 private: 00130 00132 Interface *mdbImpl; 00133 WriteUtilIface* mWriteIface; 00134 00136 std::string exodusFile; 00137 int ncFile; 00138 00140 EntityHandle mCurrentMeshHandle; 00141 00144 Tag mMaterialSetTag; 00145 Tag mDirichletSetTag; 00146 Tag mNeumannSetTag; 00147 Tag mHasMidNodesTag; 00148 Tag mGeomDimensionTag; 00149 Tag mDistFactorTag; 00150 Tag mGlobalIdTag; 00151 Tag mQaRecordTag; 00152 00153 Tag mEntityMark; //used to say whether an entity will be exported 00154 00155 ErrorCode gather_mesh_information(ExodusMeshInfo &mesh_info, 00156 std::vector<MaterialSetData> &block_info, 00157 std::vector<NeumannSetData> &sideset_info, 00158 std::vector<DirichletSetData> &nodeset_info, 00159 std::vector<EntityHandle> &blocks, 00160 std::vector<EntityHandle> &sidesets, 00161 std::vector<EntityHandle> &nodesets); 00162 00163 ErrorCode write_header(ExodusMeshInfo& mesh_info, 00164 std::vector<MaterialSetData> &block_info, 00165 std::vector<NeumannSetData> &sideset_info, 00166 std::vector<DirichletSetData> &nodeset_info, 00167 const char *filename); 00168 00169 ErrorCode initialize_exodus_file(ExodusMeshInfo &mesh_info, 00170 std::vector<MaterialSetData> &block_data, 00171 std::vector<NeumannSetData> & sideset_data, 00172 std::vector<DirichletSetData> & nodeset_data, 00173 const char* title_string, 00174 bool write_maps = true, 00175 bool write_sideset_distribution_factors = true); 00176 00177 ErrorCode write_qa_string(const char *string, 00178 int record_number, 00179 int record_position); 00180 00181 ErrorCode write_qa_records( std::vector<std::string> &qa_record_list); 00182 00183 ErrorCode write_nodes(int num_nodes, Range& nodes, int dimension ); 00184 00185 ErrorCode write_elementblocks(std::vector<MaterialSetData> &block_data ); 00186 00187 ErrorCode write_exodus_integer_variable(const char* variable_name, 00188 int *variable_array, 00189 int start_position, 00190 int number_values); 00191 00192 ErrorCode write_global_node_order_map(int num_nodes, Range& nodes); 00193 ErrorCode write_global_element_order_map(int num_elements); 00194 ErrorCode write_element_order_map(int num_elements); 00195 00196 ErrorCode write_BCs(std::vector<NeumannSetData> &sidesets, 00197 std::vector<DirichletSetData> &nodesets); 00198 00199 ErrorCode find_side_element_type( const int element_id, ExoIIElementType &type ); 00200 00201 /* ErrorCode assign_block_ids_to_ssets(EntityHandle ss_handle, 00202 MB_MeshSet *ss_mesh_set); 00203 */ 00205 void reset_block(std::vector<MaterialSetData> &block_info); 00206 00210 ErrorCode get_sideset_elems(EntityHandle sideset, int current_sense, 00211 Range &forward_elems, Range &reverse_elems); 00212 00213 00214 ErrorCode get_valid_sides(Range &elems, ExodusMeshInfo &mesh_info, 00215 const int sense, 00216 NeumannSetData &sideset_data); 00217 00219 static void time_and_date(char* time_string, char* date_string); 00220 }; 00221 00222 } // namespace moab 00223 00224 #endif