A Python script for the extraction of results from a Nastran XDB file

Purpose of the script

The script illustrates the extraction of Nastran results from an XDB file with the FeResPost Python extension.

Script

Python
import sys
sys.stdout=open(__file__+".log", 'w')

from FeResPost import *
import sys

sys.path.insert(0, '../UTIL')
import Util

# Creates and initializes the DataBase :

db=NastranDb()
db.Name="tmpDB"
db.readBdf("../../MODEL/MAINS/unit_xyz.bdf")
db.readGroupsFromPatranSession("../../MODEL/PATRAN/groups.ses")

# Reading or generating Results :

xdbFileName="../../MODEL/EXEC_XDB/unit_xyz.xdb"
db.attachXdb(xdbFileName)

infos=db.getAttachmentLcInfos(xdbFileName)
for tab in infos:
    sys.stdout.write("%-20s %-25s %-6d %-6d %-15g %-15g\n"%(tab[0],tab[1],tab[3],tab[4],tab[5],tab[6]))

resNames=db.getAttachmentResNames(xdbFileName)
for resName in resNames:
    sys.stdout.write("%-20s\n"%(resName))

lcName="LAUNCH_ONE_MS2_Y"
scName="Statics"
resNames=[]
resNames.append("Shell Forces")
resNames.append("Shell Moments")
resNames.append("Strain Tensor")
resNames.append("Curvature Tensor")

location="ElemCenters"
grp=db.getGroupCopy("pan_MZ")

results=db.getAttachmentResults(xdbFileName,lcName,scName,resNames,location,grp,["NONE"])
for key,res in results.iteritems():
    Util.printRes(sys.stdout,key[0]+" ==> "+key[2],res)

key=tuple([lcName,scName,"Shell Moments"])
shMoments=results[key]
key=tuple([lcName,scName,"Shell Forces"])
shForces=results[key]
key=tuple([lcName,scName,"Strain Tensor"])
shAvrgStrains=results[key]
key=tuple([lcName,scName,"Curvature Tensor"])
shCurvatures=results[key]

Util.printRes(sys.stdout,key[0]+" ==> "+key[2],shMoments)

Explanation

The different steps of the script are:

References

More information on this example, and on the functions it uses, is given in the FeResPost User Manual.

← Back to the examples