Use the following command to retrieve the example program: abaqus fetch job=stressRange The fetch command also retrieves an input file that you can use to generate an output database that can be read by the example program. ////////////////////////////////////////////////////
// Code to compute a stress range from 
// all the load cases in a step.
//
// The stress range is saved to a frame with the
// description "Stress Range"
// System includes
#if (defined(HP) && (! defined(HKS_HPUXI)))
#include <iostream.h>
#else
#include <iostream>
using namespace std;
#endif
// Begin Local Includes
#include <odb_API.h>
// End Local Includes
odb_FieldOutput computeStressRange( odb_Step& step );
int ABQmain(int argc, char **argv)
{
    if( argc < 3 ) {
        cerr << "Usage: abaqus stressRange.x odb_name"
             <<         "step_name" 
             <<         endl;
        return 1;
    }
    odb_String odbName(argv[1]);
    odb_String stepName(argv[2]);
    cout << "Computing for odb \"" << odbName.CStr() << "\"";
    cout << " and step \"" << stepName.CStr() << "\"." << endl;
    // compute stress range and save to odb
    odb_Odb& odb = openOdb(odbName);
    odb_Step& step = odb.steps()[stepName];
    odb_FieldOutput range = computeStressRange(step);
    // Save the results in the output database. 
    odb_Frame rangeFrame = step.Frame(0, 0, "Stress Range");
    rangeFrame.FieldOutput(range, "S11 Range");
    odb.save();
    odb.close();
    return 0;
}
odb_FieldOutput
computeStressRange(odb_Step& step)
{
    // collect stress fields for all load cases
    odb_SequenceFieldOutput sFields;
    odb_LoadCaseRepositoryIT iter(step.loadCases());
    for( iter.first(); !iter.isDone(); iter.next() ) {
        odb_Frame frame = step.getFrame( iter.currentValue() );
        odb_FieldOutput& stressField = frame.fieldOutputs()["S"];
        sFields.append(stressField.getScalarField("S11"));
    };
    // compute maximum and minimum envelopes
    odb_SequenceFieldOutput maxFields = maxEnvelope(sFields);
    odb_SequenceFieldOutput minFields = minEnvelope(sFields);
    // compute and return range
    return (maxFields.get(0) - minFields.get(0));
}
 | |||||||