Since version 3.5.0, FeResPost allows a random access to DES/FAC result files. This method is more efficient than the methods that import Results into the DataBase, and extracting copies of these Results. A particular case in which the random access methods will be more efficient is when only some small parts of the Result file are of interest to the programmer.
The principle of random access is as follows:
The DES/FAC file is attached to the DataBase.
Its content (lists of load cases, sub-cases, Results...) is identified.
The Results that are needed are then read from the file.
The different methods called to perform these operations are described in the following sub-sections.
Note that the content of DES file is read only when the DES/FAC files are attached to the DataBase. After that, the DES file is closed. This is why when information is extracted from a particular attachment, the attachment is identified by the name of the FAC file.
The method “attachDesFac” is used to attach a DES/FAC file to the Samcef DataBase. This method has between two and four arguments:
A String containing the name of the DES file. (Full path name must be provided.)
A String containing the name of the FAC file. (Full path name must be provided.)
An integer or an Array of integers identifying load cases.
A String or an Array of Strings corresponding to the names that are attributed to the load cases and which shall be used to retrieve corresponding Results.
The arguments 3 and 4 are optional. They correspond to arguments 3 and 4 of the “readDesFac” method discussed in section III.2.1.4.
Several other methods are used to manage the DES/FAC attachments to a DataBase:
“detachDesFac” is used to delete an attachment. The method has one String argument corresponding to the name of the FAC file.
“removeAllAttachments” removes all the attachments to a DataBase. This method has no argument.
“getNbrAttachments” has no argument and returns the number of DES/FAC files attached to the DataBase.
“getAttachmentNames” has no argument and returns an Array of Strings containing the list of FAC files attached to the DataBase.
“checkAttachmentExists” has one String argument containing the FAC file name, and returns “True” if the FAC file is Attached to the DataBase, and “False” otherwise.
The following methods extract information related to the Results stored in DES/FAC files attached to the DataBase:
“getAttachmentLcInfos” returns information on load cases and sub-cases of Results found in the DataBase. The information is returned in an Array. (Format of returned Array is described in chapter III.1.)
“getAttachmentNbrLoadCases” returns the number of load cases found in an attachment.
“getAttachmentLcNames” returns an Array of Strings corresponding to the load case names found in an attachment.
“getAttachmentLcScNames” returns an Array containing two elements. The first element is an Array of String containing the load case names found in the FAC file. The second element is an Array of String containing the sub-case names found in the FAC file.
“getAttachmentLcScResNames” 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.
“getAttachmentNbrLayers” returns the number of layers identified in an attachment.
“getAttachmentLayerIds” returns an Array of Integers corresponding to the identifiers of the layers found in an attachment.
“getAttachmentLayerNames” returns an Array of Strings corresponding to the names of the layers found in an attachment.
“getAttachmentNbrSubLayers” returns the number of sub-layers identified in an attachment.
“getAttachmentSubLayerIds” returns an Array of Integers corresponding to the identifiers of the sub-layers found in an attachment.
“getAttachmentSubLayerNames” returns an Array of Strings corresponding to the names of the sub-layers found in an attachment.
All these methods have a single String argument containing the name of the FAC file that must have been previously attached to the DataBase. On the other hand, the following methods have one or two arguments:
“getAttachmentNbrSubCases” returns the number of sub-cases found in an attachment.
“getAttachmentScNames” returns an Array of Strings corresponding to the sub-case names found in an attachment.
“getAttachmentNbrResults” returns the number of Result names identified in an attachment.
“getAttachmentResIds” returns an Array of Integers corresponding to the identifiers of the Results found in an attachment.
“getAttachmentResNames” returns an Array of Strings corresponding to the names of the Results found in an attachment.
The first argument is the name of the FAC 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 FAC 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 FAC attachment an error message is issued.
The method “getAttachmentResults” is used to read Results from the FAC file. The Results are directly returned by the method to the caller. They are not inserted in the DataBase from which the method is called.
The method has minimum four arguments:
A String corresponding to the name of FAC file attachment from which Results are read. (This file must have been previously attached to the DataBase.)
A String corresponding to the name of the load case for which Results are read.
A String or an Array of Strings corresponding to the names of sub-cases for which Results are read.
A String or an Array of Strings corresponding to the names of Results for which Results are read.
The other arguments are optional and correspond to the specification of target entities for which Results are read. Actually, the reading operation from a FAC file combines the reading and some of the extraction operations described in section I.4.3. For example:
The fifth argument can be a ResKeyList object. Then the Results are extracted on the keys of the ResKeyList object.
The fifth argument can be a Result object. Then the Results are extracted on the keys of the Result object.
Extractions can be performed on Groups. Then one specifies the target by a “Method” String argument and a “GrpTarget” Group argument. The possible values of the “Method” argument are listed in section I.4.3.1. (Description of “extractResultOnEntities” method in the Result class.) When Results are extracted on Groups, one can also specify list of layers and sub-layers for which values are extracted. This argument is optional. (See below.)
One can also specify a list of layers by providing a parameter which is an Array of String or Integer values. Note however that the filtering on layers is done only when Results for which several layers can be read. For example, this parameter does not influence the reading of MPC Forces, Shell Forces...
One can also specify a list of sub-layers by providing a parameter which is an Array of String or Integer values. Note that this last parameter influences only the reading of laminate stresses or strains. The reading of solid or shell element stresses and strains is not affected by this parameter.
One can extract Results without specifying the ResKeyList, Result or Group argument. However, it is still possible to specify a list of layers, a list of sub-layers, and a location to filter the values that are inserted in Results. The “Location” argument corresponds to the “Method” argument when Results are extracted on Groups. Possible values of this parameter are “Elements”, “ElemCenters", “ElemCorners”...
Only lists below the list of valid calls to “getAttachmentResults”:
h=db.getAttachmentResults(facName,lcName,scNames,resNames, method,grpTarget[,layers[,subLayers]]) h=db.getAttachmentResults(facName,lcName,scNames,resNames, resTarget) h=db.getAttachmentResults(facName,lcName,scNames,resNames, rklTarget) h=db.getAttachmentResults(facName,lcName,scNames,resNames [,layers[,sub-Layers[,location]]])
As several Result types, and sub-case names can be given as argument to “getAttachmentResults” method, this method can return several Results. This is why Results are returned in a Hash:
The Hash keys are Array of three Strings corresponding to the name of the load case, the name of the sub-case, and the Result type name respectively.
The Hash values are the Results.
For example, the list of extracted Result sizes can be printed with the following statements:
h=db.getAttachmentResults(facName,lcName,scNames,resNames,"Nodes",grp)
h.each do |id,res|
lcName=id[0]
scName=id[1]
resName=id[2]
size=res.Size
STDOUT.printf("%s - %s - %s : %d\n",lcName,scName,resName,size)
#~ Util::printRes(STDOUT,"brol",res)
end
The method “getAttachmentResultsCombili” is used to extract linear combinations of elementary Results found in one or several attached FAC files. As for method “getAttachmentResults” the Results are directly returned by the method to the caller. They are not inserted in the DataBase from which the method is called. This method is more or less a combination of the methods “getAttachmentResults” and “buildLoadCasesCombili” of the generic DataBase class.
Practically, the main difference between “getAttachmentResults” and “getAttachmentResultsCombili” is that the first argument is no longer a FAC file name. This argument is removed. Instead, one provides a “Combili” argument that describes the linear combination corresponding to extracted Results. This “Combili” argument is the second argument. The first argument is the “LcName” argument corresponding to the load case name attributed to the generated Results. This load case name is not supposed to correspond to any load case name found in the attached FAC file(s).
The method has minimum four arguments:
A String corresponding to the name of the load case for which Results are read.
A “Combili” Array containing the description of the linear combination of elementary load case Results. The Array is an Array of Arrays. Each secondary Array contains three elements:
A Real value corresponding to the factor in the linear combination.
A String corresponding to the name of the FAC file from which elementary Results are read. This file must have been previously attached to the Samcef DataBase.
A String corresponding to the name of the load case for which Results are extracted.
A String or an Array of Strings corresponding to the names of sub-cases for which Results are read.
A String or an Array of Strings corresponding to the names of Results for which Results are read.
The other arguments are optional and correspond to the specification of target entities for which Results are read. Actually, the reading operation from a FAC file combines the reading and some of the extraction operations described in section I.4.3. For example:
The fifth argument can be a ResKeyList object. Then the Results are extracted on the keys of the ResKeyList object.
The fifth argument can be a Result object. Then the Results are extracted on the keys of the Result object.
Extractions can be performed on Groups. Then one specifies the target by a “Method” String argument and a “GrpTarget” Group argument. The possible values of the “Method” argument are listed in section I.4.3.1. (Description of “extractResultOnEntities” method in the Result class.)
One can also specify a list of layers by providing a parameter which is an Array of String or Integer values.
One can also specify a list of sub-layers by providing a parameter which is an Array of String or Integer values.
One can extract Results without specifying the ResKeyList, Result or Group argument. However, it is still possible to specify a list of layers, a list of sub-layers, and a location to filter the values that are inserted in Results. The “Location” argument corresponds to the “Method” argument when Results are extracted on Groups. Possible values of this parameter are “Elements”, “ElemCenters", “ElemCorners”...
Only lists below the list of valid calls to “getAttachmentResultsCombili”:
h=db.getAttachmentResultsCombili(lcName,combili,scNames,resNames, method,grpTarget,layers) h=db.getAttachmentResultsCombili(lcName,combili,scNames,resNames, method,grpTarget) h=db.getAttachmentResultsCombili(lcName,combili,scNames,resNames, resTarget) h=db.getAttachmentResultsCombili(lcName,combili,scNames,resNames, rklTarget) h=db.getAttachmentResultsCombili(lcName,combili,scNames,resNames, layers) h=db.getAttachmentResultsCombili(lcName,combili,scNames,resNames)
The Hash object returned by the method has a structure identical to the one returned by “getAttachmentResults” and can be manipulated the same way.
In order to reduce the number of accesses to disk, it may be useful to store some of the blocks read from binary result files into memory. FeResPost provides an algorithm that allows to store the blocks most recently read for later usage. Two singleton methods of the “SamcefDb” class allow the to tune the capacity of the buffer area:
“setStorageBufferMaxCapacity” sets the capacity of storage. The method has one arguments: a real value containing the size in Megabytes of the buffer.
“getStorageBufferMaxCapacity” returns the storage buffer current total capacity. The returned value is a real that corresponds to the capacity in Megabytes of the buffer. The method has no argument.
Note that all buffers are now common to all the methods that provide random access to XDB and FAC result files. In particular, the method is used in management of the binary file access for XDB and FAC attachment or reading. This means that if one Result file attached to one DataBase is more used, the storage will contain a majority of buffers for this Result file and progressively delete the other buffers.
The default capacity for storage buffer is 0Mb. Note that the two methods described above can be called from any class derived from the generic “DataBase” class.