Mesh Oriented datABase  (version 5.4.1)
Array-based unstructured mesh datastructure
ReadDamsel.hpp
Go to the documentation of this file.
00001 //-------------------------------------------------------------------------
00002 // Filename      : ReadDamsel.hpp
00003 //
00004 // Purpose       : Damsel file reader
00005 //
00006 // Creator       : Tim Tautges
00007 //-------------------------------------------------------------------------
00008 
00009 #ifndef READDAMSEL_HPP
00010 #define READDAMSEL_HPP
00011 
00012 #ifndef IS_BUILDING_MB
00013 //#error "ReadDamsel.hpp isn't supposed to be included into an application"
00014 #endif
00015 
00016 #include <vector>
00017 #include <map>
00018 #include <string>
00019 
00020 #include "moab/Forward.hpp"
00021 #include "moab/ReaderIface.hpp"
00022 #include "moab/Range.hpp"
00023 #include "moab/RangeMap.hpp"
00024 #include "DebugOutput.hpp"
00025 #include "DamselUtil.hpp"
00026 
00027 #include "damsel.h"
00028 
00029 namespace moab
00030 {
00031 
00032 class ReadUtilIface;
00033 class ParallelComm;
00034 class Error;
00035 
00036 class ReadDamsel : public ReaderIface
00037 {
00038   public:
00039     static ReaderIface* factory( Interface* );
00040 
00041     //! Load an NC file
00042     ErrorCode load_file( const char* file_name,
00043                          const EntityHandle* file_set,
00044                          const FileOptions& opts,
00045                          const SubsetList* subset_list = 0,
00046                          const Tag* file_id_tag        = 0 );
00047 
00048     //! Constructor
00049     ReadDamsel( Interface* impl = NULL );
00050 
00051     //! Destructor
00052     virtual ~ReadDamsel();
00053 
00054     virtual ErrorCode read_tag_values( const char* file_name,
00055                                        const char* tag_name,
00056                                        const FileOptions& opts,
00057                                        std::vector< int >& tag_values_out,
00058                                        const SubsetList* subset_list = 0 );
00059 
00060   private:
00061     //! Get contents of the container (containing file-side handles) and translate to moab-side
00062     //! handles
00063     ErrorCode get_contents( damsel_model m, damsel_container c, Range& ents );
00064 
00065     //! Get contents of the container (containing file-side handles) and translate to moab-side
00066     //! handles ents argument should point to already-allocated space
00067     ErrorCode get_contents( damsel_model m, damsel_container c, EntityHandle* ents );
00068 
00069     ErrorCode init();
00070 
00071     ErrorCode parse_options( const FileOptions& opts, bool& parallel );
00072 
00073     ErrorCode process_tags( std::vector< damsel_tag_buf_type >& tag_infos );
00074 
00075     ErrorCode process_ent_info( const damsel_entity_buf_type& einfo );
00076 
00077     ErrorCode process_entity_tags( int count,
00078                                    damsel_container tag_container,
00079                                    damsel_container app_cont,
00080                                    Range& these_ents );
00081 
00082     ErrorCode process_coll_infos( std::vector< damsel_collection_buf_type >& coll_infos );
00083 
00084     //! Convert handles in a container into handle pairs, one pair per contiguous sequence of
00085     //! handles in the container
00086     ErrorCode container_to_handle_pairs( damsel_container& cont, std::vector< damsel_handle >& handle_pairs );
00087 
00088     //! Store MOAB handles starting from start_handle, corresponding to store handles in
00089     //! handle_pairs, into the entity map
00090     ErrorCode insert_into_map( std::vector< damsel_handle >& handle_pairs, EntityHandle start_handle );
00091 
00092     class subrange
00093     {
00094       public:
00095         subrange( damsel_handle ch, EntityHandle s, int c ) : collh( ch ), seth( s ), count( c ) {}
00096         damsel_handle collh;
00097         EntityHandle seth;
00098         int count;
00099     };
00100 
00101     //------------member variables ------------//
00102 
00103     //! Interface instance
00104     Interface* mbImpl;
00105 
00106     //! UtilIface
00107     ReadUtilIface* readMeshIface;
00108 
00109     //! File name
00110     std::string fileName;
00111 
00112     //! Whether this reader natively supports parallel semantics
00113     bool nativeParallel;
00114 
00115     //! Parallel info
00116     ParallelComm* myPcomm;
00117 
00118     //! Used to track file handles
00119     Tag mGlobalIdTag;
00120 
00121     //! map from damsel to moab handles
00122     RangeMap< damsel_handle, EntityHandle, 0 > dmHandleRMap;
00123 
00124     //! Keep various damsel data
00125     DamselUtil dU;
00126 };
00127 
00128 inline const bool operator==( const damsel_err_t& lhs, const damsel_err_t& rhs )
00129 {
00130     return lhs.id == rhs.id;
00131 }
00132 
00133 }  // namespace moab
00134 
00135 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines