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, and so on)
are defined in ANSYS Fluent using the Scheme language.
DEFINE_EXECUTE_FROM_GUI (name, libname, mode)
|
Argument Type |
Description |
|---|---|
|
|
UDF name. |
|
|
name of the UDF library that has been loaded in ANSYS Fluent. |
|
|
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.
Important:
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.
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 , 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);
}
}
After the UDF that you have defined using DEFINE_EXECUTE_FROM_GUI is compiled (Compiling UDFs), 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 (that is, when a call is made from a user-defined Scheme
program to execute a C function).