Include files:
The following header file is required in any file containing these library routines.
#include
"/udmf_extern.h"
/*--------------------------------------------------------------------
USERD_get_name_of_mf
*-------------------------------------------------------------------- * * Gets the name of the math function, so gui can list as a calculator * function. * * (OUT) mf_name = the name of the math function * (max length is UDMFSNAME, which is 64) * * returns: Z_OK if successful * Z_ERR if not successful * *--------------------------------------------------------------------*/ int USERD_get_name_of_mf(char mf_name[UDMFSNAME]) /*--------------------------------------------------------------------
USERD_get_mf_version
*--------------------------------------------------------------------
*
* Gets the version number of the user defined math function supported API
*
* (OUT) version_number = the version number of the math function
* (max length is UDMFSNAME, which is 64)
*
* returns: Z_OK if successful
* Z_ERR if not successful
*
* Notes:
* * version needs to be "1.000".
*--------------------------------------------------------------------*/
int
USERD_get_mf_version(char version_number[UDMFSNAME]) {
strcpy(version_number, "1.000");
return(Z_OK);
}
/*--------------------------------------------------------------------
USERD_get_nargs
*--------------------------------------------------------------------
*
* Gets the number of arguments needed by the function.
*
* (OUT) nArgs = the number of arguments
*
* returns: Z_OK if successful
* Z_ERR if not successful
*
*--------------------------------------------------------------------*/
int
USERD_get_nargs(int *nArgs) {
*nArgs = 2;
return(Z_OK);
}
/*--------------------------------------------------------------------
USERD_get_meta_data
*--------------------------------------------------------------------
*
* Get the function descriptions, argument types, and return type.
*
* (OUT) listDescription = description shown in general function column
* (OUT) funcDescription = description shown in feedback window
* (OUT) argTypes = data types of arguments passed into USERD_evaluate
* (OUT) returnType = data type returned by function USERD_evaluate
*
* returns: Z_OK if successful
* Z_ERR if not successful
*
*--------------------------------------------------------------------*/
int
USERD_get_meta_data(char listDescription[UDMFLNAME],
char funcDescription[UDMFLNAME],
int *argTypes, int *returnType) {
strcpy(listDescription, "add2(part, scalar, scalar)");
strcpy(funcDescription, "add2(any part(s), scalar, scalar)");
argTypes[0] = UDMFSCL;
argTypes[1] = UDMFSCL;
*returnType = UDMFSCL;
return(Z_OK);
}
/*--------------------------------------------------------------------
USERD_evaluate
*--------------------------------------------------------------------
* Note: see math_functions/example1/libudmf-ex1.c
* Evaluate the function.
*
* (OUT) args = pointers to arguments
* args[0] = pointer to the first variable needed by the function
* args[1] = pointer to the second variable needed by the function
* ...
* args[n] = pointer to the last variable needed by the function
* EnSight 10.1 adds args[n+1] and args[n+2] as follows
* args[n+1] is a float that is the number of nodes
* when computing a constant then num_nodes = 0.
* when computing a per-node variable num_nodes = 1
* when computing a per-element variable num_nodes
* is the number of nodes is the element being processed.
* args[n+2] is the coordinates, x1,y1,z1,x2,y2,z2,...
* if xyz = args[3] then,
* xyz[0] = x coordinate of the first node
* xyz[1] = y coordinate of the first node
* xyz[2] = z coordinate of the first node
* xyz[3] = x coordinate of the second node
* xyz[4] = y coordinate of the second node
*
* (OUT) undefined = boolean; true if return value is undefined.
* (OUT) value = returned value
*
* returns: Z_OK if successful
* Z_ERR if not successful
*--------------------------------------------------------------------*/
int
USERD_evaluate(void *args[], void *value, int *undefined) {
int i, j, num_nodes;
float *result;
float *arg1, *arg2;
float *num_nodes_float;
float *xyz;
result = value;
arg1 = args[0];
arg2 = args[1];
num_nodes_float = args[2];
xyz = args[3];
num_nodes = *num_nodes_float;
if(*num_nodes_float - num_nodes > .5) {
++num_nodes;
}
fprintf(stderr,"number of nodes from udmf = %d\n",num_nodes);
for(i=0; i<num_nodes; ++i) {
fprintf(stderr,"x/y/z coords = %f %f %f\n",xyz[i*3],xyz[i*3+1],xyz[i*3+2]);
}
*result = *arg1 + *arg2;
*undefined = 0;
return(Z_OK);
}