#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. More... | |
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. More... | |
int | mhdf_countOpenHandles (mhdf_FileHandle file_handle) |
Get number of open HDF5 objects from file. More... | |
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. More... | |
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. More... | |
int | mhdf_checkOpenHandles (mhdf_FileHandle handle, mhdf_Status *status) |
void | mhdf_closeFile (mhdf_FileHandle handle, mhdf_Status *status) |
Close the file. More... | |
void | mhdf_closeData (mhdf_FileHandle file, hid_t handle, mhdf_Status *status) |
Common close function for all data handle types. More... | |
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. More... | |
char ** | mhdf_getElemHandles (mhdf_FileHandle file_handle, unsigned int *count_out, mhdf_Status *status) |
Get the list of element groups in the file. More... | |
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. More... | |
const char * | mhdf_node_type_handle (void) |
Get an mhdf_ElemHandle object for the node data. More... | |
const char * | mhdf_set_type_handle (void) |
Return a special element group handle used to specify the set group. More... | |
int | mhdf_isPolyElement (mhdf_FileHandle file_handle, const char *elem_handle, mhdf_Status *status) |
Check if an element group contains polygon or polyhedron. More... | |
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. More... | |
char ** | mhdf_readHistory (mhdf_FileHandle file_handle, int *num_strings, mhdf_Status *status) |
Read the file history as a list of strings. More... | |
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. More... | |
|
static |
Definition at line 155 of file file.c.
References START_ID_ATTRIB.
Referenced by max_id_iter(), and scan_for_max_id().
|
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().
|
static |
Definition at line 214 of file file.c.
References CONNECTIVITY_NAME, and get_max_id().
Referenced by scan_for_max_id().
void mhdf_addElement | ( | mhdf_FileHandle | file_handle, |
const char * | elem_handle, | ||
unsigned int | named_elem_type, | ||
mhdf_Status * | status | ||
) |
Add a new table of element data to the file.
Add a element group to the file. An element group is the data for a block of elements with the same TSTT type and same number of nodes in their connectivity data. (e.g. all the MBHEX20 elements). This function is also used to create the groups for general polygon data and general polyhedron data. The requirement that all elements have the same number of nodes in their connectivity does not apply for poly(gons|hedra).
file_handle | File in which to create the element type. |
elem_handle | The name to use for the element data. This name is used as an identifier to reference the data for this element type later. The selected name also appears explicitly in the file and therefore should be something descriptive of the element type such as the 'base type' and number of nodes (e.g. "Hex20"). |
named_elem_type | An index into the list of named element types passed to mhdf_createFile . |
status | Passed back status of API call. |
Definition at line 507 of file file.c.
References API_BEGIN, API_END, DENSE_TAG_SUBGROUP, ELEM_TYPE_ATTRIB, ELEMENT_GROUP, get_elem_type_enum(), struct_FileHandle::hdf_handle, mhdf_check_valid_file(), mhdf_create_scalar_attrib(), mhdf_malloc(), mhdf_name_to_path(), mhdf_path_to_name(), mhdf_setFail(), and mhdf_setOkay().
Referenced by moab::WriteHDF5::create_elem_table().
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().
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.
file | The file the object pointed to by the passed data handled exists int. |
handle | The data object to close. |
status | Passed 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().
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().
int mhdf_countOpenHandles | ( | mhdf_FileHandle | file_handle | ) |
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().
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 (mhdf_type), 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().
char** mhdf_getElemHandles | ( | mhdf_FileHandle | file_handle, |
unsigned int * | count_out, | ||
mhdf_Status * | status | ||
) |
Get the list of element groups in the file.
Get the list of element groups in the file. An element group is the data for a block of elements with the same TSTT type and same number of nodes in their connectivity data. (e.g. all the MBHEX20 elements). This function is also used to retrieve the groups for general polygon data and general polyhedron data. The requirement that all elements have the same number of nodes in their connectivity does not apply for poly(gons|hedra).
file_handle | The file. |
count_out | Memory location at which to store the length of the returned array. |
status | Passed back status of API call. |
Definition at line 586 of file file.c.
References buffer, ELEMENT_GROUP, struct_FileHandle::hdf_handle, length(), mhdf_check_valid_file(), mhdf_malloc(), mhdf_path_to_name(), mhdf_setFail(), and mhdf_setOkay().
Referenced by main(), and mhdf_getFileSummary().
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.
file_handle | The file. |
type_index | The type index. Corresponds to indices into the element type list passed to mhdf_createFile. |
buffer | The buffer into which to copy the name. |
buffer_size | The length of buffer . |
status | Passed back status of API call. |
Definition at line 368 of file file.c.
References API_BEGIN, API_END, buffer, get_elem_type_enum(), mhdf_check_valid_file(), mhdf_setFail(), and mhdf_setOkay().
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.
Fails if name is longer than buf_len
.
file_handle | The file. |
elem_handle | One of the group names passed back from mhdf_getElemHandles |
buffer | A buffer to copy the name into. |
buf_len | The length of buffer . |
status | Passed back status of API call. |
Definition at line 655 of file file.c.
References API_BEGIN, API_END, buffer, ELEM_TYPE_ATTRIB, mhdf_check_valid_file(), mhdf_elem_group_from_handle(), mhdf_setFail(), and mhdf_setOkay().
Referenced by get_elem_desc(), and main().
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().
int mhdf_isPolyElement | ( | mhdf_FileHandle | file_handle, |
const char * | elem_handle, | ||
mhdf_Status * | status | ||
) |
Check if an element group contains polygon or polyhedron.
Check if an element group contains general polygon or polyhedrons rather than typically fixed-connectivity elements.
file_handle | The file. |
elem_handle | The element group. |
status | Passed back status of API call. |
Definition at line 748 of file file.c.
References API_BEGIN, API_END, mhdf_check_valid_file(), mhdf_elem_group_from_handle(), mhdf_is_in_group(), mhdf_setOkay(), and POLY_INDEX_NAME.
Referenced by get_elem_desc().
const char* mhdf_node_type_handle | ( | void | ) |
Get an mhdf_ElemHandle object for the node data.
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. MHDF API for reading/writing MOAB-format HDF5 mesh files. Error handling Element group handle
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().
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().
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().
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
file | The file. |
num_records_out | The length of the returned array. |
status | Passed back status of API call. |
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().
const char* mhdf_set_type_handle | ( | void | ) |
Return a special element group handle used to specify the set group.
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().
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.
file | The file. |
strings | An array of null-terminated strings. |
num_strings | The length of strings |
status | Passed 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().
|
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().