Reading field output data

Field output data are stored in the fieldOutputs repository under the OdbFrame object. The key to the repository is the name of the variable. The following statements list all the variables found in the last frame of the first step (the statements use the variable lastFrame that we defined previously):


    odb_FieldOutputRepository& fieldOutputRep = 
        lastFrame.fieldOutputs();
    odb_FieldOutputRepositoryIT fieldIter( fieldOutputRep );
    for (fieldIter.first(); !fieldIter.isDone(); fieldIter.next())
        cout << fieldIter.currentKey().CStr() << endl;
 
S 
U
LE 
CSHEAR1  ASURF/BSURF 
CSLIP1   ASURF/BSURF 
CPRESS   ASURF/BSURF 
COPEN    ASURF/BSURF 
UR3
Different variables can be written to the output database at different frequencies. As a result, not all frames will contain all the field output variables.

You can use the following to view all the available field data in a frame:


    for (fieldIter.first(); !fieldIter.isDone(); 
    fieldIter.next()) {
     odb_FieldOutput& field = 
         fieldOutputRep[fieldIter.currentKey()];
     const odb_SequenceFieldValue& seqVal = field.values();
     const odb_SequenceFieldLocation& seqLoc = 
         field.locations();
     cout << field.name().CStr() << " : " << field.description().CStr() 
     << endl;
     cout << "    Type: " << field.type() << endl;
     int numLoc = seqLoc.size();
     for (int loc = 0; loc<numLoc; loc++){
         cout << "Position: "<<seqLoc.constGet(loc).position();
     }
     cout << endl;
    }
 

The resulting print output lists all the field output variables in a particular frame, along with their type and position.

S : Stress components
    Type: 7
    Number of fieldValues : 135
    Number of locations : 1
U : Spatial displacement
    Type: 3
    Number of fieldValues : 161
    Number of locations : 1

In turn, a FieldOutput object has a method values that returns a reference to a sequence of FieldValue objects that contain data. Each FieldValue object in the sequence corresponds to a particular location in the model. You can obtain the data corresponding to each FieldValue object using the data method, which returns a pointer to an array that contains the results at the current location. For example,


    const odb_SequenceFieldValue& displacements =
      lastFrame.fieldOutputs()["U"].values();
    int numValues = displacements.size();
    int numComp = 0;
    for (int i=0; i<numValues; i++) {
      const odb_FieldValue val = displacements[i];
      cout << "Node = " << val.nodeLabel();
      const float* const U = val.data(numComp);
      cout << ", U = ";
      for (int comp=0;comp<numComp;comp++)
	cout << U[comp] << "  ";   
      cout << endl;
    }
 

The resulting output is

Node = 1 U[x] = 0.0000, U[y] = -76.4580
Node = 3 U[x] = -0.0000, U[y] = -64.6314
Node = 5 U[x] = 0.0000, U[y] = -52.0814
Node = 7 U[x] = -0.0000, U[y] = -39.6389
Node = 9 U[x] = -0.0000, U[y] = -28.7779
Node = 11 U[x] = -0.0000, U[y] = -20.3237...

The data in the FieldValue object depend on the field output variable, which is displacement in the above example. In the example above the field output for displacements was of type NODAL and there is a FieldValue object for the output at each node. In this case the data method returns a pointer to an array containing the displacements at the node. For INTEGRATION_POINT data each integration point in an element will correspond to a different FieldValue object, and the data method will return a pointer to an array containing the element results data at that particular integration point.

Note:

Access to field data using the FieldValue object will be deprecated in future releases of the C++ version of the Abaqus Scripting Interface because of the improved performance of the bulk data access method. For more information, see FieldBulkData object, and Using bulk data access to an output database.