Use 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.
Register 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).
-
From the Compose editor, select the function name,
right-click, and select Register Function from the
context-sensitive menu.
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.
- Launch a HyperWorks product to see the function automatically loaded into the product.
Register 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:
*SetOMLRootDir(path)
where path is the path to the Compose installation.
The syntax for the *RegisterOMLFunction() statement is:
*RegisterOMLFunction(Function, File, Parameters)
- Function
- The name of the OML function. This is a string.
- File
- The name of the OML file where the function resides. This is a string.
- Parameters
- The number of parameters that the function accepts as input. This is for syntax presentation only.
*SetOMLRootDir("E:/COMPOSE/Compose_2017.3")
*RegisterOMLFunction("mymean","E:/ST_COMPOSE/mymean.oml",1)
where mymean is the function in the mymean.oml file and that function takes one argument as input.
function y = mymean(x)
b = 0.2*ones(1,5);
a = 1;
y = filter(b,a,x);
end
Use 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.
-
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); end if iresp(2) ~= 0 rresp(2) = rparam(1)/2.0 + rparam(2)/2.0; end if isens dresp(2,2) = rresp(1)/2.0 + rresp(2)/2.0; udata = 'sensitivity'; end %udata = 'user data'; end
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.Note: udata is an additional message. It displays in addition to the OptiStruct messages. -
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
- Load the OML file using this command: