A Ruby script that reads Nastran HDF file
Purpose of the script
The script illustrates the reading of Nastran Results from an HDF file.
Script
Ruby
require "FeResPost"
include FeResPost
require "../UTIL/util"
Post.loadHDFLibrary("C:/NewProgs/HDF/HDF-1.8.20-win32/bin/HDF.dll")
#~ Post.loadHDFLibrary("C:/NewProgs/HDF/HDF-1.8.20-win64/bin/HDF.dll")
dirName="D:/SHARED/FERESPOST/TESTSAT/MODEL/EXEC_HDF"
baseName="unit_xyz"
lcIndex=0
scIndex=0
bdfName=format("%s/%s.dat",dirName,baseName)
hdfName=format("%s/%s.h5",dirName,baseName)
xdbName=format("%s/%s.xdb",dirName,baseName)
db=NastranDb.new()
db.readBdf(bdfName)
db.attachHdf(hdfName)
lcNames=db.getHdfAttachmentLcNames(hdfName)
lcName=lcNames[lcIndex]
scNames=db.getHdfAttachmentScNames(hdfName,lcName)
scName=scNames[scIndex]
resNames=db.getHdfAttachmentResNames(hdfName,lcName)
hdfResNames=resNames.clone
db.readHdfAttachmentResults(hdfName,lcName,scName,resNames)
...
Explanation
The different steps of the access to Nastran results from an HDF file are:
- The loading of the HDF DLL library. Note that you must choose the right version, depending on the version of Ruby you are running. For example, on Windows, you must choose the appropriate 32-bit or 64-bit shared library.
- A Nastran HDF Result file ("h5" extension) must be attached to a NastranDb database.
- Then, you can access information about the results stored in the HDF file. Results can be read into the database, or returned in a Hash object, as in the example above.
References
More information on this example, and on the functions it uses, is given in the FeResPost User Manual.