Mesh Oriented datABase  (version 5.5.1)
An array-based unstructured mesh library
nodes.c File Reference
#include <H5Tpublic.h>
#include <H5Dpublic.h>
#include <H5Ppublic.h>
#include <H5Gpublic.h>
#include "mhdf.h"
#include "status.h"
#include "names-and-paths.h"
#include "util.h"
#include "file-handle.h"
+ Include dependency graph for nodes.c:

Go to the source code of this file.

Functions

int mhdf_haveNodes (mhdf_FileHandle file, mhdf_Status *status)
 
hid_t mhdf_createNodeCoords (mhdf_FileHandle file_handle, int dimension, long num_nodes, long *first_id_out, mhdf_Status *status)
 Create new table for node coordinate data. More...
 
hid_t mhdf_openNodeCoords (mhdf_FileHandle file_handle, long *num_nodes_out, int *dimension_out, long *first_id_out, mhdf_Status *status)
 Open table containing node coordinate data. More...
 
hid_t mhdf_openNodeCoordsSimple (mhdf_FileHandle file_handle, mhdf_Status *status)
 
void mhdf_writeNodeCoords (hid_t table_id, long offset, long count, const double *coords, mhdf_Status *status)
 Write node coordinate data. More...
 
void mhdf_writeNodeCoordsWithOpt (hid_t table_id, long offset, long count, const double *coords, hid_t prop, mhdf_Status *status)
 
void mhdf_readNodeCoords (hid_t table_id, long offset, long count, double *coords, mhdf_Status *status)
 Read node coordinate data. More...
 
void mhdf_readNodeCoordsWithOpt (hid_t table_id, long offset, long count, double *coords, hid_t prop, mhdf_Status *status)
 
void mhdf_writeNodeCoord (hid_t table_id, long offset, long count, int dimension, const double *coords, mhdf_Status *status)
 Write node coordinate data. More...
 
void mhdf_writeNodeCoordWithOpt (hid_t table_id, long offset, long count, int dimension, const double *coords, hid_t prop, mhdf_Status *status)
 
void mhdf_readNodeCoord (hid_t table_id, long offset, long count, int dimension, double *coords, mhdf_Status *status)
 Read node coordinate data. More...
 
void mhdf_readNodeCoordWithOpt (hid_t table_id, long offset, long count, int dimension, double *coords, hid_t prop, mhdf_Status *status)
 

Function Documentation

◆ mhdf_createNodeCoords()

hid_t mhdf_createNodeCoords ( mhdf_FileHandle  file_handle,
int  dimension,
long  num_nodes,
long *  first_node_id_out,
mhdf_Status status 
)

Create new table for node coordinate data.

Parameters
file_handleThe file.
dimensionNumber of coordinate values per node.
num_nodesThe number of nodes the table will contain.
first_node_id_outNodes are assigned IDs sequentially in the order they occur in the table, where the ID of the first node in the table is this passed-back value.
statusPassed back status of API call.
Returns
An HDF5 handle to the coordinate table.

Definition at line 72 of file nodes.c.

77 {
78  FileHandle* file_ptr = (FileHandle*)file_handle;
79  hid_t table_id;
80  hsize_t dims[2];
81  long first_id;
82  API_BEGIN;
83 
84  if( !mhdf_check_valid_file( file_ptr, status ) ) return -1;
85 
86  if( dimension < 1 )
87  {
88  mhdf_setFail( status, "Invalid argument: dimension = %d.", dimension );
89  return -1;
90  }
91 
92  dims[0] = (hsize_t)num_nodes;
93  dims[1] = (hsize_t)dimension;
94  table_id = mhdf_create_table( file_ptr->hdf_handle, NODE_COORD_PATH, H5T_NATIVE_DOUBLE, 2, dims, status );
95  if( table_id < 0 ) return -1;
96 
97  first_id = file_ptr->max_id + 1;
98  if( !mhdf_create_scalar_attrib( table_id, START_ID_ATTRIB, H5T_NATIVE_LONG, &first_id, status ) )
99  {
100  H5Dclose( table_id );
101  return -1;
102  }
103 
104  *first_id_out = first_id;
105  file_ptr->max_id += num_nodes;
106  if( !mhdf_write_max_id( file_ptr, status ) )
107  {
108  H5Dclose( table_id );
109  return -1;
110  }
111  file_ptr->open_handle_count++;
112  mhdf_setOkay( status );
113 
114  API_END_H( 1 );
115  return table_id;
116 }

References API_BEGIN, API_END_H, struct_FileHandle::hdf_handle, struct_FileHandle::max_id, mhdf_check_valid_file(), mhdf_create_scalar_attrib(), mhdf_create_table(), mhdf_setFail(), mhdf_setOkay(), mhdf_write_max_id(), NODE_COORD_PATH, struct_FileHandle::open_handle_count, and START_ID_ATTRIB.

Referenced by moab::WriteHDF5Parallel::create_node_table(), and moab::WriteHDF5::serial_create_file().

◆ mhdf_haveNodes()

int mhdf_haveNodes ( mhdf_FileHandle  file,
mhdf_Status status 
)

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 26 of file nodes.c.

27 {
28  FileHandle* file_ptr = (FileHandle*)file;
29  hid_t root_id, node_id;
30  int result;
31  API_BEGIN;
32 
33  if( !mhdf_check_valid_file( file_ptr, status ) ) return -1;
34 
35 #if defined( H5Gopen_vers ) && H5Gopen_vers > 1
36  root_id = H5Gopen2( file_ptr->hdf_handle, ROOT_GROUP, H5P_DEFAULT );
37 #else
38  root_id = H5Gopen( file_ptr->hdf_handle, ROOT_GROUP );
39 #endif
40  if( root_id < 0 )
41  {
42  mhdf_setFail( status, "H5Gopen( \"%s\" ) failed.", ROOT_GROUP );
43  return -1;
44  }
45 
46  result = mhdf_is_in_group( root_id, NODE_GROUP_NAME, status );
47  if( result < 1 )
48  {
49  H5Gclose( root_id );
50  return result;
51  }
52 
53 #if defined( H5Gopen_vers ) && H5Gopen_vers > 1
54  node_id = H5Gopen2( root_id, NODE_GROUP_NAME, H5P_DEFAULT );
55 #else
56  node_id = H5Gopen( root_id, NODE_GROUP_NAME );
57 #endif
58  H5Gclose( root_id );
59  if( node_id < 0 )
60  {
61  mhdf_setFail( status, "H5Gopen( \"%s\" ) failed.", NODE_GROUP );
62  return -1;
63  }
64 
65  result = mhdf_is_in_group( node_id, NODE_COORD_NAME, status );
66  if( result >= 0 ) mhdf_setOkay( status );
67  H5Gclose( node_id );
68  API_END;
69  return result;
70 }

References API_BEGIN, API_END, struct_FileHandle::hdf_handle, mhdf_check_valid_file(), mhdf_is_in_group(), mhdf_setFail(), mhdf_setOkay(), NODE_COORD_NAME, NODE_GROUP, NODE_GROUP_NAME, and ROOT_GROUP.

Referenced by mhdf_getFileSummary().

◆ mhdf_openNodeCoords()

hid_t mhdf_openNodeCoords ( mhdf_FileHandle  file_handle,
long *  num_nodes_out,
int *  dimension_out,
long *  first_node_id_out,
mhdf_Status status 
)

Open table containing node coordinate data.

Parameters
file_handleThe file.
dimension_outNumber of coordinate values per node.
num_nodes_outThe number of nodes the table contains.
first_node_id_outNodes are assigned IDs sequentially in the order they occur in the table, where the ID of the first node in the table is this passed-back value.
statusPassed back status of API call.
Returns
An HDF5 handle to the coordinate table.

Definition at line 118 of file nodes.c.

123 {
124  FileHandle* file_ptr = (FileHandle*)file_handle;
125  hid_t table_id;
126  hsize_t dims[2];
127  API_BEGIN;
128 
129  if( !mhdf_check_valid_file( file_ptr, status ) ) return -1;
130 
131  table_id = mhdf_open_table2( file_ptr->hdf_handle, NODE_COORD_PATH, 2, dims, first_id_out, status );
132  if( table_id < 0 ) return -1;
133 
134  *num_nodes_out = dims[0];
135  *dimension_out = dims[1];
136  file_ptr->open_handle_count++;
137  mhdf_setOkay( status );
138  API_END_H( 1 );
139  return table_id;
140 }

References API_BEGIN, API_END_H, struct_FileHandle::hdf_handle, mhdf_check_valid_file(), mhdf_open_table2(), mhdf_setOkay(), NODE_COORD_PATH, and struct_FileHandle::open_handle_count.

Referenced by main(), mhdf_getFileSummary(), and moab::WriteHDF5::write_nodes().

◆ mhdf_openNodeCoordsSimple()

hid_t mhdf_openNodeCoordsSimple ( mhdf_FileHandle  file_handle,
mhdf_Status status 
)

Definition at line 142 of file nodes.c.

143 {
144  FileHandle* file_ptr = (FileHandle*)file_handle;
145  hid_t table_id;
146  API_BEGIN;
147 
148  if( !mhdf_check_valid_file( file_ptr, status ) ) return -1;
149 
150  table_id = mhdf_open_table_simple( file_ptr->hdf_handle, NODE_COORD_PATH, status );
151  if( table_id < 0 ) return -1;
152 
153  file_ptr->open_handle_count++;
154  mhdf_setOkay( status );
155  API_END_H( 1 );
156  return table_id;
157 }

References API_BEGIN, API_END_H, struct_FileHandle::hdf_handle, mhdf_check_valid_file(), mhdf_open_table_simple(), mhdf_setOkay(), NODE_COORD_PATH, and struct_FileHandle::open_handle_count.

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

◆ mhdf_readNodeCoord()

void mhdf_readNodeCoord ( hid_t  data_handle,
long  offset,
long  count,
int  dimension,
double *  coords,
mhdf_Status status 
)

Read node coordinate data.

Read a single coordinate value (e.g. the 'x' coordinate) for a block of nodes.

Parameters
data_handleHandle returned from mhdf_createNodeCoords or mhdf_openNodeCoords.
offsetTable row (node index) at which to start reading.
countNumber of rows (number of nodes) to read.
dimensionThe coordinate to read (0->x, 1->y, ...)
coordsBuffer in which to write node coordinate data.
statusPassed back status of API call.

Definition at line 219 of file nodes.c.

220 {
221  API_BEGIN;
222  mhdf_read_column( table_id, dimension, offset, count, H5T_NATIVE_DOUBLE, coords, H5P_DEFAULT, status );
223  API_END;
224 }

References API_BEGIN, API_END, and mhdf_read_column().

◆ mhdf_readNodeCoords()

void mhdf_readNodeCoords ( hid_t  data_handle,
long  offset,
long  count,
double *  coordinates,
mhdf_Status status 
)

Read node coordinate data.

Read interleaved coordinate data for a block of nodes

Parameters
data_handleHandle returned from mhdf_createNodeCoords or mhdf_openNodeCoords.
offsetTable row (node index) at which to start reading.
countNumber of rows (number of nodes) to read.
coordinatesBuffer in which to write node coordinate data.
statusPassed back status of API call.

Definition at line 177 of file nodes.c.

178 {
179  API_BEGIN;
180  mhdf_read_data( table_id, offset, count, H5T_NATIVE_DOUBLE, coords, H5P_DEFAULT, status );
181  API_END;
182 }

References API_BEGIN, API_END, and mhdf_read_data().

Referenced by main().

◆ mhdf_readNodeCoordsWithOpt()

void mhdf_readNodeCoordsWithOpt ( hid_t  table_id,
long  offset,
long  count,
double *  coords,
hid_t  prop,
mhdf_Status status 
)

Definition at line 183 of file nodes.c.

189 {
190  API_BEGIN;
191  mhdf_read_data( table_id, offset, count, H5T_NATIVE_DOUBLE, coords, prop, status );
192  API_END;
193 }

References API_BEGIN, API_END, and mhdf_read_data().

◆ mhdf_readNodeCoordWithOpt()

void mhdf_readNodeCoordWithOpt ( hid_t  table_id,
long  offset,
long  count,
int  dimension,
double *  coords,
hid_t  prop,
mhdf_Status status 
)

Definition at line 225 of file nodes.c.

232 {
233  API_BEGIN;
234  mhdf_read_column( table_id, dimension, offset, count, H5T_NATIVE_DOUBLE, coords, prop, status );
235  API_END;
236 }

References API_BEGIN, API_END, and mhdf_read_column().

◆ mhdf_writeNodeCoord()

void mhdf_writeNodeCoord ( hid_t  data_handle,
long  offset,
long  count,
int  dimension,
const double *  coords,
mhdf_Status status 
)

Write node coordinate data.

Write a single coordinate value (e.g. the 'x' coordinate) for a block of nodes.

Parameters
data_handleHandle returned from mhdf_createNodeCoords or mhdf_openNodeCoords.
offsetTable row (node index) at which to start writing.
countNumber of rows (number of nodes) to write.
dimensionThe coordinate to write (0->x, 1->y, ...)
coordsCoordinate list.
statusPassed back status of API call.

Definition at line 195 of file nodes.c.

201 {
202  API_BEGIN;
203  mhdf_write_column( table_id, dimension, offset, count, H5T_NATIVE_DOUBLE, coords, H5P_DEFAULT, status );
204  API_END;
205 }

References API_BEGIN, API_END, and mhdf_write_column().

◆ mhdf_writeNodeCoords()

void mhdf_writeNodeCoords ( hid_t  data_handle,
long  offset,
long  count,
const double *  coords,
mhdf_Status status 
)

Write node coordinate data.

Write interleaved coordinate data for a block of nodes

Parameters
data_handleHandle returned from mhdf_createNodeCoords or mhdf_openNodeCoords.
offsetTable row (node index) at which to start writing.
countNumber of rows (number of nodes) to write.
coordsInterleaved node coordinate data.
statusPassed back status of API call.

Definition at line 159 of file nodes.c.

160 {
161  API_BEGIN;
162  mhdf_write_data( table_id, offset, count, H5T_NATIVE_DOUBLE, coords, H5P_DEFAULT, status );
163  API_END;
164 }

References API_BEGIN, API_END, and mhdf_write_data().

◆ mhdf_writeNodeCoordsWithOpt()

void mhdf_writeNodeCoordsWithOpt ( hid_t  table_id,
long  offset,
long  count,
const double *  coords,
hid_t  prop,
mhdf_Status status 
)

Definition at line 165 of file nodes.c.

171 {
172  API_BEGIN;
173  mhdf_write_data( table_id, offset, count, H5T_NATIVE_DOUBLE, coords, prop, status );
174  API_END;
175 }

References API_BEGIN, API_END, and mhdf_write_data().

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

◆ mhdf_writeNodeCoordWithOpt()

void mhdf_writeNodeCoordWithOpt ( hid_t  table_id,
long  offset,
long  count,
int  dimension,
const double *  coords,
hid_t  prop,
mhdf_Status status 
)

Definition at line 206 of file nodes.c.

213 {
214  API_BEGIN;
215  mhdf_write_column( table_id, dimension, offset, count, H5T_NATIVE_DOUBLE, coords, prop, status );
216  API_END;
217 }

References API_BEGIN, API_END, and mhdf_write_column().

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