[ANSYS, Inc. Logo] return to home search
next up previous contents index

2.2.5 DEFINE_EXECUTE_FROM_GUI



Description


DEFINE_EXECUTE_FROM_GUI is a general-purpose macro that you can use to define a UDF which is to be executed from a user-defined graphical user interface (GUI). For example, a C function that is defined using DEFINE_EXECUTE_FROM_GUI can be executed whenever a button is clicked in a user-defined GUI. Custom GUI components (dialog boxes, buttons, etc.) are defined in ANSYS FLUENT using the Scheme language.



Usage



DEFINE_EXECUTE_FROM_GUI( name, libname, mode)


Argument Type Description
symbol name UDF name.
char *libname name of the UDF library that has been loaded in ANSYS FLUENT
int mode an integer passed from the Scheme program that defines the
  user-defined GUI.
   
Function returns  
void  
   

There are three arguments to DEFINE_EXECUTE_FROM_GUI: name, libname, and mode. You supply name, the name of the UDF. The variables libname and mode are passed by the ANSYS FLUENT solver to your UDF. The integer variable mode is passed from the Scheme program which defines the user-defined GUI, and represent the possible user options available from the GUI dialog box. A different C function in UDF can be called for each option. For example, the user-defined GUI dialog box may have a number of buttons. Each button may be represented by different integers, which, when clicked, will execute a corresponding C function.

figure   

DEFINE_EXECUTE_FROM_GUI UDFs must be implemented as compiled UDFs, and there can be only one function of this type in a UDF library.



Example


The following UDF, named reset_udm, resets all user-defined memory (UDM) values when a reset button on a user-defined GUI dialog box is clicked. The clicking of the button is represented by $0$, which is passed to the UDF by the ANSYS FLUENT solver.

/*********************************************************
   UDF called from a user-defined GUI dialog box to reset 
   all user-defined memory locations                         
**********************************************************/
#include "udf.h"

DEFINE_EXECUTE_FROM_GUI(reset_udm, myudflib, mode)
{
	Domain *domain = Get_Domain(1); /* Get domain pointer */
	Thread *t;
	cell_t c;
	int i;

	/* Return if mode is not zero */
	if (mode != 0) return;

	/* Return if no User-Defined Memory is defined in ANSYS FLUENT */
        if (n_udm == 0) return;

        /* Loop over all cell threads in domain */
	thread_loop_c(t, domain)
        {
        /* Loop over all cells */
                begin_c_loop(c, t)
                      {
                        /* Set all UDMs to zero */
                        for (i = 0; i < n_udm; i++)
                               {
                                C_UDMI(c, t, i) = 0.0;
                               }
                       }
                end_c_loop(c, t);
        }
}



Hooking an Execute From GUI UDF to ANSYS FLUENT


After the UDF that you have defined using DEFINE_EXECUTE_FROM_GUI is compiled (Chapter  5), the function will not need to be hooked to ANSYS FLUENT through any graphics dialog boxes. Instead, the function will be searched automatically by the ANSYS FLUENT solver when the execution of the UDF is requested (i.e., when a call is made from a user-defined Scheme program to execute a C function).


next up previous contents index Previous: 2.2.4 DEFINE_EXECUTE_AT_EXIT
Up: 2.2 General Purpose DEFINE
Next: 2.2.6 DEFINE_EXECUTE_ON_LOADING
Release 12.0 © ANSYS, Inc. 2009-01-14