## 25.19.2 Defining Macros

Macros that you define for automatic execution during the calculation can also be used interactively by you during the problem setup or postprocessing. For example, if you define a macro that performs a certain type of adaption after each iteration, you can also use the macro to perform this adaption interactively.

Definition of a macro is accomplished as follows:

1.   In the Execute Commands panel, click the Define Macro... button to open the Define Macro panel (Figure  25.19.2). Since this is a "modal'' panel, the solver will not allow you to do anything else until you perform step 2, below.

2.   In the Define Macro panel, specify a Name for the macro (e.g., adapt1) and click OK. (The Define Macro... button in the Execute Commands panel will become the End Macro button.)

3.   Perform the steps that you want the macro to perform. For example, if you want the macro to perform gradient adaption, open the Gradient Adaption panel, specify the appropriate adaption function and parameters, and click Adapt to perform the adaption.

 If the command to be executed involves saving a file, see Section  25.19.3 for important information.

4.   When you have completed the steps you wish the macro to perform, click the End Macro button in the Execute Commands panel.

As noted above, once you have defined a macro for execution during the calculation, you can use it at any time. If you defined the macro called adapt1 to adapt based on pressure gradient, you can simply type adapt1 in the console (text) window to perform this adaption. This macro is independent of any text menus, so you need not move to a different text menu to use it. Macros can be saved to and read from files. To save all macros that are currently defined, use the file/write-macros text command. To read all the macros in a macro file, use the file/read-macros text command.

 A macro, like a journal file, is a simple record/playback function. It will therefore know nothing about the state in which it was recorded or the state in which it is being played back. You must be careful not to change directories while defining a macro. Also, you must be careful that all surfaces, variables, etc. that are used by the macro have been properly defined when you (or FLUENT) invoke the macro.

Previous: 25.19.1 Specifying the Commands
Up: 25.19 Executing Commands During
Next: 25.19.3 Saving Files During