========================================================= Example programs that access data from an output database ========================================================= The following examples illustrate how you use the output database commands to access data from an output database. Finding the maximum value of von Mises stress --------------------------------------------- This example illustrates how you can iterate through an output database and search for the maximum value of von Mises stress. The program opens the output database specified by the first argument on the command line and iterates through the following: - Each step. - Each frame in each step. - Each value of von Mises stress in each frame. In addition, you can supply an optional assembly element set argument from the command line, in which case the program searches only the element set for the maximum value of von Mises stress. The following illustrates how you can run the example program from the system prompt. The program will search the element set ALL ELEMENTS in the viewer tutorial output database for the maximum value of von Mises stress: .. code-block:: sh abaqus odbMaxMises.exe -odb viewer_tutorial.odb -elset "ALL ELEMENTS" .. note:: If a command line argument is a String that contains spaces, some systems will interpret the String correctly only if it is enclosed in double quotation marks. For example, "ALL ELEMENTS". You can also run the example with only the **-help** parameter for a summary of the usage. Use the following commands to retrieve the example program and the viewer tutorial output database: .. code-block:: cpp // abaqus fetch job=odbMaxMises.C // abaqus fetch job=viewer_tutorial /*************************************************************** odbMaxMises.C Code to determine the location and value of the maximum von-mises stress in an output database. Usage: abaqus odbMaxMises -odb odbName -elset(optional) elsetName Requirements: 1. -odb : Name of the output database. 2. -elset : Name of the assembly level element set. Search will be done only for element belonging to this set. If this parameter is not provided, search will be performed over the entire model. 3. -help : Print usage ****************************************************************/ #if (defined(HP) && (! defined(HKS_HPUXI))) #include #else #include using namespace std; #endif #include #include /* *************** utility functions *************** */ bool fileExists(const odb_String &string); void rightTrim(odb_String &string,const char* char_set); void printExecutionSummary(); /***************************************************************/ int ABQmain(int argc, char **argv) { odb_String odbPath; bool ifOdbName = false; odb_String elsetName; bool ifElset = false; odb_Set myElset; odb_String region = "over the entire model"; char msg[256]; char *abaCmd = argv[0]; for (int arg = 0; arg maxMises) { maxMises = misesData; maxElem = elementLabels[elem]; maxStep = step.name(); maxFrame = frame.incrementNumber(); } } } } } } } if (isStressPresent) { cout << "Maximum von Mises stress " << region.CStr() << " is " << maxMises << " in element " << maxElem << endl; cout << "Location: frame # " << maxFrame << " step: " << maxStep.CStr() << endl; } else { cout << " Stress output is not available in the " << "output database : " << myOdb.name().CStr() << endl; } // close the output database before exiting the program myOdb.close(); return(0); } bool fileExists(const odb_String &string) { bool exists = false; struct stat buf; if (stat(string.CStr(),&buf)==0) exists = true; return exists; } void rightTrim(odb_String &string,const char* char_set) { int length = string.Length(); if (string.Find(char_set)==length) string.append(odb_String(char_set)); } void printExecutionSummary() { cout << " Code to determine the location and value of the\n" << " maximum von-mises stress in an output database.\n" << " Usage: abaqus odbMaxMises -odb odbName \n" << " -elset(optional), -elsetName\n" << " Requirements:\n" << " 1. -odb : Name of the output database.\n" << " 2. -elset : Name of the assembly level element set.\n" << " Search will be done only for element \n" << " belonging to this set.\n" << " If this parameter is not provided, search \n" << " will be performed over the entire model.\n" << " 3. -help : Print usage\n"; } Creating an output database --------------------------- The following example illustrates how you can use the Abaqus C++ API commands to do the following: 1. Create a new output database. 2. Add model data. 3. Add field data. 4. Add history data. 5. Read history data. 6. Save the output database. Use the following command to retrieve the example program: .. code-block:: cpp // abaqus fetch job=odbWrite //////////////////////////////////////////////////// // Code to create an output database and add model, // field, and history data. The code also reads // history data, performs an operation on the data, and writes // the result back to the output database. // // SECTION: System includes // #include // // Begin local includes // #include #include #include // // End local includes // int ABQmain(int argc, char **argv) { // Create an ODB (which also creates the rootAssembly). int n; odb_String name("simpleModel"); odb_String analysisTitle("ODB created with C++ ODB API"); odb_String description("example illustrating C++ ODB API"); odb_String path("odbWriteC.odb"); odb_Odb& odb = Odb(name, analysisTitle, description, path); // Model data: // Set up the section categories. odb_String sectionCategoryName("S5"); odb_String sectionCategoryDescription("Five-Layered Shell"); odb_SectionCategory& sCat = odb.SectionCategory(sectionCategoryName, sectionCategoryDescription); int sectionPointNumber = 1; odb_String sectionPointDescription("Bottom"); odb_SectionPoint spBot = sCat.SectionPoint(sectionPointNumber, sectionPointDescription); sectionPointNumber = 3; sectionPointDescription = "Middle"; odb_SectionPoint spMid = sCat.SectionPoint(sectionPointNumber, sectionPointDescription); sectionPointNumber = 5; sectionPointDescription = "Top"; odb_SectionPoint spTop = sCat.SectionPoint(sectionPointNumber, sectionPointDescription); // Create few materials odb_MaterialApi materialApi; odb.extendApi(odb_Enum::odb_MATERIAL,materialApi); odb_String materialName("Elastic Material"); odb_Material& material_1 = materialApi.Material(materialName); odb_SequenceSequenceDouble myTable; odb_SequenceDouble myData; myData.append(12000.00);//youngs modulus myData.append(0.3);//poissons ratio myTable.append(myData); odb_String type("ISOTROPIC"); bool noCompression = false; bool noTension = false; bool temperatureDependency = false; int dependencies = 0; odb_String moduli("LONG_TERM"); material_1.Elastic(myTable, type, noCompression, noTension, temperatureDependency, dependencies, moduli); //create few sections odb_SectionApi sectionApi; odb.extendApi(odb_Enum::odb_SECTION, sectionApi); odb_String sectionName("Homogeneous Shell Section"); double thickness = 2.0; odb_HomogeneousShellSection& section_1 = sectionApi.HomogeneousShellSection(sectionName,thickness,materialName); // Create a 2-element shell model, //4 integration points, 5 section points. odb_Part& part1 = odb.Part("part-1", odb_Enum::THREE_D, odb_Enum::DEFORMABLE_BODY); odb_SequenceInt nodeLabels; for(n=1; n<7; n++) nodeLabels.append(n); double c[6][3] = { {1, 0, 0.0}, {2, 0, 0.0}, {2, 1, 0.1}, {1, 1, 0.1}, {2, -1, -0.1}, {1, -1, -0.1} }; odb_SequenceSequenceFloat nodeCoor; for(n=0; n`_. - **-largeOdb odbName** The name of the large output database generated by the original problem. The program copies selected frames from this output database. The following parameters are optional: - **-history** Copy all history output from all available steps in the large output database. By default, history output is not copied. .. warning:: Copying large amounts of history data can result in the program creating a very large output database. - **-debug** Print a detailed report of all the operations performed during the running of the program. By default, no debug information is generated. .. warning:: If you are extracting data from a large output database, the debug option can generate large amounts of information. You can also run the example with only the **-help** parameter for a summary of the usage. The following is an example of how you can use this program in conjunction with the output database generated by the problem described in `Free ring under initial velocity: comparison of rate-independent and rate-dependent plasticity `_. Use the following commands to retrieve the example program and the benchmark input file: .. code-block:: sh abaqus fetch job=odbFilter.C abaqus fetch job=ringshell.inp 1. Run an analysis using the benchmark input file: .. code-block:: sh abaqus job=ringshell This creates an output database called `ringshell.odb` that contains 100 frames of data. 1. Run a **datacheck** analysis to obtain a new output database called `ringshell_datacheck.odb` that contains the same model data as `ringshell.odb`: .. code-block:: sh abaqus job=ringshell_datacheck -input ringshell datacheck 1. Create the executable program: .. code-block:: sh abaqus make job=odbFilter.C The program displays the number of frames available in each step. For each step you must specify the number of increments between frames, which is the frequency at which the data will be copied to the new output database. Data for the first and last increment in each step are always copied. For example, if a step has 100 frames, and you enter a frame interval of 37, the program will copy data for frames 0, 37, 74, and 100. The following statement will run the executable program and read data from the small output database containing only model data and the large output database created by the benchmark example: .. code-block:: sh abaqus odbFilter -smallOdb ringshell_datacheck -largeOdb ringshell The program prompts you for the increment between frames: .. code-block:: sh Results from ODB : ringshell.odb will be filtered & written to ODB: ringshell_datacheck By default only the first & last increment of a step will be saved For each step enter the increment between frames for example : 3 => frames 0,3,6,..,lastframe will be saved STEP Step-1 has 101 Frames Enter Increment between frames Enter 37 to define the increment between frames. The program then reads the data and displays the frames being processed: .. code-block:: sh Processing frame # : 0 Processing frame # : 37 Processing frame # : 74 Processing frame # : 100 Filtering successfully completed Stress range for multiple load cases ------------------------------------ This example illustrates how you can use the envelope operations to compute the stress range over a number of load cases. The example program does the following: - For each load case during a specified step, the program collects the S11 components of the stress tensor fields into a list of scalar fields. - Computes the maximum and minimum of the S11 stress component using the envelope calculations. - Computes the stress range using the maximum and minimum values of the stress component. - Creates a new frame in the step. - Writes the computed stress range into a new FieldOutput object in the new frame. Use the following command to retrieve the example program: .. code-block:: sh 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-block:: cpp //////////////////////////////////////////////////// // 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 #else #include using namespace std; #endif // Begin Local Includes #include // 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)); } A C++ version of FELBOW ----------------------- This example illustrates the use of a C++ program to read selected element integration point records from an output database and to postprocess the elbow element results. The program creates **X - Y** data that can be plotted with the *X–Y* plotting capability in Abaqus/CAE. The program performs the same function as the Fortran program described in `Creation of a data file to facilitate the postprocessing of elbow element results: FELBOW `_. The program reads integration point data for elbow elements from an output database to visualize one of the following: 1. Variation of an output variable around the circumference of a given elbow element, or 2. Ovalization of a given elbow element. The program creates either an ASCII file containing *X–Y* data or a new output database file that can be viewed using Abaqus/CAE. To use option 2, you must ensure that the integration point coordinates (COORD) are written to the output database. For option 1 the *X*-data are data for the distance around the circumference of the elbow element, measured along the middle surface, and the *Y*-data are data for the output variable. For option 2 the *X–Y* data are the current coordinates of the middle-surface integration points around the circumference of the elbow element, projected to a local coordinate system in the plane of the deformed cross-section. The origin of the local system coincides with the center of the cross-section; the plane of the deformed cross-section is defined as the plane that contains the center of the cross-section. You should specify the name of the output database during program execution. The program prompts for more information, depending on the option that was chosen; this information includes the following: - Your choice for storing results (ASCII file or a new output database) - File name based on the above choice - The postprocessing option (1 or 2) - The part name - The step name - The frame number - The element output variable (option 1 only) - The component of the variable (option 1 only) - The section point number (option 1 only) - The element number or element set name Before program execution, compile and link the C++ program using the **abaqus make** utility: .. code-block:: sh abaqus make job=felbow.C After successful compilation, the program's object code is linked automatically with the Abaqus object codes stored in the shared program library and interface library to build the executable program. Refer to `Customizing the Abaqus environment `_ to see which compile and link commands are used for a particular computer. Before executing the program, run an analysis that creates an output database file containing the appropriate output. This analysis includes, for example, output for the elements and the integration point coordinates of the elements. Execute the program using the following command: .. code-block:: sh abaqus felbow The program prompts for other information, such as the desired postprocessing option, part name, etc. The program processes the data and produces a text file or a new output database file that contains the information required to visualize the elbow element results. `Elastic-plastic collapse of a thin-walled elbow under in-plane bending and internal pressure `_ contains several figures that can be created with the aid of this program.