IV.2.8.3 Accessing results
We give here an example, in which CBAR element forces are read from the XDB file. This is done to
illustrate the extraction of element results. Otherwise, there is no practical use to this example, as the
corresponding extractions can be done by the “usual” XDB result extraction methods. The example is
provided in file “RUBY/EX22/recoverFBAR.rb”.
One first attempts to access the definition of load cases:
db.each_xdbRaw(xdbFileName,["SUBCASES",0],"iiiiiiii") do |tab|
puts tab
end
str="i"
(0..95).each do |i|
str+="s"
end
db.each_xdbRaw(xdbFileName,["SUBCTITL",0],str) do |tab|
STDOUT.printf("%d' n",tab[0])
(0..2).each do |j|
str=""
(1..32).each do |i|
str+=tab[32*j+i]
end
str.strip!
STDOUT.printf("%s' n",str)
end
end
The integers extracted from “SUBCASES” table correspond to sub-case integer ID, the corresponding
load ID, the SPC ID... The access to “SUBCTITL” shows how strings must be concatenated when they
correspond to several words.
The reading of CBAR forces is done as follows:
modulo=-1;
db.each_xdbRaw(xdbFileName,["FBARR",2],"iiiiiiiii") do |tab|
if (tab[0]==0) then
modulo=tab[1]
end
break;
end
db.each_xdbRaw(xdbFileName,["FBARR",2],"iffffffff") do |tab|
accessType=12
if (tab[0]>0) then
elemIntId=tab[0]/modulo
elemExtId=db.getAttachmentElementExtId(xdbFileName,accessType,elemIntId)
STDOUT.printf("%30s : %d' n","Element ID",elemExtId)
STDOUT.printf("%30s : %g' n","M bending A 1",tab[1])
STDOUT.printf("%30s : %g' n","M bending A 2",tab[2])
STDOUT.printf("%30s : %g' n","M bending B 1",tab[3])
STDOUT.printf("%30s : %g' n","M bending B 2",tab[4])
STDOUT.printf("%30s : %g' n","F shear 1",tab[5])
STDOUT.printf("%30s : %g' n","F shear 2",tab[6])
STDOUT.printf("%30s : %g' n","F axial",tab[7])
STDOUT.printf("%30s : %g' n' n","M torque",tab[8])
end
end
One must add a few explanations:
- The first call to iterator is done to access the first “void” field. This allows to identify
an integer “modulo” that is used later to calculate the element internal ID for each field.
There is a “break” statements that forces an exit from iterator loop once the modulo has
been identified.
- Then, one calls the iterator a second time to perform the “real” reading of element results.
Note that the string “translation” argument is not the same.
- The definition of the translation string has been done by trials and errors. The reading
of Nastran documentation may help (for example the structure of OP2 data blocks in
Nastran DMAP manual [Rey04]) to understand the output, but there is no detailed
description of XDB file content in MSC.Access documentation. This is true for results
tables, as well as for FEM description tables.
- For the “real” reading, one skips the “modulo” part.
- The element access type is set to 12 as one extracts forces on CBAR elements.
- The element internal ID is obtained by dividing key by the modulo.
- Method “getAttachmentElementExtId” is used to obtain the element external ID (Nastran
element ID).