Mesh Oriented datABase
(version 5.4.1)
Array-based unstructured mesh datastructure
|
00001 /** \file ReadHDF5VarLen.hpp 00002 * \author Jason Kraftcheck 00003 * \date 2010-09-04 00004 */ 00005 00006 #ifndef moab_READ_HDF5_VAR_LEN_HPP 00007 #define moab_READ_HDF5_VAR_LEN_HPP 00008 00009 #include "moab/MOABConfig.h" 00010 #ifdef MOAB_HAVE_MPI 00011 #include "moab_mpi.h" 00012 #endif 00013 #include "DebugOutput.hpp" 00014 #include "moab/Range.hpp" 00015 #include "H5Ipublic.h" 00016 00017 namespace moab 00018 { 00019 00020 class ReadHDF5Dataset; 00021 00022 /**\brief Read variable-length data from 1-D array dataset 00023 * 00024 * Utility class for reading variable-length data from an HDF5 dataset. 00025 * Used for reading set contents, set parents, set children, 00026 * polygon and polyhedron connectivity, and variable-length tag 00027 * data. 00028 * 00029 * This is an abstract class. The pure virtual \c store_data method 00030 * must be implemented to create a concrete instance. 00031 */ 00032 class ReadHDF5VarLen 00033 { 00034 protected: 00035 DebugOutput& dbgOut; 00036 00037 private: 00038 void* const dataBuffer; 00039 const size_t bufferSize; 00040 00041 /**\brief Test if passed file_id is value pointed to by ranged_iter, 00042 * and if so, incremenet ranged_iter 00043 */ 00044 static bool is_ranged( EntityHandle file_id, Range::const_iterator& ranged_iter, Range::const_iterator ranged_end ); 00045 00046 protected: 00047 /**\brief Store data list for a single entity 00048 * 00049 * The is the pure virtual method that must be provided. 00050 * It is responsible for storing the data read for a single 00051 * entity. 00052 * 00053 * This function will always be called in the order of the 00054 * file_ids in the range passed to the \c read method. 00055 * 00056 *\param file_id The file ID for the entity 00057 *\param data A pointer to the data for the entity 00058 *\param num_data Number of values for the entity 00059 *\param ranged For set contents, true if in ranged format. 00060 */ 00061 virtual ErrorCode store_data( EntityHandle file_id, void* data, long num_data, bool ranged ) = 0; 00062 00063 public: 00064 /**\brief Constructor 00065 *\param buffer A temporary buffer to use during read 00066 *\param buffer_size Size of \c buffer, in bytes. 00067 */ 00068 ReadHDF5VarLen( DebugOutput& debug_output, void* buffer, size_t buffer_size ) 00069 : dbgOut( debug_output ), dataBuffer( buffer ), bufferSize( buffer_size ) 00070 { 00071 } 00072 00073 virtual ~ReadHDF5VarLen() {} 00074 00075 /**\brief Do actual read of data set 00076 *\param data_set The data set to read. 00077 *\param file_ids The file ids of the entities to read. 00078 *\param start_file_id The file id corresponding to the first row of the dataset 00079 *\param data_type The desired, in-memory data type for values 00080 *\param vals_per_ent The number of values for each entity 00081 *\param ranged_file_ids Those file ids for which the 'ranged' 00082 * argument to \c storedata should be passed 00083 * as \c true. 00084 */ 00085 ErrorCode read_data( ReadHDF5Dataset& data_set, 00086 const Range& offsets, 00087 EntityHandle start_offset, 00088 hid_t data_type, 00089 const Range& file_ids, 00090 const std::vector< unsigned >& vals_per_ent, 00091 const Range& ranged_file_ids ); 00092 00093 /**\brief Read set description table or offset vector for 00094 * var-len tags or old-format poly(gon|hedra) connectivity. 00095 *\param data_set The data set to read. 00096 *\param file_ids The file ids of the entities to read. 00097 *\param start_file_id The file id corresponding to the first row of the dataset 00098 *\param num_columns The number of columns of offsets in the dataset 00099 *\param indices Array of length \c num_columns contaning the 00100 * indices of the columns to read. 00101 *\param nudge Amount by which to offset values in 00102 * \c offset_out to avoid putting zeros in 00103 * Range. Must be greater than 0. Probably 1. 00104 *\param offsets_out An array of length \c num_columns which will 00105 * be populated with the resulting list of offsets 00106 * into the contents list calculated from reading 00107 * the offsets from the passed data set. 00108 *\param counts_out An array of length \c num_columns of std::vectors, 00109 * where each vector will be filled with one value 00110 * per file ID indicating the length of the data for 00111 * the corresponding file ID. 00112 *\param ranged_file_ids If non-null, the last column of the table will 00113 * be read and tested for the ranged bit. For 00114 * all file_ids for which the range bit is set, 00115 * the file ID will be added to this list. 00116 */ 00117 /* 00118 ErrorCode read_offsets( ReadHDF5Dataset& data_set, 00119 const Range& file_ids, 00120 EntityHandle start_file_id, 00121 unsigned num_columns, 00122 const unsigned indices[], 00123 EntityHandle nudge, 00124 Range offsets_out[], 00125 std::vector<unsigned> counts_out[], 00126 Range* ranged_file_ids = 0 ); 00127 */ 00128 ErrorCode read_offsets( ReadHDF5Dataset& data_set, 00129 const Range& file_ids, 00130 EntityHandle start_file_id, 00131 EntityHandle nudge, 00132 Range& offsets_out, 00133 std::vector< unsigned >& counts_out ); 00134 00135 ErrorCode read( ReadHDF5Dataset& offset_data, 00136 ReadHDF5Dataset& value_data, 00137 const Range& file_ids, 00138 EntityHandle start_file_id, 00139 hid_t data_type, 00140 const Range* ranged = 0 ) 00141 { 00142 ErrorCode rval; 00143 const EntityHandle nudge = 1; 00144 Range offsets; 00145 std::vector< unsigned > counts; 00146 rval = read_offsets( offset_data, file_ids, start_file_id, nudge, offsets, counts ); 00147 if( MB_SUCCESS != rval ) return rval; 00148 Range empty; 00149 rval = read_data( value_data, offsets, nudge, data_type, file_ids, counts, ranged ? *ranged : empty ); 00150 return rval; 00151 } 00152 }; 00153 00154 } // namespace moab 00155 00156 #endif // moab_READ_HDF5_VAR_LEN_HPP