When you create the array you specifiy the "shape" of each element in the
array.  If its a connections component that you are reading, and there are
n vertices per element:

array = DXNewArray (TYPE_INT, CATEGORY_REAL, 1, n);
npoints = H5Sget_simple_extent_npoints (dataspace);
data = DXGetArrayData (DXAddArrayData (array, 0, (int) npoints, NULL));

Each element of the array is a n-vector, and there are npoints of them.

H5Dread (dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL,H5P_DEFAULT, data));

retval = DXNewField ();

You need to tell it the element type, which can be done several ways:

DXSetAttribute((Object)array, "element type", "triangles");
DXSetComponentValue (retval, "connections", (Object) array);

Or after its stuck in the field:

DXSetComponentValue (retval, "connections", (Object) array);
DXSetComponentAttribute(retval, "connections", "element type",
"triangles");

DXEndField (retval);

I understand there's a HDF5 reader available through Cactus - and I think
it was Scott that told me about it.



                                                                                
                                                         
                      "Mike H. Miller"                                          
                                                         
                      <[EMAIL PROTECTED]>                   To:       
[email protected]                                  
                      Sent by:                             cc:                  
                                                         
                      [EMAIL PROTECTED]        Subject:  [opendx-users] 
Importing Data-- creating connections and positions  
                      son.ibm.com                           from raw arrays     
                                                         
                                                                                
                                                         
                                                                                
                                                         
                      07/12/2002 11:41 AM                                       
                                                         
                      Please respond to                                         
                                                         
                      opendx-users                                              
                                                         
                                                                                
                                                         
                                                                                
                                                         




Hi,
I'm writing a module to import some HDF5 data into DX, and I'm not sure
how to transform my arrays with the connection, position, and data data
into actual connection, position, and data components of one field. I
have code that looks like (I've cut out all sanity checking to
illustrate):

array = DXNewArray (TYPE_INT, CATEGORY_REAL, 0);
npoints = H5Sget_simple_extent_npoints (dataspace);
data = DXGetArrayData (DXAddArrayData (array, 0, (int) npoints, NULL));
H5Dread (dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL,H5P_DEFAULT, data));

which reads the first thing from the file-- the connections list. I then
used the following which, I believe, marks that as the data component.

retval = DXNewField ();
DXSetComponentValue (retval, "data", (Object) array);
DXEndField (retval);

I presume I could replace the "data" with "connections", but the other
problem is that this data is supposed to be a 7500x3 array, but instead
it declared it (since I did AddArrayData on npoints) as 22500 (aka
7500*3). I have the 7500 and 3 as variables, so I know what they are
supposed to be-- how do I redimension that large array-- or do I not
need to? A print shows I have the correct numbers being read, but
suggests they actually are only one dimensional.

Also, when I need to read the positions and data points, do I just add
them to the rest of the array (by doing a DXAddArrayData(array, npoints,
nposition, NULL), or should I use an new array and/or overwrite that
one? Thanks in advance!

--
Mike Miller
[EMAIL PROTECTED] ->
[EMAIL PROTECTED]


#### signature.asc has been removed from this note on July 12 2002 by
Gregory D Abram



Reply via email to