MOAB: Mesh Oriented datABase
(version 5.4.1)
|
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <H5Fpublic.h>
#include <H5Ppublic.h>
#include <H5Gpublic.h>
#include <H5Spublic.h>
#include <H5Tpublic.h>
#include <H5Apublic.h>
#include "mhdf.h"
#include "status.h"
#include "names-and-paths.h"
#include "util.h"
#include "file-handle.h"
Go to the source code of this file.
Functions | |
static int | make_hdf_group (const char *path, hid_t file, size_t size, mhdf_Status *status) |
mhdf_FileHandle | mhdf_createFile (const char *filename, int overwrite, const char **elem_type_list, size_t elem_list_len, hid_t id_type, mhdf_Status *status) |
Create a new file. | |
mhdf_FileHandle | mhdf_openFile (const char *filename, int writeable, unsigned long *max_id_out, hid_t id_type, mhdf_Status *status) |
Open an existing file. | |
int | mhdf_countOpenHandles (mhdf_FileHandle file_handle) |
Get number of open HDF5 objects from file. | |
static herr_t | get_max_id (hid_t group_id, const char *subgroup, const char *datatable, unsigned long *data) |
static herr_t | max_id_iter (hid_t group_id, const char *name, void *data) |
static int | scan_for_max_id (FileHandle *file_ptr, mhdf_Status *status) |
mhdf_FileHandle | mhdf_openFileWithOpt (const char *filename, int writable, unsigned long *max_id_out, hid_t id_type, hid_t access_prop, mhdf_Status *status) |
Open an existing file with options. | |
void | mhdf_getElemName (mhdf_FileHandle file_handle, unsigned int type_index, char *buffer, size_t buf_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_closeFile (mhdf_FileHandle handle, mhdf_Status *status) |
Close the file. | |
void | mhdf_closeData (mhdf_FileHandle file, hid_t handle, mhdf_Status *status) |
Common close function for all data handle types. | |
void | mhdf_addElement (mhdf_FileHandle file_handle, const char *name, unsigned int elem_type, mhdf_Status *status) |
Add a new table of element data to the file. | |
char ** | mhdf_getElemHandles (mhdf_FileHandle file_handle, unsigned int *count_out, mhdf_Status *status) |
Get the list of element groups in the file. | |
void | mhdf_getElemTypeName (mhdf_FileHandle file_handle, const char *elem_handle, char *buffer, size_t buf_len, mhdf_Status *status) |
Get the element type name for a given element group handle. | |
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. | |
int | mhdf_isPolyElement (mhdf_FileHandle file_handle, const char *elem_handle, mhdf_Status *status) |
Check if an element group contains polygon or polyhedron. | |
void | mhdf_writeHistory (mhdf_FileHandle file_handle, const char **strings, int num_strings, mhdf_Status *status) |
Write the file history as a list of strings. | |
char ** | mhdf_readHistory (mhdf_FileHandle file_handle, int *num_strings, mhdf_Status *status) |
Read the file history as a list of strings. | |
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. |
static herr_t get_max_id | ( | hid_t | group_id, |
const char * | subgroup, | ||
const char * | datatable, | ||
unsigned long * | data | ||
) | [static] |
Definition at line 155 of file file.c.
References rank, and START_ID_ATTRIB.
Referenced by max_id_iter(), and scan_for_max_id().
{ unsigned long id; hid_t elem_id, conn_id, attr_id, space_id; herr_t rval; int rank; hsize_t dims[2]; #if defined( H5Gopen_vers ) && H5Gopen_vers > 1 elem_id = H5Gopen2( group_id, subgroup, H5P_DEFAULT ); #else elem_id = H5Gopen( group_id, subgroup ); #endif if( elem_id < 0 ) return (herr_t)-1; #if defined( H5Dopen_vers ) && H5Dopen_vers > 1 conn_id = H5Dopen2( elem_id, datatable, H5P_DEFAULT ); #else conn_id = H5Dopen( elem_id, datatable ); #endif H5Gclose( elem_id ); if( conn_id < 0 ) return (herr_t)-1; space_id = H5Dget_space( conn_id ); if( space_id < 0 ) { H5Dclose( conn_id ); return -1; } rank = H5Sget_simple_extent_ndims( space_id ); if( rank <= 0 || rank > 2 ) { H5Dclose( conn_id ); H5Sclose( space_id ); return -1; } rval = H5Sget_simple_extent_dims( space_id, dims, NULL ); H5Sclose( space_id ); if( rval < 0 ) { H5Dclose( conn_id ); return -1; } attr_id = H5Aopen_name( conn_id, START_ID_ATTRIB ); H5Dclose( conn_id ); if( attr_id < 0 ) return (herr_t)-1; rval = H5Aread( attr_id, H5T_NATIVE_ULONG, &id ); H5Aclose( attr_id ); if( rval < 0 ) return rval; id += dims[0]; if( id > *data ) *data = id; return 0; }
static int make_hdf_group | ( | const char * | path, |
hid_t | file, | ||
size_t | size, | ||
mhdf_Status * | status | ||
) | [static] |
MOAB, a Mesh-Oriented datABase, is a software component for creating, storing and accessing finite element mesh data.
Copyright 2004 Sandia Corporation. Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains certain rights in this software.
This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.
Definition at line 713 of file file.c.
References mhdf_setFail().
Referenced by mhdf_createFile().
{ #if defined( H5Gcreate_vers ) && H5Gcreate_vers > 1 hid_t handle = H5Gcreate2( file, path, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT ); /* empty statement to avoid compiler warning */ if( sz ) { } #else hid_t handle = H5Gcreate( file, path, sz ); #endif if( handle < 0 ) { mhdf_setFail( status, "Failed to create \"%s\" group.", path ); return 0; } else { H5Gclose( handle ); return 1; } }
static herr_t max_id_iter | ( | hid_t | group_id, |
const char * | name, | ||
void * | data | ||
) | [static] |
Definition at line 214 of file file.c.
References CONNECTIVITY_NAME, and get_max_id().
Referenced by scan_for_max_id().
{ return get_max_id( group_id, name, CONNECTIVITY_NAME, (unsigned long*)data ); }
static int scan_for_max_id | ( | FileHandle * | file_ptr, |
mhdf_Status * | status | ||
) | [static] |
Definition at line 219 of file file.c.
References ELEMENT_GROUP_NAME, get_max_id(), struct_FileHandle::hdf_handle, struct_FileHandle::max_id, MAX_ID_ATTRIB, max_id_iter(), mhdf_is_in_group(), mhdf_read_scalar_attrib(), mhdf_setFail(), NODE_GROUP_NAME, ROOT_GROUP, SET_GROUP_NAME, and SET_META_NAME.
Referenced by mhdf_openFileWithOpt().
{ hid_t group_id; herr_t rval; /* Check for new format, with max_id as attrib of root 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 if( group_id < 0 ) { mhdf_setFail( status, "Internal error - invalid file." ); return 0; } if( mhdf_read_scalar_attrib( group_id, MAX_ID_ATTRIB, H5T_NATIVE_ULONG, &file_ptr->max_id, status ) ) { H5Gclose( group_id ); return 1; } /* Didn't find it, scan the elements group */ rval = H5Giterate( group_id, ELEMENT_GROUP_NAME, 0, &max_id_iter, &file_ptr->max_id ); if( rval ) { H5Gclose( group_id ); mhdf_setFail( status, "Internal error -- invalid file." ); return 0; } /* Check node table too */ rval = get_max_id( group_id, NODE_GROUP_NAME, "coordinates", (unsigned long*)( &file_ptr->max_id ) ); if( rval ) { H5Gclose( group_id ); mhdf_setFail( status, "Internal error -- invalid file." ); return 0; } /* Check set table, if it exists */ rval = mhdf_is_in_group( group_id, SET_GROUP_NAME, status ); if( rval < 1 ) { H5Gclose( group_id ); return !rval; } rval = get_max_id( group_id, SET_GROUP_NAME, SET_META_NAME, (unsigned long*)( &file_ptr->max_id ) ); H5Gclose( group_id ); if( rval ) { mhdf_setFail( status, "Internal error -- invalid file." ); return 0; } return 1; }