Mesh Oriented datABase
(version 5.4.1)
Array-based unstructured mesh datastructure
|
typedef struct mhdf_ElemDesc MHDF_ElemDesc |
typedef struct mhdf_EntDesc MHDF_EntDesc |
Data common to sets, nodes, and each element type
typedef struct mhdf_FileDesc MHDF_FileDesc |
typedef void* mhdf_FileHandle |
Opaque handle to an open file.
Definition at line 87 of file mhdf_public.h.
typedef mhdf_FileHandle MHDF_FileHandle |
Definition at line 89 of file mhdf_public.h.
typedef struct mhdf_TagDesc MHDF_TagDesc |
Struct describing a tag
void mhdf_closeFile | ( | mhdf_FileHandle | handle, |
mhdf_Status * | status | ||
) |
Close the file.
handle | The file to close. |
status | Passed back status of API call. |
Definition at line 438 of file file.c.
References API_BEGIN, API_END_H, struct_FileHandle::hdf_handle, mhdf_check_valid_file(), mhdf_checkOpenHandles(), mhdf_setFail(), and mhdf_setOkay().
Referenced by moab::ReadHDF5::clean_up_read(), iMOAB_ReadHeaderInfo(), main(), moab::WriteHDF5Parallel::parallel_create_file(), moab::ReadHDF5::set_up_read(), and moab::WriteHDF5::write_file().
{ FileHandle* file_ptr; API_BEGIN; file_ptr = (FileHandle*)( handle ); if( !mhdf_check_valid_file( file_ptr, status ) ) return; /* if (file_ptr->open_handle_count) { mhdf_setError( status, "Cannot close file with %d open data handles.", file_ptr->open_handle_count ); return; } */ /* Check for open handles. HDF5 will not actually close the file until all handles are closed. */ if( mhdf_checkOpenHandles( handle, status ) ) return; if( 0 > H5Fclose( file_ptr->hdf_handle ) ) { mhdf_setFail( status, "H5FClose failed. Invalid handle?" ); return; } memset( file_ptr, 0, sizeof( FileHandle ) ); free( file_ptr ); mhdf_setOkay( status ); API_END_H( -1 ); }
int mhdf_countOpenHandles | ( | mhdf_FileHandle | h | ) |
Get number of open HDF5 objects from file.
Definition at line 150 of file file.c.
Referenced by moab::CheckOpenReadHDF5Handles::~CheckOpenReadHDF5Handles(), and moab::CheckOpenWriteHDF5Handles::~CheckOpenWriteHDF5Handles().
{ return H5Fget_obj_count( ( (FileHandle*)file_handle )->hdf_handle, H5F_OBJ_ALL ); }
mhdf_FileHandle mhdf_createFile | ( | const char * | filename, |
int | overwrite, | ||
const char ** | elem_type_list, | ||
size_t | elem_type_list_len, | ||
hid_t | id_type, | ||
mhdf_Status * | status | ||
) |
Create a new file.
Create a new HDF mesh file. This handle must be closed with mhdf_closeFile
to avoid resource loss.
filename | The path and name of the file to create |
overwrite | If zero, will fail if the specified file already exists. If non-zero, will overwrite an existing file. |
elem_type_list | The list of element types that will be stored in the file. If the element name exits as a pre- defined constant (Common element type names.), that constant should be used. If a constant does not exist for the type, a similar naming pattern should be used (accepted name for type, first character uppercase, subsequent characters lowercase.) The element type index passed to mhdf_addElement is then an index into this list. The array may contain null entries to allow the caller some control over the assigned indices without creating dummy types which may confuse readers. |
elem_type_list_len | The length of elem_type_list . |
id_type | Type to use when creating datasets containing file IDs |
status | Passed back status of API call. |
Definition at line 37 of file file.c.
References API_BEGIN, API_END_H, ELEMENT_GROUP, struct_FileHandle::hdf_handle, make_hdf_group(), struct_FileHandle::max_id, MAX_ID_ATTRIB, mhdf_alloc_FileHandle(), mhdf_create_scalar_attrib(), mhdf_setFail(), mhdf_setOkay(), NODE_GROUP, NODE_TAG_GROUP, ROOT_GROUP, SET_GROUP, SET_TAG_GROUP, TAG_GROUP, and TYPE_ENUM_PATH.
Referenced by moab::WriteHDF5Parallel::parallel_create_file(), and moab::WriteHDF5::serial_create_file().
{ FileHandle* file_ptr; unsigned int flags; unsigned char idx; size_t i; hid_t enum_id, group_id; int rval; API_BEGIN; if( elem_list_len > 255 ) { mhdf_setFail( status, "Element type list too long." ); return NULL; } mhdf_setOkay( status ); /* Create struct to hold working data */ file_ptr = mhdf_alloc_FileHandle( 0, id_type, status ); if( !file_ptr ) return NULL; /* Create the file */ flags = overwrite ? H5F_ACC_TRUNC : H5F_ACC_EXCL; file_ptr->hdf_handle = H5Fcreate( filename, flags, H5P_DEFAULT, H5P_DEFAULT ); if( file_ptr->hdf_handle < 0 ) { mhdf_setFail( status, "Failed to create file \"%s\"", filename ); free( file_ptr ); return NULL; } /* Create file structure */ if( !make_hdf_group( ROOT_GROUP, file_ptr->hdf_handle, 6, status ) || !make_hdf_group( TAG_GROUP, file_ptr->hdf_handle, 0, status ) || !make_hdf_group( ELEMENT_GROUP, file_ptr->hdf_handle, 8, status ) || !make_hdf_group( NODE_GROUP, file_ptr->hdf_handle, 3, status ) || !make_hdf_group( SET_GROUP, file_ptr->hdf_handle, 5, status ) || !make_hdf_group( NODE_TAG_GROUP, file_ptr->hdf_handle, 0, status ) || !make_hdf_group( SET_TAG_GROUP, file_ptr->hdf_handle, 0, status ) ) { H5Fclose( file_ptr->hdf_handle ); free( file_ptr ); return NULL; } /* Store the max ID as an attribite on the /tstt/ group */ #if defined( H5Gopen_vers ) && H5Gopen_vers > 1 group_id = H5Gopen2( file_ptr->hdf_handle, ROOT_GROUP, H5P_DEFAULT ); #else group_id = H5Gopen( file_ptr->hdf_handle, ROOT_GROUP ); #endif rval = mhdf_create_scalar_attrib( group_id, MAX_ID_ATTRIB, H5T_NATIVE_ULONG, &file_ptr->max_id, status ); H5Gclose( group_id ); if( !rval ) { H5Fclose( file_ptr->hdf_handle ); free( file_ptr ); return NULL; } /* Create the type name list in file */ enum_id = H5Tenum_create( H5T_NATIVE_UCHAR ); if( enum_id < 0 ) { mhdf_setFail( status, "Failed to store elem type list." ); H5Fclose( file_ptr->hdf_handle ); free( file_ptr ); return NULL; } for( i = 0; i < elem_list_len; ++i ) { if( !elem_type_list[i] || !*elem_type_list[i] ) continue; idx = (unsigned char)i; if( H5Tenum_insert( enum_id, elem_type_list[i], &idx ) < 0 ) { mhdf_setFail( status, "Failed to store elem type list." ); H5Fclose( file_ptr->hdf_handle ); free( file_ptr ); return NULL; } } #if defined( H5Tcommit_vers ) && H5Tcommit_vers > 1 if( H5Tcommit2( file_ptr->hdf_handle, TYPE_ENUM_PATH, enum_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT ) < 0 ) #else if( H5Tcommit( file_ptr->hdf_handle, TYPE_ENUM_PATH, enum_id ) < 0 ) #endif { mhdf_setFail( status, "Failed to store elem type list." ); H5Fclose( file_ptr->hdf_handle ); free( file_ptr ); return NULL; } H5Tclose( enum_id ); API_END_H( 1 ); return file_ptr; }
void mhdf_fixFileDesc | ( | struct mhdf_FileDesc * | copy_ptr, |
const struct mhdf_FileDesc * | orig_addr | ||
) |
Fix nested pointers for copied/moved FileDesc struct.
This is a utility method to facility copying/moving/communicating struct FileDesc instances. The structure and all data it references are allocated in a single contiguous block of memory of size FileDesc::total_size. As such, the struct can be copied with a single memcpy, packed into a single network packet, communicated with a single MPI call, etc. However, the pointers contained within the struct will not be valid in the copied instance (they will still point into the original instance.) Given a pointer to the copied struct and the address of the original struct, this function will updated all contained pointers.
Definition at line 77 of file file-desc.c.
References API_BEGIN, API_END, mhdf_FileDesc::defTagsEntSets, mhdf_FileDesc::defTagsVals, mhdf_EntDesc::dense_tag_indices, mhdf_FileDesc::elems, FIX_OFFSET, mhdf_FileDesc::nodes, mhdf_FileDesc::num_elem_desc, mhdf_FileDesc::num_tag_desc, mhdf_FileDesc::numEntSets, mhdf_FileDesc::sets, and mhdf_FileDesc::tags.
Referenced by realloc_data(), and moab::ReadHDF5::set_up_read().
{ int i; API_BEGIN; FIX_OFFSET( int*, nodes.dense_tag_indices ); FIX_OFFSET( int*, sets.dense_tag_indices ); FIX_OFFSET( struct mhdf_ElemDesc*, elems ); FIX_OFFSET( struct mhdf_TagDesc*, tags ); FIX_OFFSET( int*, numEntSets ); FIX_OFFSET( int**, defTagsEntSets ); FIX_OFFSET( int**, defTagsVals ); for( i = 0; i < 5; i++ ) { if( copy_ptr->defTagsEntSets ) FIX_OFFSET( int*, defTagsEntSets[i] ); if( copy_ptr->defTagsVals ) FIX_OFFSET( int*, defTagsVals[i] ); } if( copy_ptr->elems != NULL ) { for( i = 0; i < copy_ptr->num_elem_desc; ++i ) { FIX_OFFSET( const char*, elems[i].handle ); FIX_OFFSET( const char*, elems[i].type ); FIX_OFFSET( int*, elems[i].desc.dense_tag_indices ); } } if( copy_ptr->tags != NULL ) { for( i = 0; i < copy_ptr->num_tag_desc; ++i ) { FIX_OFFSET( const char*, tags[i].name ); FIX_OFFSET( void*, tags[i].default_value ); FIX_OFFSET( void*, tags[i].global_value ); FIX_OFFSET( int*, tags[i].dense_elem_indices ); } } API_END; }
MHDF_FileDesc* mhdf_getFileSummary | ( | mhdf_FileHandle | file_handle, |
hid_t | file_id_type, | ||
mhdf_Status * | status, | ||
int | extraSetInfo | ||
) | [read] |
Get summary of data tables contained within file.
Returned struct, including all pointed-to data, is allocated in a single contiguous block of memory with a size equal to 'total_size'. Caller is responsible for freeing the returned struct FileDesc pointer (and *only* that pointer, not pointers nexted within the struct!). Caller may copy (e.g. MPI_BCast) entire struct as one contiguous block, assuming all nested pointers in the copy are updated to the correct relative offset from the beginning of the struct.
Definition at line 385 of file file-desc.c.
References alloc_file_desc(), API_BEGIN, API_END, mhdf_EntDesc::count, mhdf_FileDesc::defTagsEntSets, mhdf_FileDesc::defTagsVals, mhdf_TagDesc::dense_elem_indices, mhdf_EntDesc::dense_tag_indices, mhdf_ElemDesc::desc, mhdf_FileDesc::elems, free_string_list(), get_elem_desc(), get_tag_desc(), mhdf_FileDesc::have_set_children, mhdf_FileDesc::have_set_contents, mhdf_FileDesc::have_set_parents, mhdf_TagDesc::have_sparse, mhdf_closeData(), mhdf_getElemHandles(), mhdf_getTagNames(), mhdf_haveDenseTag(), mhdf_haveNodes(), mhdf_haveSets(), mhdf_isError(), mhdf_malloc(), mhdf_node_type_handle(), mhdf_openDenseTagData(), mhdf_openNodeCoords(), mhdf_openSetMeta(), mhdf_openSparseTagData(), mhdf_read_data(), mhdf_readTagValues(), mhdf_set_type_handle(), mhdf_setOkay(), mhdf_TagDesc::name, mhdf_FileDesc::nodes, mhdf_TagDesc::num_dense_indices, mhdf_EntDesc::num_dense_tags, mhdf_FileDesc::num_elem_desc, mhdf_FileDesc::num_tag_desc, mhdf_FileDesc::numEntSets, mhdf_FileDesc::offset, realloc_data(), mhdf_FileDesc::sets, size, mhdf_EntDesc::start_id, mhdf_FileDesc::tags, mhdf_FileDesc::total_size, and mhdf_EntDesc::vals_per_ent.
Referenced by iMOAB_ReadHeaderInfo(), main(), and moab::ReadHDF5::set_up_read().
{ struct mhdf_FileDesc* result; hid_t table_id; int i, i1, numtags, j, k, size, *indices, have, num_tag_names = 0; unsigned int ui; void* ptr; char **elem_handles = 0, **tag_names = 0; unsigned char *array, *matrix; const char* pname[5] = { "PARALLEL_PARTITION", "MATERIAL_SET", "NEUMANN_SET", "DIRICHLET_SET", "GEOM_DIMENSION" }; long* id_list; struct mhdf_TagDesc* tag_desc; long int nval, junk; hid_t table[3]; hid_t data_type; API_BEGIN; mhdf_setOkay( status ); result = alloc_file_desc( status ); if( NULL == result ) return NULL; /* get node info */ have = mhdf_haveNodes( file_handle, status ); if( mhdf_isError( status ) ) { free( result ); return NULL; } if( have ) { table_id = mhdf_openNodeCoords( file_handle, &result->nodes.count, &result->nodes.vals_per_ent, &result->nodes.start_id, status ); if( table_id < 0 ) { free( result ); return NULL; } mhdf_closeData( file_handle, table_id, status ); } else { result->nodes.count = 0; result->nodes.vals_per_ent = 0; result->nodes.start_id = 0; } /* get set info */ result->sets.vals_per_ent = -1; have = mhdf_haveSets( file_handle, &result->have_set_contents, &result->have_set_children, &result->have_set_parents, status ); if( mhdf_isError( status ) ) { free( result ); return NULL; } if( have ) { table_id = mhdf_openSetMeta( file_handle, &result->sets.count, &result->sets.start_id, status ); if( table_id < 0 ) { free( result ); return NULL; } mhdf_closeData( file_handle, table_id, status ); } else { result->sets.count = 0; result->sets.start_id = 0; } /* get element list */ elem_handles = mhdf_getElemHandles( file_handle, &ui, status ); if( elem_handles == NULL ) { free( result ); return NULL; } result->num_elem_desc = ui; /* allocate array of element descriptors */ size = result->num_elem_desc * sizeof( struct mhdf_ElemDesc ); ptr = realloc_data( &result, size, status, sizeof( char* ) ); if( NULL == ptr ) { free( elem_handles ); return NULL; } memset( ptr, 0, size ); result->elems = ptr; /* Initialize each element descriptor */ for( i = 0; i < result->num_elem_desc; ++i ) { result = get_elem_desc( file_handle, result, elem_handles[i], i, status ); if( NULL == result ) { free( elem_handles ); return NULL; } } /* get tag list */ tag_names = mhdf_getTagNames( file_handle, &num_tag_names, status ); if( mhdf_isError( status ) ) { free( elem_handles ); free( result ); return NULL; } /* allocate array of tag descriptors */ size = num_tag_names * sizeof( struct mhdf_TagDesc ); ptr = realloc_data( &result, size, status, sizeof( char* ) ); if( NULL == ptr ) { free( elem_handles ); free_string_list( tag_names, result->num_tag_desc ); return NULL; } memset( ptr, 0, size ); result->tags = ptr; result->num_tag_desc = num_tag_names; memset( result->tags, 0, size ); /* Initialize each tag descriptor */ for( i = 0; i < result->num_tag_desc; ++i ) { result = get_tag_desc( file_handle, result, tag_names[i], i, file_id_type, status ); if( NULL == result ) { free( elem_handles ); free_string_list( tag_names, num_tag_names ); return NULL; } } /* Determine which dense tags are present */ size = ( 2 + result->num_elem_desc ) * result->num_tag_desc; array = mhdf_malloc( size, status ); if( NULL == array ) { free( elem_handles ); free_string_list( tag_names, num_tag_names ); free( result ); return NULL; } memset( array, 0, size ); matrix = array + ( 2 * result->num_tag_desc ); for( j = 0; j < result->num_tag_desc; ++j ) { if( mhdf_haveDenseTag( file_handle, tag_names[j], mhdf_node_type_handle(), status ) ) matrix[-1 * result->num_tag_desc + j] = 1; if( mhdf_haveDenseTag( file_handle, tag_names[j], mhdf_set_type_handle(), status ) ) matrix[-2 * result->num_tag_desc + j] = 1; for( i = 0; i < result->num_elem_desc; ++i ) if( mhdf_haveDenseTag( file_handle, tag_names[j], elem_handles[i], status ) ) matrix[i * result->num_tag_desc + j] = 1; } free( elem_handles ); free_string_list( tag_names, result->num_tag_desc ); /* Populate dense tag lists for element types */ for( i = -2; i < result->num_elem_desc; ++i ) { size = 0; for( j = 0; j < result->num_tag_desc; ++j ) size += matrix[i * result->num_tag_desc + j]; if( !size ) { indices = NULL; } else { indices = realloc_data( &result, size * sizeof( int ), status, sizeof( int ) ); if( NULL == indices ) { free( array ); return NULL; } k = 0; for( j = 0; j < result->num_tag_desc; ++j ) if( matrix[i * result->num_tag_desc + j] ) indices[k++] = j; assert( k == size ); } if( i == -2 ) { result->sets.dense_tag_indices = indices; result->sets.num_dense_tags = size; } else if( i == -1 ) { result->nodes.dense_tag_indices = indices; result->nodes.num_dense_tags = size; } else { result->elems[i].desc.dense_tag_indices = indices; result->elems[i].desc.num_dense_tags = size; } } /* Populate dense tag lists for each tag */ for( j = 0; j < result->num_tag_desc; ++j ) { size = 0; for( i = -2; i < result->num_elem_desc; ++i ) size += matrix[i * result->num_tag_desc + j]; if( !size ) { indices = 0; } else { indices = realloc_data( &result, size * sizeof( int ), status, sizeof( int ) ); if( NULL == ptr ) { free( array ); return NULL; } k = 0; for( i = -2; i < result->num_elem_desc; ++i ) if( matrix[i * result->num_tag_desc + j] ) indices[k++] = i; assert( k == size ); } result->tags[j].num_dense_indices = size; result->tags[j].dense_elem_indices = indices; } if( extraSetInfo ) { /* open the table for parallel partitions, material sets, neumann sets, * dirichlet sets * to determine number of parts, etc * this is needed for iMOAB and VisIt plugin */ const int NPRIMARY_SETS = 5; ptr = realloc_data( &result, NPRIMARY_SETS * sizeof( int ), status, sizeof( int ) ); if( NULL == ptr || mhdf_isError( status ) ) { free( array ); return NULL; } result->numEntSets = ptr; for( i = 0; i < NPRIMARY_SETS; ++i ) result->numEntSets[i] = 0; ptr = realloc_data( &result, NPRIMARY_SETS * sizeof( int* ), status, sizeof( int* ) ); if( NULL == ptr || mhdf_isError( status ) ) { free( array ); return NULL; } result->defTagsEntSets = ptr; ptr = realloc_data( &result, NPRIMARY_SETS * sizeof( int* ), status, sizeof( int* ) ); if( NULL == ptr || mhdf_isError( status ) ) { free( array ); return NULL; } result->defTagsVals = ptr; numtags = result->num_tag_desc; for( i = 0; i < numtags; i++ ) { tag_desc = &( result->tags[i] ); for( k = 0; k < NPRIMARY_SETS; k++ ) /* number of default tags to consider */ { if( strcmp( pname[k], tag_desc->name ) == 0 ) { if( tag_desc->have_sparse ) { mhdf_openSparseTagData( file_handle, pname[k], &nval, &junk, table, status ); if( mhdf_isError( status ) ) { free( array ); return NULL; } /* for sparse tags, read */ result->numEntSets[k] = nval; if( nval <= 0 ) continue; /* do not do anything */ ptr = realloc_data( &result, nval * sizeof( int ), status, sizeof( int ) ); if( NULL == ptr || mhdf_isError( status ) ) { free( array ); return NULL; } memset( ptr, 0, nval * sizeof( int ) ); result->defTagsEntSets[k] = ptr; tag_desc = &( result->tags[i] ); ptr = realloc_data( &result, nval * sizeof( int ), status, sizeof( int ) ); if( NULL == ptr || mhdf_isError( status ) ) { free( array ); return NULL; } memset( ptr, 0, nval * sizeof( int ) ); result->defTagsVals[k] = ptr; tag_desc = &( result->tags[i] ); /* this is because the tag might point to something else*/ /* make room for the long array type is it long or something else? */ id_list = mhdf_malloc( nval * sizeof( long ), status ); /* fill the id with values, then convert to int type (-set start) mhdf_read_data( table_id, offset, count, int_type, id_list, H5P_DEFAULT, status );*/ data_type = H5Dget_type( table[0] ); mhdf_read_data( table[0], 0, nval, data_type, id_list, H5P_DEFAULT, status ); if( mhdf_isError( status ) ) { free( array ); return NULL; } H5Tclose( data_type ); for( i1 = 0; i1 < nval; i1++ ) result->defTagsEntSets[k][i1] = (int)( id_list[i1] - result->sets.start_id + 1 ); /* now read values, integer type */ data_type = H5Dget_type( table[1] ); mhdf_read_data( table[1], 0, nval, data_type, result->defTagsVals[k], H5P_DEFAULT, status ); if( mhdf_isError( status ) ) { free( array ); return NULL; } H5Tclose( data_type ); mhdf_closeData( file_handle, table[0], status ); if( mhdf_isError( status ) ) { free( array ); return NULL; } mhdf_closeData( file_handle, table[1], status ); if( mhdf_isError( status ) ) { free( array ); return NULL; } free( id_list ); } else if( 0 == k || 1 == k ) { /* parallel partition or material sets should still work if dense could be dense tags on sets */ if( !mhdf_haveDenseTag( file_handle, pname[k], mhdf_set_type_handle(), status ) ) continue; table[0] = mhdf_openDenseTagData( file_handle, pname[k], mhdf_set_type_handle(), &nval, status ); if( mhdf_isError( status ) ) { continue; /* do not error out if not a dense tag either */ } result->numEntSets[k] = nval; if( nval <= 0 ) continue; /* do not do anything */ /* * if dense parallel partition or material set, we know what to expect */ result->numEntSets[k] = nval; /* k could be 0 or 1 */ if( nval <= 0 ) continue; /* do not do anything */ ptr = realloc_data( &result, nval * sizeof( int ), status, sizeof( int ) ); if( NULL == ptr || mhdf_isError( status ) ) { free( array ); return NULL; } memset( ptr, 0, nval * sizeof( int ) ); result->defTagsEntSets[k] = ptr; tag_desc = &( result->tags[i] ); ptr = realloc_data( &result, nval * sizeof( int ), status, sizeof( int ) ); if( NULL == ptr || mhdf_isError( status ) ) { free( array ); return NULL; } memset( ptr, 0, nval * sizeof( int ) ); result->defTagsVals[k] = ptr; tag_desc = &( result->tags[i] ); /* this is because the tag might point to something else*/ for( i1 = 0; i1 < nval; i1++ ) { result->defTagsEntSets[k][i1] = i1 + 1; /*result -> defTagsVals[k][i1] = i1; we know how the partition looks * like */ } /* fill in the data with the dense tag values because dense, sets will be in order we know it has to be integer */ mhdf_readTagValues( table[0], 0, nval, H5T_NATIVE_INT, result->defTagsVals[k], status ); if( mhdf_isError( status ) ) { free( array ); return NULL; } mhdf_closeData( file_handle, table[0], status ); if( mhdf_isError( status ) ) { free( array ); return NULL; } } } } } } /* Compact memory and return */ free( array ); result->total_size = result->offset - (unsigned char*)result; API_END; return result; }
mhdf_FileHandle mhdf_openFile | ( | const char * | filename, |
int | writable, | ||
unsigned long * | max_id, | ||
hid_t | id_type, | ||
mhdf_Status * | status | ||
) |
Open an existing file.
Open an existing HDF mesh file. This handle must be closed with mhdf_closeFile
to avoid resource loss.
filename | The path and name of the file to open |
writable | If non-zero, open read-write. Otherwise read-only. |
status | Passed back status of API call. |
max_id | Used to pass back the maximum global ID used in the file. Provided as an indication to the caller of the size of the mesh. This parameter is optional. NULL may be passed. |
id_type | Type to use when creating datasets containing file IDs |
Definition at line 141 of file file.c.
References mhdf_openFileWithOpt().
Referenced by iMOAB_ReadHeaderInfo(), main(), and moab::ReadHDF5::set_up_read().
{ return mhdf_openFileWithOpt( filename, writeable, max_id_out, id_type, H5P_DEFAULT, status ); }
mhdf_FileHandle mhdf_openFileWithOpt | ( | const char * | filename, |
int | writable, | ||
unsigned long * | max_id, | ||
hid_t | id_type, | ||
hid_t | options, | ||
mhdf_Status * | status | ||
) |
Open an existing file with options.
Open an existing HDF mesh file. This handle must be closed with mhdf_closeFile
to avoid resource loss. This function allows the calling application to specify the HDF5 access property list that is passed to the HDF5 H5Fopen API. If this is passed as H5P_DEFAULT, the behavior is the same as mhdf_openFile . This argument is typically used to specify a parallel context for for writing the file in parallel.
filename | The path and name of the file to open |
writable | If non-zero, open read-write. Otherwise read-only. |
status | Passed back status of API call. |
max_id | Used to pass back the maximum global ID used in the file. Provided as an indication to the caller of the size of the mesh. This parameter is optional. NULL may be passed. |
options | The HDF5 access property list to use when opening the file. See the HDF5 documentation for H5Fopen. |
id_type | Type to use when creating datasets containing file IDs |
Definition at line 277 of file file.c.
References API_BEGIN, API_END_H, struct_FileHandle::hdf_handle, struct_FileHandle::max_id, mhdf_alloc_FileHandle(), mhdf_setFail(), mhdf_setOkay(), ROOT_GROUP, and scan_for_max_id().
Referenced by mhdf_openFile(), moab::WriteHDF5Parallel::parallel_create_file(), and moab::ReadHDF5::set_up_read().
{ FileHandle* file_ptr; unsigned int flags; hid_t group_id; int check_is_hdf5 = 1; #ifdef MOAB_HAVE_HDF5_PARALLEL herr_t err; MPI_Comm comm; MPI_Info info; #endif API_BEGIN; /* Check if file is HDF5 */ /* Don't do this because it can't handle MPI-IO driver code that passes options via prefixes on the file name. */ #ifdef MOAB_HAVE_HDF5_PARALLEL if( access_prop != H5P_DEFAULT ) { err = H5Pget_fapl_mpio( access_prop, &comm, &info ); if( err >= 0 ) { check_is_hdf5 = 0; /* MPI Documentation is inconsistent with regards to whether or not the above call dup's these, but my testing with 1.8.3 indicates that at least for that version they are not. MPI_Comm_free(&comm); MPI_Info_free(&info); */ } } #endif if( check_is_hdf5 && H5Fis_hdf5( filename ) <= 0 ) { mhdf_setFail( status, "%s: File is not HDF5", filename ); return NULL; } /* Create struct to hold working data */ file_ptr = mhdf_alloc_FileHandle( 0, id_type, status ); if( !file_ptr ) { mhdf_setFail( status, "Memory allocation failed" ); return NULL; } /* Create the file */ flags = writable ? H5F_ACC_RDWR : H5F_ACC_RDONLY; file_ptr->hdf_handle = H5Fopen( filename, flags, access_prop ); if( file_ptr->hdf_handle < 0 ) { mhdf_setFail( status, "Failed to open file \"%s\"", filename ); free( file_ptr ); return NULL; } /* Check for TSTT data in file */ #if defined( H5Gopen_vers ) && H5Gopen_vers > 1 group_id = H5Gopen2( file_ptr->hdf_handle, ROOT_GROUP, H5P_DEFAULT ); #else group_id = H5Gopen( file_ptr->hdf_handle, ROOT_GROUP ); #endif if( group_id < 0 ) { mhdf_setFail( status, "Invalid file \"%s\"\n", filename ); H5Fclose( file_ptr->hdf_handle ); free( file_ptr ); return NULL; } H5Gclose( group_id ); /* Get max id */ if( !scan_for_max_id( file_ptr, status ) ) { H5Fclose( file_ptr->hdf_handle ); mhdf_setFail( status, "Internal error reading file" ); free( file_ptr ); return NULL; } if( max_id_out ) *max_id_out = file_ptr->max_id; mhdf_setOkay( status ); API_END_H( 1 ); return file_ptr; }
Tag size (number of bytes)
Definition at line 195 of file mhdf_public.h.
Referenced by get_tag_desc(), and print_tag_desc().
long mhdf_EntDesc::count |
Number of entities in table
Definition at line 183 of file mhdf_public.h.
Referenced by all_id_ranges(), check_valid_adjacencies(), check_valid_elem_conn(), check_valid_file_ids(), check_valid_set_contents(), check_valid_sets(), check_valid_tag(), check_valid_var_len_tag(), moab::ReadHDF5::find_sets_containing(), get_dim_ranges(), get_elem_desc(), moab::ReadHDF5::get_partition(), moab::ReadHDF5::get_tagged_entities(), iMOAB_ReadHeaderInfo(), moab::intersect(), moab::ReadHDF5::load_file_impl(), moab::ReadHDF5::load_file_partial(), main(), mhdf_getFileSummary(), print_ent_desc(), moab::ReadHDF5::read_all_set_meta(), moab::ReadHDF5::read_elems(), moab::ReadHDF5::read_node_adj_elems(), moab::ReadHDF5::read_set_ids_recursive(), moab::ReadHDF5::read_sets(), moab::ReadHDF5::read_tag(), moab::ReadHDF5::read_tag_values_partial(), and moab::ReadHDF5::search_tag_values().
Default value, NULL if none.
Definition at line 198 of file mhdf_public.h.
Referenced by check_valid_tag(), check_valid_var_len_tag(), moab::ReadHDF5::create_tag(), get_tag_desc(), and print_tag_desc().
Definition at line 199 of file mhdf_public.h.
Referenced by check_valid_var_len_tag(), moab::ReadHDF5::create_tag(), get_tag_desc(), and print_tag_desc().
Definition at line 229 of file mhdf_public.h.
Referenced by mhdf_fixFileDesc(), and mhdf_getFileSummary().
Definition at line 230 of file mhdf_public.h.
Referenced by mhdf_fixFileDesc(), and mhdf_getFileSummary().
Array of indices indicating element types for which dense data is stored. -2 for sets, -1 for nodes.
Definition at line 202 of file mhdf_public.h.
Referenced by check_valid_tag(), moab::ReadHDF5::get_tagged_entities(), mhdf_getFileSummary(), print_tag_desc(), moab::ReadHDF5::read_tag(), moab::ReadHDF5::read_tag_values_all(), moab::ReadHDF5::read_tag_values_partial(), and moab::ReadHDF5::search_tag_values().
Indices into mhdf_FileDesc::tags for each tag for which dense data is present for these entities
Definition at line 186 of file mhdf_public.h.
Referenced by get_elem_desc(), mhdf_fixFileDesc(), mhdf_getFileSummary(), and print_ent_desc().
struct mhdf_EntDesc mhdf_ElemDesc::desc |
Definition at line 211 of file mhdf_public.h.
Referenced by all_id_ranges(), check_valid_adjacencies(), check_valid_connectivity(), check_valid_elem_conn(), check_valid_file_ids(), check_valid_tag(), desc_name(), get_dim_ranges(), get_elem_desc(), moab::ReadHDF5::get_tagged_entities(), iMOAB_ReadHeaderInfo(), moab::ReadHDF5::load_file_partial(), mhdf_getFileSummary(), print_elem_desc(), moab::ReadHDF5::read_elems(), moab::ReadHDF5::read_node_adj_elems(), moab::ReadHDF5::read_tag(), moab::ReadHDF5::read_tag_values_partial(), and moab::ReadHDF5::search_tag_values().
struct mhdf_ElemDesc* mhdf_FileDesc::elems |
Array of element table descriptions
Definition at line 220 of file mhdf_public.h.
Referenced by all_id_ranges(), check_valid_adjacencies(), check_valid_connectivity(), check_valid_elem_conn(), check_valid_file_ids(), check_valid_poly_conn(), check_valid_tag(), ent_desc_name(), get_dim_ranges(), get_elem_desc(), moab::ReadHDF5::get_tagged_entities(), iMOAB_ReadHeaderInfo(), moab::ReadHDF5::load_file_impl(), moab::ReadHDF5::load_file_partial(), mhdf_fixFileDesc(), mhdf_getFileSummary(), print_file_summary(), moab::ReadHDF5::read_elems(), moab::ReadHDF5::read_tag(), moab::ReadHDF5::read_tag_values_all(), moab::ReadHDF5::read_tag_values_partial(), and moab::ReadHDF5::search_tag_values().
Global value, NULL if none.
Definition at line 200 of file mhdf_public.h.
Referenced by check_valid_tag(), check_valid_var_len_tag(), moab::ReadHDF5::create_tag(), get_tag_desc(), and print_tag_desc().
Definition at line 201 of file mhdf_public.h.
Referenced by check_valid_var_len_tag(), moab::ReadHDF5::create_tag(), get_tag_desc(), and print_tag_desc().
const char* mhdf_ElemDesc::handle |
String table identifier
Definition at line 208 of file mhdf_public.h.
Referenced by check_valid_adjacencies(), check_valid_elem_conn(), check_valid_poly_conn(), check_valid_tag(), desc_name(), ent_desc_name(), get_elem_desc(), moab::ReadHDF5::load_file_impl(), moab::ReadHDF5::load_file_partial(), print_elem_desc(), moab::ReadHDF5::read_elems(), moab::ReadHDF5::read_node_adj_elems(), moab::ReadHDF5::read_poly(), moab::ReadHDF5::read_tag(), moab::ReadHDF5::read_tag_values_all(), moab::ReadHDF5::read_tag_values_partial(), and moab::ReadHDF5::search_tag_values().
File contains adjacency data for this element group
Definition at line 210 of file mhdf_public.h.
Referenced by check_valid_adjacencies(), get_elem_desc(), moab::ReadHDF5::load_file_impl(), moab::ReadHDF5::load_file_partial(), and print_elem_desc().
Definition at line 218 of file mhdf_public.h.
Referenced by check_valid_sets(), mhdf_getFileSummary(), moab::ReadHDF5::read_set_ids_recursive(), and moab::ReadHDF5::read_sets().
Definition at line 217 of file mhdf_public.h.
Referenced by check_valid_sets(), moab::ReadHDF5::find_sets_containing(), moab::ReadHDF5::get_set_contents(), mhdf_getFileSummary(), moab::ReadHDF5::read_set_ids_recursive(), and moab::ReadHDF5::read_sets().
Definition at line 219 of file mhdf_public.h.
Referenced by check_valid_sets(), mhdf_getFileSummary(), and moab::ReadHDF5::read_sets().
Have sparse id/data pairs in file
Definition at line 197 of file mhdf_public.h.
Referenced by check_valid_tag(), check_valid_var_len_tag(), get_tag_desc(), moab::ReadHDF5::get_tagged_entities(), mhdf_getFileSummary(), print_tag_desc(), moab::ReadHDF5::read_tag(), moab::ReadHDF5::read_tag_values_all(), moab::ReadHDF5::read_tag_values_partial(), and moab::ReadHDF5::search_tag_values().
Definition at line 15 of file mhdf_public.h.
Referenced by mhdf_isError(), mhdf_message(), mhdf_setFail(), and mhdf_setOkay().
const char* mhdf_TagDesc::name |
Tag name
Definition at line 192 of file mhdf_public.h.
Referenced by check_valid_tag(), check_valid_var_len_tag(), moab::ReadHDF5::create_tag(), moab::ReadHDF5::find_int_tag(), get_tag_desc(), moab::ReadHDF5::get_tagged_entities(), moab::ReadHDF5::load_file_partial(), mhdf_getFileSummary(), print_ent_desc(), print_tag_desc(), moab::ReadHDF5::read_tag(), moab::ReadHDF5::read_tag_values_all(), moab::ReadHDF5::read_tag_values_partial(), and moab::ReadHDF5::search_tag_values().
struct mhdf_EntDesc mhdf_FileDesc::nodes |
Definition at line 215 of file mhdf_public.h.
Referenced by all_id_ranges(), check_valid_file_ids(), check_valid_tag(), desc_name(), ent_desc_name(), get_dim_ranges(), moab::ReadHDF5::get_tagged_entities(), iMOAB_ReadHeaderInfo(), moab::ReadHDF5::load_file_impl(), moab::ReadHDF5::load_file_partial(), main(), mhdf_fixFileDesc(), mhdf_getFileSummary(), print_file_summary(), moab::ReadHDF5::read_nodes(), moab::ReadHDF5::read_tag(), moab::ReadHDF5::read_tag_values_partial(), and moab::ReadHDF5::search_tag_values().
Definition at line 204 of file mhdf_public.h.
Referenced by check_valid_tag(), check_valid_var_len_tag(), moab::ReadHDF5::get_tagged_entities(), mhdf_getFileSummary(), print_tag_desc(), moab::ReadHDF5::read_tag(), moab::ReadHDF5::read_tag_values_all(), moab::ReadHDF5::read_tag_values_partial(), and moab::ReadHDF5::search_tag_values().
Length of dense_tag_indices
Definition at line 187 of file mhdf_public.h.
Referenced by get_elem_desc(), mhdf_getFileSummary(), and print_ent_desc().
Definition at line 221 of file mhdf_public.h.
Referenced by all_id_ranges(), check_valid_adjacencies(), check_valid_connectivity(), check_valid_file_ids(), ent_desc_name(), get_dim_ranges(), moab::ReadHDF5::get_tagged_entities(), iMOAB_ReadHeaderInfo(), moab::ReadHDF5::load_file_impl(), moab::ReadHDF5::load_file_partial(), main(), mhdf_fixFileDesc(), mhdf_getFileSummary(), print_file_summary(), and moab::ReadHDF5::search_tag_values().
Definition at line 223 of file mhdf_public.h.
Referenced by check_valid_tags(), moab::ReadHDF5::find_int_tag(), moab::ReadHDF5::load_file_impl(), moab::ReadHDF5::load_file_partial(), mhdf_fixFileDesc(), mhdf_getFileSummary(), and print_file_summary().
Definition at line 224 of file mhdf_public.h.
Referenced by iMOAB_ReadHeaderInfo(), mhdf_fixFileDesc(), and mhdf_getFileSummary().
unsigned char* mhdf_FileDesc::offset |
Unused, may be used by application
Definition at line 232 of file mhdf_public.h.
Referenced by alloc_file_desc(), mhdf_getFileSummary(), realloc_data(), moab::ReadHDF5::set_up_read(), and string_tag_value().
struct mhdf_EntDesc mhdf_FileDesc::sets |
Definition at line 216 of file mhdf_public.h.
Referenced by all_id_ranges(), check_valid_file_ids(), check_valid_sets(), check_valid_tag(), desc_name(), ent_desc_name(), moab::ReadHDF5::find_sets_containing(), moab::ReadHDF5::get_partition(), moab::ReadHDF5::get_tagged_entities(), moab::ReadHDF5::load_file_impl(), moab::ReadHDF5::load_file_partial(), mhdf_fixFileDesc(), mhdf_getFileSummary(), print_file_summary(), moab::ReadHDF5::read_all_set_meta(), moab::ReadHDF5::read_set_data(), moab::ReadHDF5::read_set_ids_recursive(), moab::ReadHDF5::read_sets(), moab::ReadHDF5::read_tag(), moab::ReadHDF5::read_tag_values_partial(), and moab::ReadHDF5::search_tag_values().
Tag size (num of data type)
Definition at line 194 of file mhdf_public.h.
Referenced by check_valid_tag(), check_valid_tags(), check_valid_var_len_tag(), moab::ReadHDF5::create_tag(), moab::ReadHDF5::find_int_tag(), get_tag_desc(), print_tag_desc(), and moab::ReadHDF5::read_tag().
First file ID for table of data
Definition at line 182 of file mhdf_public.h.
Referenced by all_id_ranges(), check_valid_adjacencies(), check_valid_elem_conn(), check_valid_file_ids(), check_valid_tag(), dcomp(), moab::ReadHDF5::find_sets_containing(), get_dim_ranges(), get_elem_desc(), moab::ReadHDF5::get_partition(), moab::ReadHDF5::get_tagged_entities(), moab::intersect(), moab::ReadHDF5::load_file_impl(), moab::ReadHDF5::load_file_partial(), mhdf_getFileSummary(), print_ent_desc(), moab::ReadHDF5::read_elems(), moab::ReadHDF5::read_node_adj_elems(), moab::ReadHDF5::read_nodes(), moab::ReadHDF5::read_set_data(), moab::ReadHDF5::read_set_ids_recursive(), moab::ReadHDF5::read_sets(), moab::ReadHDF5::read_tag(), moab::ReadHDF5::read_tag_values_partial(), and moab::ReadHDF5::search_tag_values().
MOAB tag type (dense or sparse)
Definition at line 196 of file mhdf_public.h.
Referenced by moab::ReadHDF5::create_tag(), get_tag_desc(), and print_tag_desc().
struct mhdf_TagDesc* mhdf_FileDesc::tags |
Array of tag descriptions
Definition at line 222 of file mhdf_public.h.
Referenced by check_valid_tag(), check_valid_tags(), check_valid_var_len_tag(), moab::ReadHDF5::find_int_tag(), get_tag_desc(), moab::ReadHDF5::get_tagged_entities(), moab::ReadHDF5::load_file_partial(), mhdf_fixFileDesc(), mhdf_getFileSummary(), print_ent_desc(), print_file_summary(), moab::ReadHDF5::read_tag(), moab::ReadHDF5::read_tag_values_all(), moab::ReadHDF5::read_tag_values_partial(), and moab::ReadHDF5::search_tag_values().
size_t mhdf_FileDesc::total_size |
Size of memory block containing all struct data
Definition at line 231 of file mhdf_public.h.
Referenced by alloc_file_desc(), mhdf_getFileSummary(), realloc_data(), and moab::ReadHDF5::set_up_read().
Data type
Definition at line 193 of file mhdf_public.h.
Referenced by check_valid_tag(), check_valid_var_len_tag(), moab::ReadHDF5::create_tag(), moab::ReadHDF5::find_int_tag(), get_tag_desc(), and print_tag_desc().
const char* mhdf_ElemDesc::type |
String type designator
Definition at line 209 of file mhdf_public.h.
Referenced by check_valid_connectivity(), check_valid_poly_conn(), get_dim_ranges(), get_elem_desc(), iMOAB_ReadHeaderInfo(), moab::ReadHDF5::load_file_impl(), moab::ReadHDF5::load_file_partial(), print_elem_desc(), moab::ReadHDF5::read_elems(), moab::ReadHDF5::read_node_adj_elems(), and moab::ReadHDF5::read_poly().
Connectivity length for elems, dimension for verts, unused for sets, -1 for variable length poly* data
Definition at line 184 of file mhdf_public.h.
Referenced by check_valid_connectivity(), check_valid_elem_conn(), get_elem_desc(), iMOAB_ReadHeaderInfo(), mhdf_getFileSummary(), print_ent_desc(), moab::ReadHDF5::read_elems(), moab::ReadHDF5::read_node_adj_elems(), and moab::ReadHDF5::read_nodes().