moab
|
00001 00016 //------------------------------------------------------------------------- 00017 // Filename : WriteSLAC.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 WRITESLAC_HPP 00031 #define WRITESLAC_HPP 00032 00033 #ifndef IS_BUILDING_MB 00034 #error "WriteSLAC.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 00049 class WriteSLAC : public WriterIface 00050 { 00051 00052 public: 00053 00055 WriteSLAC(Interface *impl); 00056 00058 virtual ~WriteSLAC(); 00059 00060 static WriterIface* factory( Interface* ); 00061 00063 ErrorCode write_file(const char *file_name, 00064 const bool overwrite, 00065 const FileOptions& opts, 00066 const EntityHandle *output_list, 00067 const int num_sets, 00068 const std::vector<std::string>& qa_list, 00069 const Tag* tag_list = NULL, 00070 int num_tags = 0, 00071 int export_dimension = 3); 00072 00075 struct MaterialSetData 00076 { 00077 int id; 00078 int number_elements; 00079 int number_nodes_per_element; 00080 int number_attributes; 00081 ExoIIElementType element_type; 00082 EntityType moab_type; 00083 Range *elements; 00084 }; 00085 00088 struct DirichletSetData 00089 { 00090 int id; 00091 int number_nodes; 00092 std::vector< EntityHandle > nodes; 00093 std::vector< double > node_dist_factors; 00094 00095 }; 00096 00099 struct NeumannSetData 00100 { 00101 int id; 00102 int number_elements; 00103 std::vector<EntityHandle> elements; 00104 std::vector<int> side_numbers; 00105 EntityHandle mesh_set_handle; 00106 }; 00107 00108 00109 protected: 00110 00112 //int number_dimensions(); 00113 00115 ErrorCode open_file(const char *filename); 00116 00118 class MeshInfo 00119 { 00120 public: 00121 unsigned int num_dim; 00122 unsigned int num_nodes; 00123 unsigned int num_elements; 00124 unsigned int num_matsets; 00125 unsigned int num_int_hexes; 00126 unsigned int num_int_tets; 00127 Range bdy_hexes, bdy_tets; 00128 Range nodes; 00129 00130 MeshInfo() 00131 : num_dim(0), num_nodes(0), num_elements(0), num_matsets(0), 00132 num_int_hexes(0), num_int_tets(0) 00133 {} 00134 00135 }; 00136 00137 private: 00138 00140 Interface *mbImpl; 00141 WriteUtilIface* mWriteIface; 00142 00144 std::string fileName; 00145 int ncFile; 00146 00148 EntityHandle mCurrentMeshHandle; 00149 00152 Tag mMaterialSetTag; 00153 Tag mDirichletSetTag; 00154 Tag mNeumannSetTag; 00155 Tag mGlobalIdTag; 00156 Tag mMatSetIdTag; 00157 00158 Tag mEntityMark; //used to say whether an entity will be exported 00159 00160 ErrorCode gather_mesh_information(MeshInfo &mesh_info, 00161 std::vector<MaterialSetData> &matset_info, 00162 std::vector<NeumannSetData> &neuset_info, 00163 std::vector<DirichletSetData> &dirset_info, 00164 std::vector<EntityHandle> &matsets, 00165 std::vector<EntityHandle> &neusets, 00166 std::vector<EntityHandle> &dirsets); 00167 00168 ErrorCode initialize_file(MeshInfo &mesh_info); 00169 00170 ErrorCode write_nodes(const int num_nodes, const Range& nodes, 00171 const int dimension ); 00172 00173 ErrorCode write_matsets(MeshInfo &mesh_info, 00174 std::vector<MaterialSetData> &matset_data, 00175 std::vector<NeumannSetData> &neuset_data); 00176 00177 ErrorCode get_valid_sides(Range &elems, const int sense, 00178 WriteSLAC::NeumannSetData &sideset_data); 00179 00180 void reset_matset(std::vector<MaterialSetData> &matset_info); 00181 00182 ErrorCode get_neuset_elems(EntityHandle neuset, int current_sense, 00183 Range &forward_elems, Range &reverse_elems); 00184 00185 ErrorCode gather_interior_exterior(MeshInfo &mesh_info, 00186 std::vector<MaterialSetData> &matset_data, 00187 std::vector<NeumannSetData> &neuset_data); 00188 00189 }; 00190 00191 } // namespace moab 00192 00193 #endif