One presents here several examples illustrating the manipulation of Groups in FeResPost. They show how the Groups defined in the DataBase can be inspected, and how new Groups can be constructed and added to the DataBase.
It shows how it is possible to obtain the list of Groups contained in a DataBase. This may be useful if one wants to check whether all Groups read from a session file have been correctly integrated in the DataBase. The ruby program looks like:
# Creates and initializes the DataBase :
db=NastranDb.new()
db.Name="tmpDB"
db.readBdf("../../MODEL/MAINS/unit_xyz.bdf")
db.readGroupsFromPatranSession("../../MODEL/PATRAN/groups.ses")
# Prints all the group names :
puts db.getAllGroupNames()
The last line performs the printing of the names of all Groups contained in the DataBase. The other lines are for DataBase creation and initialization.
The example is given in file "RUBY/EX02/printGroupNames.rb".
In the previous example one simply printed the list of the names of Groups contained in a DataBase. In this new examples, information is also printed on the content of each Group. Practically, this is done as follows:
One initializes the DataBase “as usual”.
One loops on the list of Group names stored in the DataBase, and for each groupName:
One gets a copy of the Group stored in the DataBase.
For the four types of entities, the entities are retrieved. In fact, only the respective sizes of the Arrays returned by the call to “getEntitiesByType”.
Finally, one prints the result (formatted print).
The program looks like this:
# Creates and initializes the DataBase :
db=NastranDb.new()
db.Name="tmpDB"
db.readBdf("../../MODEL/MAINS/unit_xyz.bdf")
db.readGroupsFromPatranSession("../../MODEL/PATRAN/groups.ses")
# Prints Groups’ data :
printf("%20s%10s%10s%10s%10s\n","groupName","Nodes",\
"Elements","RBEss","CoordSys")
db.each_groupName do |groupName|
grp = db.getGroupCopy(groupName)
nodesNbr = grp.NbrElements
elementsNbr = grp.NbrNodes
rbesNbr = grp.NbrRbes
coordNbr = grp.NbrCoordsys
printf("%20s%10d%10d%10d%10d\n",groupName,nodesNbr,\
elementsNbr,rbessNbr,coordNbr)
end
The example is given in file "RUBY/EX02/printGroups.rb".
The third example prints Groups defined in a Patran session file without importing them into a DataBase. Groups are directly read into a Hash object with the following statement:
h=Post.readGroupsFromPatranSession("../../MODEL/PATRAN/groups.ses")
Then, for each Group, the entities are printed as lists of integer. One shows below how it is done for the nodes:
nbrEntitiesPerLine=8
h.each do |id,grp|
os.printf("Group \"%s\":\n\n",id)
...
nbr=grp.getNbrEntitiesByType("Node")
os.printf(" Nbr Nodes: %d",nbr)
counter=0
grp.each_node do |id|
if (counter%nbrEntitiesPerLine==0) then
os.printf("\n ")
end
os.printf("%8d",id)
counter+=1
end
os.printf("\n\n")
...
end
The example is given in file "RUBY/EX02/writeGroupEntities.rb".