The first example illustrates different versions of the call to “readBdf” method:
require "FeResPost"
include FeResPost
# Creates and initializes the DataBase :
db=NastranDb.new()
db.Name="tmpDB1"
db.readBdf("../../MODEL/MAINS/unit_xyz.bdf")
The first call to “readBdf” is the default instruction used to read the Bulk file in most examples.
A second bdf read operation is performed as follows:
db=NastranDb.new()
db.Name="tmpDB2"
begin
db.readBdf("unit_xyz_V1.bdf",[],"bdf",{},true)
rescue Exception => x then
printf ("\n\nMaybe you should modify the two first include statements in main file!\n")
printf ("**********************************************************************\n\n")
raise x
end
The revised version reads main file “unit_xyz_V1.bdf” that illustrates several possible interpretation of the “include” statements in Nastran Bulk Data Files. The user must uncomment the corresponding statement, and modify the absolute paths in the include statements of “unit_xyz_V1.bdf” file. (The “begin” and “rescue” statements have been added to remind the user of this necessary modification. An error message is issued if the reading fails.)
Include statement in the data file look as follows:
include ’/home/ferespost/Documents/FERESPOST/TESTSAT/ MODEL/MESH/coordSys.bdf’ include /home/ferespost/Documents/FERESPOST/ , TESTSAT/MODEL/MATS/mats.bdf include ’../../MODEL/PROPS/props.bdf’ $ include ../../MODEL/MESH/elemNodes_pan_MX.bdf include ../../MODEL/MESH/elemNodes_pan_MY.bdf include ../../MODEL/MESH/elemNodes_pan_MZ.bdf include ../../ MODEL/MES H/elemNod es_pan_PX.bdf include ../../MODEL/MESH/ elemNodes_pan_PY.bdf
The example is given in file “RUBY/EX01/readBdf.rb”.
Another version of the example is given in file “RUBY/EX01/readBdf_V2.rb”. It illustrates the reading of Bulk Data Files containing include statements in which symbols are used. In that example, the call to “readBdf” looks as follows:
symbols=Hash.new
symbols["INCDIR"]="../../MODEL"
db=NastranDb.new()
db.Name="tmpDB2"
db.readBdf("unit_xyz_V2.bdf",[],"bdf",symbols,true)
The variable “symbols” is a Hash containing the list of symbols that must be substituted in the include statements. (Only one symbol is defined in this case.) The include statements of the BDF file look as follows:
include INCDIR:/MESH/elemNodes_pan_MX.bdf include INCDIR:/MESH/elemNodes_pan_MY.bdf include INCDIR:/MESH/elemNodes_pan_MZ.bdf include ../../ MODEL/MES H/elemNod es_pan_PX.bdf include INCDIR:/MESH/ elemNodes_pan_PY.bdf
The example “readBdf_V3” proposes a slightly more complicated case of file inclusions in a main BDF.
Example “readBdf_V7” illustrates several functions allowing the manipulation of the database FEM entities. A list of Nastran cards corresponding to the FEM definition is build as follows:
cards=[]
db.each_coordSysId do |id|
cards << db.fillCard("CoordSys",id)
end
db.each_nodeId do |id|
cards << db.fillCard("Node",id)
end
db.each_elemId do |id|
cards << db.fillCard("Element",id)
end
db.each_rbeId do |id|
cards << db.fillCard("RBE",id)
end
db.each_materialId do |id|
cards << db.fillCard("Material",id)
end
db.each_propertyId do |id|
cards << db.fillCard("Property",id)
end
Then, one builds a new database using these cards:
db3=NastranDb.new() db3.Name="tmpDB3" db3.insertCards(cards);
Finally, one checks the content of the new database:
db3.writeBdfLines("out.bdf","w","left","short","All");
vectStr=NastranDb.writeNastranCardsToVectStr("left","short",cards);
vectStr.each do |line|
puts line
end
Example “readBdf_V8” illustrates the reading of a model by several calls to “readBdf” methods:
db.readBdf("D:/SHARED/FERESPOST/TESTSAT/MODEL/MESH/coordSys.bdf",nil,nil,nil,true,true)
db.readBdf("D:/SHARED/FERESPOST/TESTSAT/MODEL/MATS/mats.bdf",nil,nil,nil,true,true)
db.readBdf("../../MODEL/PROPS/props.bdf",nil,nil,nil,true,true)
...
db.readBdf("../../MODEL/FIXAS/launch.bdf",nil,nil,nil,true,true)
db.readBdf("../../MODEL/LOADS/unit_accel.bdf",nil,nil,nil,true,true)
This approach can be used to modify finite element model stored in a database during script execution.
Example “readBdf_V9” illustrates additional capabilities for the reading of BDF files. In particular, cards in free format are added to file “unit_xyz_V9.bdf” to test FeResPost capabilities. You can verify the effect of parameters like params["STRICTUAI"]="1" on the reading of following card:
CHEXA,200, 200, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20
Two examples present the possibility of iterating on items read from BDF files. The first example uses method “each_bdfCard” and can be used to recover the BDF cards read from one or several BDF files (includes are managed by the method). The part of interest is as follows:
NastranDb.each_bdfCard("../../MODEL/MAINS/unit_xyz.bdf") do |crd|
counter=0
crd.each do |x|
if counter==0 then
printf("%8s : ",x)
else
if x.class==String then
printf("%12s",x)
elsif x.class==Fixnum then
printf("%12d",x)
elsif x.class==Float then
printf("%12g",x)
end
end
counter+=1
end
puts
end
The second example is a little more complex. The iterator “each_bdfCard2” returns more than the BDF card. The printing of information returned by this iterator should help the reader understanding the format of items:
NastranDb.each_bdfCard2(bdfPath,nil,nil,nil,false) do |typeName,card,lines|
counter=0
printf("\"%s\"\n",typeName)
case typeName
when "CARD" then
card.each do |x|
if counter==0 then
printf("%8s : ",x)
else
if x.class==String then
printf("%12s",x)
elsif x.class==Fixnum then
printf("%12d",x)
elsif x.class==Float then
printf("%12g",x)
end
end
counter+=1
end
printf("\n")
when "INCLUDE" then
printf(" %s --> %s\n",card[1],card[2])
when "EQUALS" then
printf(" \"%s\" = \"%s\"\n",card[1],card[3])
else
# Nothing ...
end # case typeName ...
printf("LINES:\n")
lines.each do |fileName,lineNumber,lineStr|
printf(" %s --- %d --- \"%s\"\n",fileName,lineNumber,lineStr)
end
puts
end
You can verify the effect of parameters like params["STRICTUAI"]="1" on the reading of following card:
CHEXA,200, 200, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20
The two examples are provided in files “RUBY/EX01/scanBdfCards.rb” and “RUBY/EX01/scanBdfCards2.rb”. The examples can be run on different BDF files. The BDF file “RUBY/EX01/testSat_scanBdfCards2.bdf” contains different examples of BDF cards in free format.