Loading [MathJax]/extensions/tex2jax.js
Mesh Oriented datABase  (version 5.5.1)
An array-based unstructured mesh library
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
WriteCGNS.hpp
Go to the documentation of this file.
1 /** 2  * MOAB, a Mesh-Oriented datABase, is a software component for creating, 3  * storing and accessing finite element mesh data. 4  * 5  * Copyright 2004 Sandia Corporation. Under the terms of Contract 6  * DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government 7  * retains certain rights in this software. 8  * 9  * This library is free software; you can redistribute it and/or 10  * modify it under the terms of the GNU Lesser General Public 11  * License as published by the Free Software Foundation; either 12  * version 2.1 of the License, or (at your option) any later version. 13  * 14  */ 15  16 #ifndef WRITE_CGNS_HPP 17 #define WRITE_CGNS_HPP 18  19 #include "moab/Forward.hpp" 20 #include "moab/WriterIface.hpp" 21 #include <cstdio> 22  23 // Junior 24 #include "cgnslib.h" 25 #include "moab/Range.hpp" 26  27 // Junior 28 #if CGNS_VERSION < 3100 29 #define cgsize_t int 30 #else 31 #if CG_BUILD_SCOPE 32 #error enumeration scoping needs to be off 33 #endif 34 #endif 35  36 namespace moab 37 { 38  39 class WriteUtilIface; 40  41 /** 42  * \brief Export CGNS files. 43  * \author Carlos Junqueira Junior 44  */ 45  46 class WriteCGNS : public WriterIface 47 { 48  49  public: 50  //! factory method 51  static WriterIface* factory( Interface* ); 52  53  //! Constructor 54  WriteCGNS( Interface* impl ); 55  56  //! Destructor 57  virtual ~WriteCGNS(); 58  59  // A structure to store Set information. 60  class SetStruct 61  { 62  public: 63  std::string TagName; // Tag name 64  cgsize_t IdSet; // Id of the Set 65  cgsize_t NbEdges; // Number of Edges in the Set 66  cgsize_t NbFaces; // Number of Faces in the Set 67  cgsize_t NbCells; // Number of Cells in the Set 68  // vector with the number of entities in the Sets 69  // 0-MBEDGE | 1-MBTRI | 2-MBQUAD | 3-MBTET | 4-MBPYRAMID | 5-MBPRISM | 6-MBHEX 70  std::vector< cgsize_t > NbEntities; 71  ElementType_t CGNSType; 72  73  SetStruct() : IdSet( -1 ), NbEdges( 0 ), NbFaces( 0 ), NbCells( 0 ){}; 74  ~SetStruct(){}; 75  }; 76  77  //! writes out a file 78  ErrorCode write_file( const char* file_name, 79  const bool overwrite, 80  const FileOptions& opts, 81  const EntityHandle* output_list, 82  const int num_sets, 83  const std::vector< std::string >& qa_list, 84  const Tag* tag_list = NULL, 85  int num_tags = 0, 86  int export_dimension = 3 ); 87  88  // Get and count vertex entities 89  ErrorCode get_vertex_entities( cgsize_t& VrtSize, std::vector< moab::EntityHandle >& Nodes ); 90  91  // Get and count edge entities 92  ErrorCode get_edge_entities( cgsize_t& EdgeSize, std::vector< moab::EntityHandle >& Edges ); 93  94  // Get and count face entities 95  ErrorCode get_face_entities( cgsize_t& FaceSize, std::vector< moab::EntityHandle >& Faces ); 96  97  // Get and count cell entities 98  ErrorCode get_cell_entities( cgsize_t& CellSize, std::vector< moab::EntityHandle >& Cells ); 99  100  // Write coordinates in the cgns file 101  ErrorCode write_coord_cgns( std::vector< moab::EntityHandle >& nodes ); 102  103  // Set Tag values on entities 104  ErrorCode set_tag_values( std::vector< moab::Tag >& TagHandles, 105  std::vector< moab::EntityHandle >& Edges, 106  std::vector< moab::EntityHandle >& Faces, 107  std::vector< moab::EntityHandle >& Cells, 108  std::vector< WriteCGNS::SetStruct >& Sets ); 109  110  // Get Entities in the set 111  ErrorCode get_set_entities( int i, 112  std::vector< moab::Tag >& TagHandles, 113  std::vector< WriteCGNS::SetStruct >& Sets ); 114  115  // Get the CGNSType 116  ErrorCode get_cgns_type( int i, std::vector< WriteCGNS::SetStruct >& Sets ); 117  118  // Get the connectivity table 119  ErrorCode get_conn_table( std::vector< moab::EntityHandle >& Elements, 120  std::vector< int >& Begin, 121  std::vector< int >& End, 122  std::vector< moab::Tag >& TagHandles, 123  std::vector< WriteCGNS::SetStruct >& Sets, 124  std::vector< std::vector< cgsize_t > >& ConnTable ); 125  126  // Read the Moab type and return CGNS type 127  int moab_cgns_conv( const EntityHandle handle ); 128  129  private: 130  // interface instance 131  Interface* mbImpl; 132  WriteUtilIface* mWriteIface; 133  134  // File var 135  const char* fileName; 136  int IndexFile; 137  138  // Base var 139  const char* BaseName; 140  int IndexBase; 141  142  // Zone var 143  const char* ZoneName; 144  int IndexZone; 145  146  // Section var 147  int IndexSection; 148  149  // Coordinates var 150  int IndexCoord[3]; 151  152  // Mesh dimension 153  int celldim; 154  int physdim; 155  cgsize_t isize[3]; 156  157  // Entities of mesh 158  std::vector< moab::EntityHandle > Nodes; 159  std::vector< moab::EntityHandle > Edges; 160  std::vector< moab::EntityHandle > Faces; 161  std::vector< moab::EntityHandle > Cells; 162  163  // Number of entities in the mesh 164  cgsize_t VrtSize; 165  cgsize_t EdgeSize; 166  cgsize_t FaceSize; 167  cgsize_t CellSize; 168 }; 169  170 } // namespace moab 171  172 #endif