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
ReadDamsel.hpp
Go to the documentation of this file.
1 //------------------------------------------------------------------------- 2 // Filename : ReadDamsel.hpp 3 // 4 // Purpose : Damsel file reader 5 // 6 // Creator : Tim Tautges 7 //------------------------------------------------------------------------- 8  9 #ifndef READDAMSEL_HPP 10 #define READDAMSEL_HPP 11  12 #ifndef IS_BUILDING_MB 13 //#error "ReadDamsel.hpp isn't supposed to be included into an application" 14 #endif 15  16 #include <vector> 17 #include <map> 18 #include <string> 19  20 #include "moab/Forward.hpp" 21 #include "moab/ReaderIface.hpp" 22 #include "moab/Range.hpp" 23 #include "moab/RangeMap.hpp" 24 #include "DebugOutput.hpp" 25 #include "DamselUtil.hpp" 26  27 #include "damsel.h" 28  29 namespace moab 30 { 31  32 class ReadUtilIface; 33 class ParallelComm; 34 class Error; 35  36 class ReadDamsel : public ReaderIface 37 { 38  public: 39  static ReaderIface* factory( Interface* ); 40  41  //! Load an NC file 42  ErrorCode load_file( const char* file_name, 43  const EntityHandle* file_set, 44  const FileOptions& opts, 45  const SubsetList* subset_list = 0, 46  const Tag* file_id_tag = 0 ); 47  48  //! Constructor 49  ReadDamsel( Interface* impl = NULL ); 50  51  //! Destructor 52  virtual ~ReadDamsel(); 53  54  virtual ErrorCode read_tag_values( const char* file_name, 55  const char* tag_name, 56  const FileOptions& opts, 57  std::vector< int >& tag_values_out, 58  const SubsetList* subset_list = 0 ); 59  60  private: 61  //! Get contents of the container (containing file-side handles) and translate to moab-side 62  //! handles 63  ErrorCode get_contents( damsel_model m, damsel_container c, Range& ents ); 64  65  //! Get contents of the container (containing file-side handles) and translate to moab-side 66  //! handles ents argument should point to already-allocated space 67  ErrorCode get_contents( damsel_model m, damsel_container c, EntityHandle* ents ); 68  69  ErrorCode init(); 70  71  ErrorCode parse_options( const FileOptions& opts, bool& parallel ); 72  73  ErrorCode process_tags( std::vector< damsel_tag_buf_type >& tag_infos ); 74  75  ErrorCode process_ent_info( const damsel_entity_buf_type& einfo ); 76  77  ErrorCode process_entity_tags( int count, 78  damsel_container tag_container, 79  damsel_container app_cont, 80  Range& these_ents ); 81  82  ErrorCode process_coll_infos( std::vector< damsel_collection_buf_type >& coll_infos ); 83  84  //! Convert handles in a container into handle pairs, one pair per contiguous sequence of 85  //! handles in the container 86  ErrorCode container_to_handle_pairs( damsel_container& cont, std::vector< damsel_handle >& handle_pairs ); 87  88  //! Store MOAB handles starting from start_handle, corresponding to store handles in 89  //! handle_pairs, into the entity map 90  ErrorCode insert_into_map( std::vector< damsel_handle >& handle_pairs, EntityHandle start_handle ); 91  92  class subrange 93  { 94  public: 95  subrange( damsel_handle ch, EntityHandle s, int c ) : collh( ch ), seth( s ), count( c ) {} 96  damsel_handle collh; 97  EntityHandle seth; 98  int count; 99  }; 100  101  //------------member variables ------------// 102  103  //! Interface instance 104  Interface* mbImpl; 105  106  //! UtilIface 107  ReadUtilIface* readMeshIface; 108  109  //! File name 110  std::string fileName; 111  112  //! Whether this reader natively supports parallel semantics 113  bool nativeParallel; 114  115  //! Parallel info 116  ParallelComm* myPcomm; 117  118  //! Used to track file handles 119  Tag mGlobalIdTag; 120  121  //! map from damsel to moab handles 122  RangeMap< damsel_handle, EntityHandle, 0 > dmHandleRMap; 123  124  //! Keep various damsel data 125  DamselUtil dU; 126 }; 127  128 inline const bool operator==( const damsel_err_t& lhs, const damsel_err_t& rhs ) 129 { 130  return lhs.id == rhs.id; 131 } 132  133 } // namespace moab 134  135 #endif