As described in Monitoring Solution Convergence and Animating the Solution, respectively, you can report and monitor various quantities (for example, residuals, force coefficients) and create animations of the solution while the solver is performing calculations. Ansys Fluent also includes a feature that allows you to define your own command(s) to be executed during the calculation at specified intervals. For example, you can ask Ansys Fluent to adapt the mesh based on gradient field value cell registers after a set number of iterations. You will specify a series of text commands or use the GUI to define the steps to be performed.
Important: Note that the Calculation Activities task page provides options to perform the following during the calculation:
save case and data files
export transient solution files
export transient particle history data files
Each of these options has their own dialog box, which should be used rather than executing a command to perform them. See Automatic Saving of Case and Data Files and Exporting Data During a Transient Calculation for details.
You will indicate the command(s) that you want the solver to execute at specified intervals during the calculation using the Execute Commands Dialog Box (Figure 36.41: The Execute Commands Dialog Box).
Solution → Calculation Activities → Execute Commands New...
The procedure is as follows:
Enable the Active check button if you want it to be executed during the calculation. You may define multiple commands and choose to use only a subset of them by turning off the check button for those that you do not want to use.
Enter a Name for the command.
Select Execute Repeatedly if the command(s) are to be repeated as part of a sequence.
Indicate how often you want the command to be executed by setting the interval under Every and selecting Iteration, Time Step, Flow Time, Adjoint Iteration, or Design Iteration in the drop-down list below When. ( Time Step and Flow Time are only valid choices if you are calculating unsteady flow, and Adjoint Iteration and Design Iteration are only available if you have opened the Execute Commands dialog box from the Gradient-Based Optimizer or Run Adjoint Calculation dialog box.) For example, to execute the command every 10 iterations, you would enter
10
under Every and select Iteration under When.Important: If you specify an interval in iterations, be sure to keep the Reporting Interval in the Run Calculation Task Page at its default value of 1.
Select Execute Once if the command(s) are only to be executed a single time.
Indicate how often the command is to be executed. You can enter the interval under Number and select Iteration, Time Step, Flow Time, Adjoint Iteration, or Design Iteration under At. (Time Step and Flow Time are only valid choices if you are calculating unsteady flow, and Adjoint Iteration and Design Iteration are only available if you have opened the Execute Commands dialog box from the Gradient-Based Optimizer or Run Adjoint Calculation dialog box.)
Select Execute At End if the command(s) are only to be executed at the end of the simulation.
Define the command by entering a series of text commands in the command text field on the right (using multiple lines if required), or by entering the name of a command macro you have defined (or will define) as described in Defining Macros.
Important:If the command to be executed involves saving a file, see Saving Files During the Calculation for important information.
If the command enables or disables equations, you must disable the convergence check for these equations.
Note: For any commands that are already defined in the Outline View, you can hover over them individually and Fluent will display a preview of the command properties.
You can keep track of your defined commands using the Execute Commands Manager Dialog Box (Figure 36.43: The Execute Commands Manager Dialog Box) dialog box.
Solution → Calculation Activities → Execute Commands Manage...
For additional information, see the following sections:
You can also use the macros that you define for automatic execution during the calculation, interactively during the problem setup or postprocessing. For example, if you define a macro that adapts the mesh after each iteration, you can also use the macro to perform this adaption interactively.
Definition of a macro is accomplished as follows:
In the Execute Commands Dialog Box, click the button to open the Define Macro Dialog Box (Figure 36.44: The Define Macro Dialog Box). Since this is a “modal” dialog box, the solver will not allow you to do anything else until you perform step 2, below.
In the Define Macro dialog box, specify a Name for the macro (for example,
adapt1
) and click . (The Define Macro... button in the Execute Commands dialog box will become the End Macro button.)Perform the steps that you want the macro to perform. For example, if you want the macro to perform adaption, open the Manual Mesh Adaption dialog box, specify the appropriate coarsening, refinement, and other parameters, and click to perform the adaption.
Important: If the command to be executed involves saving a file, see Saving Files During the Calculation for important information.
When you have completed the steps you want the macro to perform, click the Execute Commands dialog box.
button in the
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 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.
Important: 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, and so on that are used by the macro have been properly defined when you (or Ansys Fluent) invoke the macro.
If the command to be executed during the calculation involves saving a file, you should include a special character in the file name when you enter it in The Select File Dialog Box so that the solver will know to assign a new name to each file it saves. See Automatic Numbering of Files for details about these special characters for filenames.
Important: Note that the Calculation Activities task page provides options to perform the following during the calculation:
save case and data files
export transient solution files
export transient particle history data files
Each of these options has their own dialog box, which should be used rather than the Execute Commands dialog box. See Automatic Saving of Case and Data Files and Exporting Data During a Transient Calculation for details.