IV.2.8.4 Producing a “clean” model from topometric optimization
We provide here an example where modeling information is read from the XDB file. The modeling
information corresponds to the last output of a topometric optimization. The purpose of the script is to
produce a “clean” FEM corresponding to the topometric optimization. The example is given in
“RUBY/EX22/recoverTopometricModel.rb”.
The reading of PSHELL cards is done as follows:
pshellCards={}
db.each_xdbRaw(xdbFileName,["PSHELL",49],"iifififfffi") do |tab|
card=[]
card << "PSHELL"
(0...10).each do |i|
if (tab[i].class==Float&&tab[i].nan?) then
card << ""
else
card << tab[i]
end
end
if (tab[10]==0) then
card << ""
else
card << tab[10]
end
pshellCards[tab[0]]=card
end
Remark that:
- The XDB file contains in this case 50 “PSHELL” tables because one outputs the results
of all optimization steps. One reads only the last “PSHELL” table. (Its index is 49 as the
numbering starts with 0.)
- Here again, the identification of “real” and “integer” values has been done by trials and
errors. (If you print the translated values in an output file, you see easily if you have made
an error.)
- A similar reading is done in for the CQUAD4 elements.
- Also, if you print the PSHELL cards, you will discover the for a topometric optimization,
Nastran generates a very large number of PSHELL cards. (One card per element in the
group of topometric optimization.) In our example, the numbering of the newly generated
cards starts with 1000000.
- The CQUAD4 elements that are read refer to the new generated property IDs.
In the rest of the script, one generates renumbered PSHELL cards. Each PSHELL PID will be the same as
the element ID of the CQUAD4 that refers to the property. The CQUAD4 elements are modified
accordingly. The new Nastran cards are output in “newModel.bdf” file, and a GMSH file
corresponding to the modified thicknesses is output:
outputCards=[]
propRemap={}
elemIds=cquad4Cards.keys.sort
elemIds.each do |elemId|
elemCard=cquad4Cards[elemId].clone
propId=elemCard[2]
if propId>1000000 then
elemCard[2]=elemId
propRemap[propId]=elemId
end
outputCards << elemCard[0..7]
end
propIds=pshellCards.keys.sort
res=Result.new
res.TensorOrder=0
res.Format=1
propIds.each do |propId|
propCard=pshellCards[propId].clone
if propRemap.has_key?(propId) then
propCard[1]=propRemap[propId]
res.insert([propCard[1]],["NONE",propCard[3]])
end
outputCards << propCard[0..8]
end
NastranDb::writeNastranCards("newModel.bdf","w","right","short",outputCards)
#~ Util::printRes($stdout,"brol",res)
db.writeGmsh("thicknesses.gmsh",0,[[res,"thickness","ElemCenters"]])
Note that the example could be improved. For example, you could also consider the CTRIA3
elements in the model generation.