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.


    odb_Set& center = instance.nodeSets()["PUNCH"];
    odb_FieldOutput& fieldU = lastFrame.fieldOutputs()["U"];
    odb_FieldOutput centerDisp = fieldU.getSubset(center);
    const odb_SequenceFieldValue& centerValues = 
        centerDisp.values();    
    const odb_FieldValue val = centerValues.value(0);
    const float* const data = val.data(numComp);
    cout << " Node: " << val.nodeLabel() << endl;
    cout << " U = ";
    for (int comp=0;comp<numComp;comp++)
      cout << data[comp] << "  ";   
    cout << endl;
 
The resulting output is
Node: 1000
U = 0.0000  -76.4555
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 the stress at integration points for CAX4 elements from the element set "CENT":

    odb_Set& topCenter = instance.elementSets()["CENT"];
    odb_Step& step2 = odb.steps()["Step-2"];
    odb_String CAX4 = "CAX4";
    odb_FieldOutput& stressField = 
        step2.frames(3).fieldOutputs()["S"];
    odb_FieldOutput fieldCAX4 = stressField.getSubset(CAX4);
    odb_FieldOutput fieldIP = 
        fieldCAX4.getSubset(odb_Enum::INTEGRATION_POINT);
    odb_FieldOutput fieldTopCenter = fieldIP.getSubset(topCenter);
    const odb_SequenceFieldValue& vals = fieldTopCenter.values();
    int valSize = vals.size();
    int dSize = 0;
    for (int l=0; l<valSize; l++) {
        const odb_FieldValue val = vals[l];
        cout << "Element label = " << val.elementLabel();
        cout << " Integration Point = " << val.integrationPoint();
        cout << endl;
        const float* const data = val.data(dSize);
	cout << " S : ";
        for (int k=0; k < dSize; k++) {
            cout << data[k] << " ";
        }
        cout << endl;
    }
 
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 enumeration for the position are:

  • INTEGRATION_POINT

  • NODAL

  • ELEMENT_NODAL

  • CENTROID

If the requested field values are not found in the output database at the specified odb_Enum::ELEMENT_NODAL or odb_Enum::CENTROID positions, they are extrapolated from the field data at the odb_Enum::INTEGRATION_POINT position.