Friday, March 27, 2026

How to Save Ansys Fluent Contour Images Automatically on HPC Clusters

 This is a very common requirement when working on HPC clusters, as it saves massive amounts of disk space and allows you to monitor the physics without downloading gigabytes of data.

To do this in Ansys Fluent, you need to set up "Execute Commands" or "Solution Animations." Since you are running on an HPC (likely in batch mode), the most robust way is using the Execute Commands method combined with a TUI (Text User Interface) command.



1. Create the Contour Plot

Before setting up the automatic save, you must define the contour in the Fluent GUI (on your local machine before uploading).

  1. Go to Results > Graphics > Contours.

  2. Set up your velocity contour, select the surfaces, and give it a specific name (e.g., velocity-contour-1).

  3. Crucial: Display it once to make sure it looks exactly how you want.


2. Set Up the "Execute Command"

This is the "engine" that will tell the HPC to snap a picture at every time step.

  1. In the outline tree, go to Calculation Activities > Execute Commands.

  2. Click Create/Edit.

  3. In the first row, define:

    • Name: save-image

    • Every: 1

    • When: Time Step

    • Command: ```scheme /display/views/restore-view/front /display/objects/display velocity-contour-1 /display/save-picture "image-%t.png"

      
      

Breakdown of that command:

  • /display/views/restore-view/front: Forces the camera to a specific orientation (replace front with your saved view name).

  • /display/objects/display velocity-contour-1: Tells Fluent to "draw" the contour you created in Step 1.

  • /display/save-picture "image-%t.png": Saves the image. The %t is a wild card that automatically inserts the current time step number into the filename (e.g., image-0010.png).


3. Alternative: Using Solution Animations

If you prefer a more "visual" setup in the GUI:

  1. Go to Calculation Activities > Solution Animations.

  2. Click Create/Edit.

  3. Assign a name and set When to Time Step.

  4. Under Animation Object, select your velocity-contour-1.

  5. Click Storage Type and select Metafile or Hardcopy (Hardcopy will save the actual .png or .jpg files).

  6. Click Write to define the folder path.


4. Hardware and Performance Tips

  • Off-Screen Rendering: When running on an HPC in batch mode (without a GUI), Fluent uses "Hidden Line Removal" or X11. Ensure your submission script uses the -g flag (e.g., fluent 3ddp -g -t24 -i input.jou).

  • Image Format: Use .png for the best balance between quality and file size.

  • Disk I/O: Saving images is much faster than saving .dat files, but if you have thousands of time steps, ensure your HPC quota allows for a high number of small files.

No comments:

Post a Comment