Using OML Functions in HyperWorks Products

OML functions can be registered from the Compose graphical user interface or via a preference file and later opened in certain HyperWorks products.

Once registered, the OML functions are accessible in the following products, without invoking Compose: HyperGraph, HyperStudy, MotionView, and the HyperMesh Matrix Browser.

Registering OML Functions in Compose

This method allows you to automatically register OML functions directly from Compose.

To register a written function, make sure it is saved on disk first (*.oml file).

  1. From the Compose editor, select the function name, right-click, and select Register Function from the context-sensitive menu.
    Figure 1.

    This displays a dialog listing the function name, the number of inputs, and the .oml file location. To complete the registration, simply accept the dialog.
    Note: The dialog also displays all pre-existing functions registered earlier via this mechanism. From the dialog, you can edit and remove the items.
    Figure 2.

  2. Launch a HyperWorks product to see the function automatically loaded into the product.

Registering OML Functions Using a Preference File

You can register a function by creating a preference file and explicitly registering it with HyperWorks Desktop.

After registering an *.oml file with the *RegisterOMLFunction() statement in a HyperWorks preference file, the OML functions in the file are available in the following HyperWorks applications, just like any other internal math function: HyperStudy (response functions), TextView, HyperView (notes), HyperGraph (curves, notes, datum lines, and plot labels), and Templex.

The path to the Compose installation is required for the HyperWorks application to use a specific version of Compose:


where path is the path to the Compose installation.

The syntax for the *RegisterOMLFunction() statement is:

*RegisterOMLFunction(Function, File, Parameters)


The name of the OML function. This is a string.
The name of the OML file where the function resides. This is a string.
The number of parameters that the function accepts as input. This is for syntax presentation only.
An example with a fixed number of parameters:

where mymean is the function in the mymean.oml file and that function takes one argument as input.

The file mymean.oml could look like this:

function y = mymean(x)
      b = 0.2*ones(1,5);
      a = 1;
      y = filter(b,a,x);

Using an OML function in an OptiStruct DRESP3 Bulk Data Entry:

In OptiStruct, the DRESP3 Bulk Data Entry allows you to define responses through user-defined external functions.

Among other formats, the external functions may be written in the OML language.
Note: This feature is available in the HyperWorks Solvers release 2017.2.2.
  1. Create an OML function in an ..oml file, using the signature described below.
    OML function for DRESP3 sample function:
    function [rresp, dresp, udata] = myDRE(iparam, rparam, nparam, iresp, rresp, dresp, nresp, isens, udata)
    %   iparam - vector of ints
    %   rparam - vector of doubles
    %   nparam - size of input vector
    %   iresp - vector of ints
    %   rresp - output parameter (vector of ints)
    %   dresp - output parameter (matrix of MxN dimension)
    %   nresp - size of output vector
    %   isens - sensitivity flag
    %   udata - userdata 
     if iresp(1) ~= 0
      rresp(1) = rparam(1) + rparam(2);
     if iresp(2) ~= 0
      rresp(2) = rparam(1)/2.0 + rparam(2)/2.0;
     if isens
        dresp(2,2) = rresp(1)/2.0 + rresp(2)/2.0;
    	udata = 'sensitivity';
    %udata = 'user data';
    Note: If isens is set to 1, then the OML function must compute and provide the sensitivities to OptiStruct through dresp. The dresp array must be populated only if the isens flag is ON.

    udata is an additional message. It displays in addition to the OptiStruct messages.

  2. Load and use this function in the OptiStruct deck (.fem)
    In the OptiStruct input deck, the following is needed:
    • Load the OML file using this command:
      LOADLIB DRESP3 HLIB 'dresp3.oml'
    • Example using the OML function myDRE
      DRESP3  6           SUMH    HLIB   myDRE       1       2
      +      DRESP1         2       3