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. |