Mesh Oriented datABase  (version 5.4.1)
Array-based unstructured mesh datastructure
Element group handle
+ Collaboration diagram for Element group handle:

Defines

#define MHDF_INDEX_TYPE   H5T_NATIVE_LONG

Functions

const char * mhdf_node_type_handle (void)
 Get an mhdf_ElemHandle object for the node data.
const char * mhdf_set_type_handle (void)
 Return a special element group handle used to specify the set group.
void mhdf_getElemName (mhdf_FileHandle file_handle, unsigned int type_index, char *buffer, size_t buffer_size, mhdf_Status *status)
 Given an element type Id, get the name. Fails if buffer is not of sufficient size.
int mhdf_checkOpenHandles (mhdf_FileHandle handle, mhdf_Status *status)
void mhdf_closeData (mhdf_FileHandle file, hid_t handle, mhdf_Status *status)
 Common close function for all data handle types.
void mhdf_getNextStartId (mhdf_FileHandle file, mhdf_index_t *start_id_out, mhdf_Status *status)
 Get start ID that will be assigned to next created dataset.
void mhdf_writeHistory (mhdf_FileHandle file, const char **strings, int num_strings, mhdf_Status *status)
 Write the file history as a list of strings.
char ** mhdf_readHistory (mhdf_FileHandle file, int *num_records_out, mhdf_Status *status)
 Read the file history as a list of strings.

Define Documentation


Function Documentation

int mhdf_checkOpenHandles ( mhdf_FileHandle  handle,
mhdf_Status status 
)

Definition at line 409 of file file.c.

References API_BEGIN, API_END_H, struct_FileHandle::hdf_handle, mhdf_check_valid_file(), and mhdf_setFail().

Referenced by mhdf_closeFile().

{
    FileHandle* file_ptr;
    int result;
    API_BEGIN;

    file_ptr = (FileHandle*)( handle );
    if( !mhdf_check_valid_file( file_ptr, status ) ) return -1;

    /* Check for open handles.  HDF5 will not actually close the
       file until all handles are closed. */
    result = H5Fget_obj_count( file_ptr->hdf_handle, H5F_OBJ_ALL );
    if( result != 1 )
    {
        mhdf_setFail( status,
                      "Cannot close file with open handles: "
                      "%d file, %d data, %d group, %d type, %d attr\n",
                      H5Fget_obj_count( file_ptr->hdf_handle, H5F_OBJ_FILE ) - 1,
                      H5Fget_obj_count( file_ptr->hdf_handle, H5F_OBJ_DATASET ),
                      H5Fget_obj_count( file_ptr->hdf_handle, H5F_OBJ_GROUP ),
                      H5Fget_obj_count( file_ptr->hdf_handle, H5F_OBJ_DATATYPE ),
                      H5Fget_obj_count( file_ptr->hdf_handle, H5F_OBJ_ATTR ) );
        return result - 1;
    }

    API_END_H( 0 );
    return 0;
}
void mhdf_closeData ( mhdf_FileHandle  file,
hid_t  handle,
mhdf_Status status 
)

Common close function for all data handle types.

Close an hid_t-type handle returned from any of the following functions. Any hid_t passed-back or returned must be closed via this function to avoid resource loss.

Parameters:
fileThe file the object pointed to by the passed data handled exists int.
handleThe data object to close.
statusPassed back status of API call.

Definition at line 470 of file file.c.

References mhdf_check_valid_file(), mhdf_setFail(), mhdf_setOkay(), and struct_FileHandle::open_handle_count.

Referenced by check_valid_adjacencies(), check_valid_elem_conn(), check_valid_poly_conn(), check_valid_sets(), check_valid_tag(), check_valid_var_len_tag(), moab::WriteHDF5Parallel::create_adjacency_tables(), moab::WriteHDF5::create_elem_table(), moab::WriteHDF5Parallel::create_node_table(), moab::WriteHDF5::create_set_meta(), moab::WriteHDF5::create_set_tables(), moab::WriteHDF5::create_tag(), moab::ReadHDF5::find_sets_containing(), get_elem_desc(), moab::ReadHDF5::get_tagged_entities(), moab::ReadHDF5::load_file_impl(), moab::ReadHDF5::load_file_partial(), main(), mhdf_getFileSummary(), moab::ReadHDF5::read_all_set_meta(), moab::ReadHDF5::read_node_adj_elems(), moab::ReadHDF5::read_nodes(), moab::ReadHDF5::read_tag(), moab::ReadHDF5::read_tag_values_all(), moab::ReadHDF5::search_tag_values(), moab::WriteHDF5::serial_create_file(), moab::WriteHDF5::write_adjacencies(), moab::WriteHDF5::write_dense_tag(), moab::WriteHDF5::write_elems(), moab::WriteHDF5::write_nodes(), moab::WriteHDF5::write_sets(), moab::WriteHDF5::write_sparse_tag(), and moab::WriteHDF5::write_var_len_tag().

{
    FileHandle* file_ptr;
    herr_t rval = -1;

    file_ptr = (FileHandle*)( file );
    if( !mhdf_check_valid_file( file_ptr, status ) ) return;

    switch( H5Iget_type( handle ) )
    {
        case H5I_GROUP:
            rval = H5Gclose( handle );
            break;
        case H5I_DATATYPE:
            rval = H5Tclose( handle );
            break;
        case H5I_DATASPACE:
            rval = H5Sclose( handle );
            break;
        case H5I_DATASET:
            rval = H5Dclose( handle );
            break;
        default:
            rval = -1;
    }

    if( rval < 0 )
    {
        mhdf_setFail( status, "H5Xclose failed.  Invalid handle?\n" );
    }
    else
    {
        file_ptr->open_handle_count--;
        mhdf_setOkay( status );
    }
}
void mhdf_getElemName ( mhdf_FileHandle  file_handle,
unsigned int  type_index,
char *  buffer,
size_t  buffer_size,
mhdf_Status status 
)

Given an element type Id, get the name. Fails if buffer is not of sufficient size.

Parameters:
file_handleThe file.
type_indexThe type index. Corresponds to indices into the element type list passed to mhdf_createFile.
bufferThe buffer into which to copy the name.
buffer_sizeThe length of buffer.
statusPassed back status of API call.

Definition at line 368 of file file.c.

References API_BEGIN, API_END, get_elem_type_enum(), mhdf_check_valid_file(), mhdf_setFail(), and mhdf_setOkay().

{
    FileHandle* file_ptr;
    herr_t rval;
    hid_t enum_id;
    API_BEGIN;

    if( type_index > 255 )
    {
        mhdf_setFail( status, "Type index out of bounds." );
        return;
    }

    file_ptr = (FileHandle*)( file_handle );
    if( !mhdf_check_valid_file( file_ptr, status ) ) return;

    enum_id = get_elem_type_enum( file_ptr, status );
    if( enum_id < 0 ) return;

    rval = H5Tconvert( H5T_NATIVE_UINT, H5Tget_super( enum_id ), 1, &type_index, NULL, H5P_DEFAULT );
    if( rval < 0 )
    {
        H5Tclose( enum_id );
        mhdf_setFail( status, "Internal error converting to enum type." );
        return;
    }

    rval = H5Tenum_nameof( enum_id, &type_index, buffer, buf_size );
    H5Tclose( enum_id );
    if( rval < 0 )
        mhdf_setFail( status, "H5Tenum_nameof failed.  Invalid type index?" );
    else
        mhdf_setOkay( status );

    API_END;
}
void mhdf_getNextStartId ( mhdf_FileHandle  file,
mhdf_index_t start_id_out,
mhdf_Status status 
)

Get start ID that will be assigned to next created dataset.

Get the first_id parameter that will be returned from the next call to any of mhdf_createNodeCoords, mhdf_createConnectivity, mhdf_createPolyConnectivity, or mhdf_createSetMeta

Definition at line 925 of file file.c.

References API_BEGIN, API_END, struct_FileHandle::max_id, mhdf_check_valid_file(), and mhdf_setOkay().

{
    FileHandle* file_ptr = (FileHandle*)file;
    API_BEGIN;

    mhdf_setOkay( status );
    if( mhdf_check_valid_file( file_ptr, status ) ) *start_id_out = file_ptr->max_id + 1;

    API_END;
}
const char* mhdf_node_type_handle ( void  )

Get an mhdf_ElemHandle object for the node data.

Returns:
A special element group handle used when specifying adjacency or tag data for nodes.

Definition at line 736 of file file.c.

Referenced by check_valid_tag(), main(), mhdf_createAdjacency(), mhdf_createDenseTagData(), mhdf_getFileSummary(), mhdf_haveAdjacency(), mhdf_haveDenseTag(), mhdf_openAdjacency(), mhdf_openDenseTagData(), moab::WriteHDF5::ExportSet::name(), moab::ReadHDF5::read_tag(), moab::ReadHDF5::read_tag_values_all(), moab::ReadHDF5::read_tag_values_partial(), moab::ReadHDF5::search_tag_values(), and moab::WriteHDF5::serial_create_file().

{
    static const char rval[] = "nodes";
    return rval;
}
char** mhdf_readHistory ( mhdf_FileHandle  file,
int *  num_records_out,
mhdf_Status status 
)

Read the file history as a list of strings.

Each entry is composed of four strings: application, version, date, and time.

Strings and array are allocated with malloc. Caller must release them by calling free

Parameters:
fileThe file.
num_records_outThe length of the returned array.
statusPassed back status of API call.
Returns:
An array of null-terminates strings.

Definition at line 823 of file file.c.

References API_BEGIN, API_END, dim, struct_FileHandle::hdf_handle, HISTORY_NAME, HISTORY_PATH, mhdf_check_valid_file(), mhdf_is_in_group(), mhdf_malloc(), mhdf_setFail(), mhdf_setOkay(), and ROOT_GROUP.

Referenced by moab::ReadHDF5::read_qa().

{
    FileHandle* file_ptr;
    hid_t data_id, type_id, space_id, group_id;
    hsize_t dim;
    herr_t rval;
    char** array;
    API_BEGIN;

    file_ptr = (FileHandle*)( file_handle );
    if( !mhdf_check_valid_file( file_ptr, status ) ) return NULL;

        /* check if file contains history data */
#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, "Could not open root group.  Invalid file." );
        return NULL;
    }

    rval = mhdf_is_in_group( group_id, HISTORY_NAME, status );
    if( rval < 1 )
    {
        H5Gclose( group_id );
        *num_strings = 0;
        if( 0 == rval ) mhdf_setOkay( status );
        return NULL;
    }

#if defined( H5Dopen_vers ) && H5Dopen_vers > 1
    data_id = H5Dopen2( group_id, HISTORY_NAME, H5P_DEFAULT );
#else
    data_id      = H5Dopen( group_id, HISTORY_NAME );
#endif
    H5Gclose( group_id );
    if( data_id < 0 )
    {
        mhdf_setFail( status, "Failed to open \"%s\".", HISTORY_PATH );
        return NULL;
    }

    space_id = H5Dget_space( data_id );
    if( space_id < 0 )
    {
        H5Dclose( data_id );
        mhdf_setFail( status, "Internal error calling H5Dget_space." );
        return NULL;
    }

    if( 1 != H5Sget_simple_extent_ndims( space_id ) || 1 != H5Sget_simple_extent_dims( space_id, &dim, NULL ) )
    {
        H5Dclose( data_id );
        mhdf_setFail( status, "Invalid dimension for \"%s\".", HISTORY_PATH );
        return NULL;
    }
    H5Sclose( space_id );

    if( 0 == dim )
    {
        H5Dclose( data_id );
        *num_strings = 0;
        mhdf_setOkay( status );
        return NULL;
    }

    array = (char**)mhdf_malloc( dim * sizeof( char* ), status );
    if( !array )
    {
        H5Dclose( data_id );
        return NULL;
    }

    type_id = H5Tcopy( H5T_C_S1 );
    if( type_id < 0 || H5Tset_size( type_id, H5T_VARIABLE ) < 0 )
    {
        H5Dclose( data_id );
        if( type_id >= 0 ) H5Tclose( type_id );
        mhdf_setFail( status, "Could not create variable length string type." );
        free( array );
        return NULL;
    }

    rval = H5Dread( data_id, type_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, array );
    H5Tclose( type_id );
    H5Dclose( data_id );
    if( rval < 0 )
    {
        free( array );
        mhdf_setFail( status, "H5Dread failed." );
        return NULL;
    }

    *num_strings = dim;
    mhdf_setOkay( status );
    API_END;
    return array;
}
const char* mhdf_set_type_handle ( void  )

Return a special element group handle used to specify the set group.

Returns:
A special element group handle used to specify the set group for reading/writing tag data on sets.

Definition at line 742 of file file.c.

Referenced by check_valid_tag(), mhdf_createDenseTagData(), mhdf_getFileSummary(), mhdf_haveDenseTag(), mhdf_openDenseTagData(), moab::WriteHDF5::ExportSet::name(), moab::ReadHDF5::read_tag(), moab::ReadHDF5::read_tag_values_all(), moab::ReadHDF5::read_tag_values_partial(), and moab::ReadHDF5::search_tag_values().

{
    static const char rval[] = "sets";
    return rval;
}
void mhdf_writeHistory ( mhdf_FileHandle  file,
const char **  strings,
int  num_strings,
mhdf_Status status 
)

Write the file history as a list of strings.

Each entry is composed of four strings: application, version, date, and time.

Parameters:
fileThe file.
stringsAn array of null-terminated strings.
num_stringsThe length of strings
statusPassed back status of API call.

Definition at line 768 of file file.c.

References API_BEGIN, API_END, dim, struct_FileHandle::hdf_handle, HISTORY_PATH, mhdf_check_valid_file(), mhdf_setFail(), and mhdf_setOkay().

Referenced by moab::WriteHDF5::write_qa().

{
    FileHandle* file_ptr;
    hid_t data_id, type_id, space_id;
    hsize_t dim = (hsize_t)num_strings;
    herr_t rval;
    API_BEGIN;

    file_ptr = (FileHandle*)( file_handle );
    if( !mhdf_check_valid_file( file_ptr, status ) ) return;

    type_id = H5Tcopy( H5T_C_S1 );
    if( type_id < 0 || H5Tset_size( type_id, H5T_VARIABLE ) < 0 )
    {
        if( type_id >= 0 ) H5Tclose( type_id );
        mhdf_setFail( status, "Could not create variable length string type." );
        return;
    }

    space_id = H5Screate_simple( 1, &dim, NULL );
    if( space_id < 0 )
    {
        H5Tclose( type_id );
        mhdf_setFail( status, "H5Screate_simple failed." );
        return;
    }

#if defined( H5Dcreate_vers ) && H5Dcreate_vers > 1
    data_id =
        H5Dcreate2( file_ptr->hdf_handle, HISTORY_PATH, type_id, space_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT );
#else
    data_id      = H5Dcreate( file_ptr->hdf_handle, HISTORY_PATH, type_id, space_id, H5P_DEFAULT );
#endif
    H5Sclose( space_id );
    if( data_id < 0 )
    {
        H5Tclose( type_id );
        mhdf_setFail( status, "Failed to create \"%s\".", HISTORY_PATH );
        return;
    }

    rval = H5Dwrite( data_id, type_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, strings );
    H5Dclose( data_id );
    H5Tclose( type_id );
    if( rval < 0 )
    {
        H5Gunlink( file_ptr->hdf_handle, HISTORY_PATH );
        mhdf_setFail( status, "Failed to write history data." );
        return;
    }

    mhdf_setOkay( status );
    API_END;
}
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines