Computations with FieldValue objects

This example illustrates how you can use the fieldValue operators to sum and average fieldValues in a region. The example script does the following:

  • Retrieves the stress field for a specified region during the last step and frame of the output database.

  • Sums all the stress fieldValues and computes the average value.

  • For each component of stress, print the sum and the average stress.

Use the following command to retrieve the example script:

abaqus fetch job=sumRegionFieldValue

The fetch command also retrieves an input file that you can use to generate the output database that is read by the example script.

#
# fieldValue operators example problem:
#
# sum and average stress field values in a region
#

from odbAccess import *

#
# get field 
#

odb = openOdb(path='sumRegionFieldValue.odb')
endSet = odb.rootAssembly.elementSets['END1']
field = odb.steps.values()[-1].frames[-1].fieldOutputs['S']
subField = field.getSubset(region=endSet)

#
# sum values
#

sum = 0 
for val in subField.values:
   sum = sum + val
ave = sum / len(subField.values)

#
# print results
#

print('Component    Sum            Average')
labels = field.componentLabels
for i in range( len(labels) ):
    print('%s          %5.3e      %5.3e'% \
              (labels[i], sum.data[i], ave.data[i]))