III.1.1.11 Attaching “HDF” files to a Nastran DataBase
Since version 4.5.0 of FeResPost, it is possible to read results from Nastran HDF5 files. The operation
is done in several steps:
- The reading of HDF files is possible only after the HDF5 shared library is loaded
into FeResPost. This is done by calling method “Post.loadHdf5Library” described in
section I.6.11.
- The HDF file is attached to the DataBase and its content (lists of load cases, sub-cases
and Results) is identified. Several methods give access to this information.
- The Results that are needed are then read from the file (into a Nastran Database, or
returned into a Hash).
The different methods called to perform these operations are described in the following sub-sections.
III.1.1.11.1 Reading Results fron an HDF file
The “readHdf” method is used to read Results into the DataBase from an “hdf” file generated by
Nastran. (Only Results can be read from a Nastran “hdf” file.) The method has up to four
arguments:
-
1.
- A String argument that corresponds to the name of the file from which Results are read.
-
2.
- A String or an Array of Strings corresponding to the names of load cases for which
Results are imported into the DataBase. If the Array is void or the parameter is omitted,
all load cases in hdf result files are considered when results are read.
-
3.
- A String or an Array of Strings corresponding to the names of subcases for which Results
are imported into the DataBase. If the Array is void or the parameter is omitted, all
sub-cases in hdf result files are considered when results are read.
-
4.
- A String or an Array of Strings corresponding to the identifiers of Results for which
Results are imported into the DataBase. If the Array is void or the parameter is omitted,
all Results of hdf result files are considered when results are read.
All parameters, except the first one, can be omitted. Then the method assumes that a void Array has been
passed as argument.
This method is a kind of wrapper to several methods described above. If necessary, FeResPost
attaches the HDF file, imports the results into the database, and closes the attachment. If the HDF is
alread attached, no attachment/detachment is done.
The “readHdf2H” method is used to read Results from an “hdf” file generated by Nastran and
return them into an Hash object. Arguments are the same as those of “readHdf” method.
III.1.1.11.2 Managing HDF file attachments
The method “attachHdf” is used to attach an HDF file to the Nastran DataBase. This method has
up one argument: a String containing the name of the HDF file. (Full path name must be
provided.)
Several other methods are used to manage the Hdf attachments to a DataBase:
- “detachHdf” is used to delete an HDF attachment. The method has one String argument
corresponding to the name of the HDF file. (Same argument as the one used to attach the
file.)
- “removeAllHdfAttachments” removes all the HDF file attachments to a DataBase. This
method has no argument.
- “getNbrHdfAttachments” has no argument and returns the number of HDF files attached
to the DataBase.
- “getHdfAttachmentNames” has no argument and returns an Array of Strings containing
the list of HDF files attached to the DataBase.
- “checkHdfAttachmentExists” has one String argument containing the HDF file name,
and returns “True” if the HDF file is Attached to the DataBase, and “False” otherwise.
III.1.1.11.3 Extracting information from HDF file attachments
The following methods extract information related to the Results stored in an HDF file attached to the
DataBase:
- “getHdfAttachmentLcInfos” returns information on load cases and sub-cases of Results
found in the attached Hdf file. The information is returned in an Array. (More information
about the content of this Array is given in the description of method“getXdbLcInfos”.)
- “getHdfAttachmentNbrLoadCases” returns the number of load cases found in an HDF
file.
- “getHdfAttachmentLcNames” returns an Array of Strings corresponding to the load case
names found in the HDF file.
- “getHdfAttachmentLcScNames” returns an Array containing two elements. The first
element is an Array of String containing the load case names found in the HDF file. The
second element is an Array of String containing the sub-case names found in the HDF
file.
- “getHdfAttachmentLcScResNames” returns an Array of three elements. Each element is
an Array of Strings. The first element is the list of load case names. The second element
is the list of sub-case names. The last element is the list of Result names.
All these methods have a single String argument containing the name of the HDF file that must have been
previously attached to the DataBase. On the other hand, the following methods have one or two
arguments:
- “getHdfAttachmentNbrSubCases” returns the number of sub-cases found in an HDF file.
- “getHdfAttachmentScNames” returns an Array of Strings corresponding to the sub-case
names found in the HDF file.
- “getAttachmentNbrResults” returns the number of Result names identified in the HDF
attached file.
- “getHdfAttachmentResIds” returns an Array of Integers corresponding to the identifiers
of the Results found in the HDF file.
- “getHdfAttachmentResNames” returns an Array of Strings corresponding to the names
of the Results found in the HDF file.
The first argument is the name of the HDF file that must have been previously attached to the DataBase.
The second argument is optional and corresponds to the name of a load case found in the attached
HDF file. If the argument is not provided, all the load cases are investigated to build the list of
sub-cases or Result names or IDs. If the argument is provided, only the sub-cases or Results of the
corresponding load case are considered. If the provided load case does not exist in HDF attachment an
error message is issued.
III.1.1.11.4 Extracting Results From HDF file attachments
Two methods are used to extract results from Nastran HDF files:
- Method “readHdfAttachmentResults” is used to read Results from the HDF file. Results
are stored in the NastranDb object.
- Method “getHdfAttachmentResults” is used to read Results from the HDF file. Results
are returned in a Hash object.
The two methods have up to four arguments:
-
1.
- A String corresponding to the name of HDF file attachment from which Results are read.
(This file must have been previously attached to the DataBase.)
-
2.
- A String or an Array of Strings corresponding to the names of load cases for which
Results are read.
-
3.
- A String or an Array of Strings corresponding to the names of sub-cases for which Results
are read.
-
4.
- A String or an Array of Strings corresponding to the names of Results for which Results
are read.
One lists below valid calls to “getHdfAttachmentResults”:
h=db.getHdfAttachmentResults(hdfName,lcNames,scNames,resNames)
h=db.getHdfAttachmentResults(hdfName,lcNames,scNames)
h=db.getHdfAttachmentResults(hdfName,lcNames)
h=db.getHdfAttachmentResults(hdfName)
Similar calls work for “readHdfAttachmentResults” method:
db.readHdfAttachmentResults(hdfName,lcNames,scNames,resNames)
db.readHdfAttachmentResults(hdfName,lcNames,scNames)
db.readHdfAttachmentResults(hdfName,lcNames)
db.readHdfAttachmentResults(hdfName)
When one of the “lcNames”, “scNames” or “resNames” is missing, nil or an empty Array, all the load
cases, sub-cases or result types are read.
III.1.1.11.5 Raw access to HDF Datasets
Several methods can be used to obtain a “raw” access to Nastran HDF Datasets:
- “getHdfAttachmentDataSets” produces a list of Dataset paths in a given HDF attachment.
The method has one String argument corresponding to the path to attachment. It return
an Array of Strings, each String corresponding to the path to corresponding Dataset in
HDF file.
- “getHdfAttachmentCompoundMemberNames”
returns an Array of Strings corresponding to the column names of a Compound Dataset.
The Dataset is referred to by the two String arguments correspond to attachment path
and Dataset path respectively. (Of course the Dataset referred to must be of “Compound”
type for the method to work.)
- “getHdfAttachmentDataSetNbrItems” returns the number of items (or lines) in a Dataset.
The Dataset is referred to by the two String arguments correspond to attachment path and
Dataset path respectively.
- “each_hdfAttachmentNasSetItem” iterates on a Compound Dataset items. The method has 2 or
4 arguments:
-
1.
- “HdfPath”, a String correspond to the path associated to HDF attachment.
-
2.
- “DataSetPath”, a String correspond to the Dataset path in HDF attachment.
-
3.
- “IPosMin”, the index of the first item to be iterated to in DataSet.
-
4.
- “IPosMax”, the index of the last item to be iterated to in DataSet.
For each item found in Dataset, the iterator returns an Array containing the values in each
column of the corresponding Compound object. If arguments “IPosMin” and “IPosMax” are
omitted, one iterates on all the items of the Dataset.
- “getHdfAttachmentDataSet” returns an Array corresponding to items read from a Dataset. Each
element of the Array corresponds to an Array that contains the values of the corresponding item.
(=Array returned by “each_hdfAttachmentNasSetItem” iterator.) The method has the same
arguments as the iterator.
Remarks:
- The two last methods are no general HDF5 Compound Dataset reader. They have been
tested for Nastran Datasets and can only be expected to work for Nastran HDF5 files.
- User does not need to specify how the items being read must be translated into objects of
the language he is using, as has been done with WDB raw iterators in section III.1.1.10.7.
This is because each HDF Compound Dataseets also contains a description of data
storage.