Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations IDS on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Creating new Field in ODB File

Status
Not open for further replies.

mika3049

Materials
Nov 4, 2016
17
Hi,
I am trying to create new field in ODB file. But for testing purpose, I just decided to read "old" stress field and re-create it as new one. So, I read S23 from ODB, create array (Element label, time, stress 23), and create new Field with the same values.
When I print out the values (Elt number, Stress), I have the same values.
But the contours look different.

Can anyone help?

Leon
#Opening ODB
odb = openOdb(path='out34.odb')
step1 = odb.steps['Step-1']
frames = odb.steps['Step-1'].frames
numFrames = len(frames)
lastFrame = odb.steps['Step-1'].frames[-1]
myInstance = odb.rootAssembly.instances['BOX-1']
numNodes = len(myInstance.nodes)
numElements = len(myInstance.elements)
# Nodes and elements
N = myInstance.nodes
EL = myInstance.elements
#-Creating Array of 3 columns: Ti
ncolum=3
strehi=np.empty((ncolum, numElements*numFrames), dtype=object)
Nums=0.
for x in odb.steps['Step-1'].frames:Element No, Step Time, Stress S23
currentsteptime = x.frameValue
print ' Time/Incr is ', currentsteptime, x.incrementNumber
stress=x.fieldOutputs['S'].getSubset(position=CENTROID)
maxstr=0.
nustr=0.
for S in stress.values:
strehi [1, Nums*numElements+nustr]=currentsteptime
strehi [0, Nums*numElements+nustr]=S.elementLabel
s11=S.data[0]
s13=S.data[5]
strehi [2, Nums*numElements+nustr]=s23
nustr=nustr+1
Nums=Nums+1
# Adding new Field to ODB
field1 = lastFrame.FieldOutput(name='Mgu04', description='none', type=SCALAR)
elmdata=()
elmNo=[]
elmdata=[(strehi [2, index],) for index in range(numElements*(numFrames-1), numElements*numFrames)]
for index in range(numElements):
ind2=index+numElements*(numFrames-1)
elmNo.append(index+1)
val2=strehi [2, ind2]
field1.addData(position=CENTROID, instance=myInstance, labels=elmNo, data=elmdata)
 
Replies continue below

Recommended for you

Make a small example, check that the script is running with that example and then post the two files.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor