moab
WriteTemplate.hpp
Go to the documentation of this file.
00001 
00016 //-------------------------------------------------------------------------
00017 // Filename      : WriteTemplate.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 WRITETemplate_HPP
00031 #define WRITETemplate_HPP
00032 
00033 #ifndef IS_BUILDING_MB
00034 #error "WriteTemplate.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 WriteTemplate : public WriterIface
00050 {
00051  
00052 public:
00053 
00055    WriteTemplate(Interface *impl);
00056 
00058   virtual ~WriteTemplate();
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_dirsets;
00126     unsigned int num_neusets;
00127     Range nodes;
00128 
00129     MeshInfo() 
00130         : num_dim(0), num_nodes(0), num_elements(0), num_matsets(0), 
00131           num_dirsets(0), num_neusets(0)
00132       {}
00133     
00134   };
00135   
00136 private:
00137 
00139   Interface *mbImpl;
00140   WriteUtilIface* mWriteIface;
00141   
00143   std::string fileName;
00144 
00146   EntityHandle mCurrentMeshHandle;
00147 
00150   Tag mMaterialSetTag;
00151   Tag mDirichletSetTag;
00152   Tag mNeumannSetTag;
00153   Tag mGlobalIdTag;
00154 
00155   Tag mEntityMark;   //used to say whether an entity will be exported
00156 
00157   ErrorCode gather_mesh_information(MeshInfo &mesh_info,
00158                                       std::vector<MaterialSetData> &matset_info,
00159                                       std::vector<NeumannSetData> &neuset_info,
00160                                       std::vector<DirichletSetData> &dirset_info,
00161                                       std::vector<EntityHandle> &matsets,
00162                                       std::vector<EntityHandle> &neusets,
00163                                       std::vector<EntityHandle> &dirsets);
00164   
00165   ErrorCode initialize_file(MeshInfo &mesh_info);
00166 
00167   ErrorCode write_nodes(const int num_nodes, const Range& nodes, 
00168                           const int dimension );
00169 
00170   ErrorCode write_matsets(MeshInfo &mesh_info, 
00171                             std::vector<MaterialSetData> &matset_data,
00172                             std::vector<NeumannSetData> &neuset_data);
00173   
00174   ErrorCode get_valid_sides(Range &elems, const int sense,
00175                               WriteTemplate::NeumannSetData &neuset_data);
00176   
00177   void reset_matset(std::vector<MaterialSetData> &matset_info);
00178   
00179   ErrorCode get_neuset_elems(EntityHandle neuset, int current_sense,
00180                                Range &forward_elems, Range &reverse_elems);
00181   
00182 };
00183 
00184 } // namespace moab
00185 
00186 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines