moab
WriteCGNS.hpp
Go to the documentation of this file.
00001 
00017 #ifndef WRITE_CGNS_HPP
00018 #define WRITE_CGNS_HPP
00019 
00020 #include "moab/Forward.hpp"
00021 #include "moab/WriterIface.hpp"
00022 #include <stdio.h>
00023 
00024 //Junior
00025 #include "cgnslib.h"
00026 #include "moab/Range.hpp"
00027 
00028 //Junior
00029 #if CGNS_VERSION < 3100
00030 # define cgsize_t int
00031 #else
00032 # if CG_BUILD_SCOPE
00033 #  error enumeration scoping needs to be off
00034 # endif
00035 #endif
00036 
00037 
00038 
00039 namespace moab {
00040 
00041 class WriteUtilIface;
00042 
00048 class WriteCGNS : public WriterIface
00049 {
00050  
00051 public:
00052   
00054   static WriterIface* factory( Interface* );
00055 
00057   WriteCGNS(Interface *impl);
00058 
00060   virtual ~WriteCGNS();
00061 
00062   // A structure to store Set information.
00063   class SetStruct {
00064   public:
00065     std::string TagName;      // Tag name
00066     cgsize_t IdSet ;      // Id of the Set
00067     cgsize_t NbEdges;       // Number of Edges in the Set
00068     cgsize_t NbFaces;       // Number of Faces in the Set
00069     cgsize_t NbCells;       // Number of Cells in the Set    
00070     // vector with the number of entities in the Sets
00071     // 0-MBEDGE | 1-MBTRI | 2-MBQUAD | 3-MBTET | 4-MBPYRAMID | 5-MBPRISM  | 6-MBHEX
00072     std::vector<cgsize_t> NbEntities; 
00073     ElementType_t CGNSType;
00074 
00075     SetStruct(): IdSet(-1), NbEdges(0), NbFaces(0), NbCells(0) {};
00076     ~SetStruct() {};
00077   };
00078   
00080   ErrorCode write_file(const char *file_name,
00081                          const bool overwrite,
00082                          const FileOptions& opts,
00083                          const EntityHandle *output_list,
00084                          const int num_sets,
00085                          const std::vector<std::string>& qa_list,
00086                          const Tag* tag_list = NULL,
00087                          int num_tags = 0,
00088                          int export_dimension = 3);  
00089 
00090   // Get and count vertex entities
00091   ErrorCode get_vertex_entities ( cgsize_t &VrtSize,
00092                    std::vector< moab::EntityHandle > &Nodes );
00093 
00094   // Get and count edge entities
00095   ErrorCode get_edge_entities ( cgsize_t &EdgeSize,
00096                   std::vector< moab::EntityHandle > &Edges );
00097 
00098   // Get and count face entities
00099   ErrorCode get_face_entities ( cgsize_t &FaceSize,
00100                   std::vector< moab::EntityHandle > &Faces );
00101 
00102   // Get and count cell entities
00103   ErrorCode get_cell_entities ( cgsize_t &CellSize,
00104                   std::vector< moab::EntityHandle > &Cells );
00105 
00106   // Write coordinates in the cgns file
00107   ErrorCode write_coord_cgns ( std::vector< moab::EntityHandle > &nodes );
00108 
00109   // Set Tag values on entities
00110   ErrorCode set_tag_values ( std::vector<moab::Tag> &TagHandles,
00111                  std::vector< moab::EntityHandle > &Edges,
00112                  std::vector< moab::EntityHandle > &Faces,
00113                  std::vector< moab::EntityHandle > &Cells,
00114                  std::vector<WriteCGNS::SetStruct> &Sets );
00115 
00116   // Get Entities in the set
00117   ErrorCode get_set_entities ( int i, std::vector<moab::Tag> &TagHandles,
00118                    std::vector<WriteCGNS::SetStruct> &Sets );
00119 
00120   // Get the CGNSType
00121   ErrorCode get_cgns_type ( int i, std::vector<WriteCGNS::SetStruct> &Sets );
00122 
00123   // Get the connectivity table
00124   ErrorCode get_conn_table ( std::vector< moab::EntityHandle > &Elements,
00125                  std::vector < int > &Begin,
00126                  std::vector < int > &End,
00127                  std::vector< moab::Tag > &TagHandles,
00128                  std::vector< WriteCGNS::SetStruct > &Sets,
00129                  std::vector < std::vector<cgsize_t> > &ConnTable );
00130 
00131   // Read the Moab type and return CGNS type
00132   int moab_cgns_conv ( const EntityHandle handle );
00133 
00134 private:
00135                                        
00136     // interface instance
00137   Interface *mbImpl;
00138   WriteUtilIface* mWriteIface;
00139   
00140   // File var
00141   const char *fileName;
00142   int IndexFile;
00143 
00144   // Base var
00145   const char *BaseName;
00146   int IndexBase;
00147   
00148   // Zone var
00149   const char *ZoneName;
00150   int IndexZone;
00151 
00152   // Section var
00153   int IndexSection;
00154   
00155   // Coordinates var
00156   int IndexCoord[3];
00157  
00158   // Mesh dimension  
00159   int celldim;
00160   int physdim;
00161   cgsize_t isize[3];
00162   
00163   // Entities of mesh
00164   std::vector< moab::EntityHandle > Nodes;
00165   std::vector< moab::EntityHandle > Edges;
00166   std::vector< moab::EntityHandle > Faces;
00167   std::vector< moab::EntityHandle > Cells;
00168 
00169   // Number of entities in the mesh  
00170   cgsize_t VrtSize ;
00171   cgsize_t EdgeSize;
00172   cgsize_t FaceSize;
00173   cgsize_t CellSize;
00174   
00175 };
00176 
00177 } // namespace moab
00178 
00179 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines