Using regions to read a subset of field output
data
After you have created an OdbSet object using model data, you can use
the getSubset method to read only the data
corresponding to that region. Typically, you will be reading data from a region that refers
to a node set or an element set. For example, the following statements create a variable
called center that refers to the node set
PUNCH at the center of the hemispherical punch. In a
previous section you created the displacement variable that
refers to the displacement of the entire model in the final frame of the first step. Now you
use the getSubset command to get the displacement for only
the center
region.
center = odb.rootAssembly.instances['PART-1-1'].nodeSets['PUNCH']
centerDisplacement = displacement.getSubset(region=center)
centerValues = centerDisplacement.values
for v in centerValues:
print(v.nodeLabel, v.data)
The resulting output
is
1000 array([0.0000, -76.4555], 'd')
The
arguments to getSubset are a region, an element
type, a position, or section point data. The following is a second example that uses an
element set to define the region and generates formatted output. For more information
on tuples, the len() function, and the
range() function, see Sequences and Sequence operations.
topCenter = \
odb.rootAssembly.instances['PART-1-1'].elementSets['CENT']
stressField = odb.steps['Step-2'].frames[3].fieldOutputs['S']
# The following variable represents the stress at
# integration points for CAX4 elements from the
# element set "CENT."
field = stressField.getSubset(region=topCenter,
position=INTEGRATION_POINT, elementType = 'CAX4')
fieldValues = field.values
for v in fieldValues:
print('Element label = ', v.elementLabel)
if v.integrationPoint:
print('Integration Point = ', v.integrationPoint)
else:
print()
# For each tensor component.
for component in v.data:
# Print using a format. The comma at the end of the
# print statement suppresses the carriage return.
print('%-10.5f' % component)
# After each tuple has printed, print a carriage return.
print()
The resulting output
is
Element label = 1 Integration Point = 1
S : 0.01230 -0.05658 0.00892 -0.00015
Element label = 1 Integration Point = 2
S : 0.01313 -0.05659 0.00892 -0.00106
Element label = 1 Integration Point = 3
S : 0.00619 -0.05642 0.00892 -0.00023
Element label = 1 Integration Point = 4
S : 0.00697 -0.05642 0.00892 -0.00108
Element label = 11 Integration Point = 1
S : 0.01281 -0.05660 0.00897 -0.00146
Element label = 11 Integration Point = 2
S : 0.01183 -0.05651 0.00897 -0.00257
Element label = 11 Integration Point = 3 ...
Possible values for the position argument to the
getSubset command are:
INTEGRATION_POINT
NODAL
ELEMENT_NODAL
CENTROID
If the requested field values are not found in the output database at the
specified ELEMENT_NODAL or CENTROID
positions, they are extrapolated from the field data at the
INTEGRATION_POINT position.